Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "SMILA/Documentation/Binary Storage"

Line 14: Line 14:
  
 
In the next future there will be other available managers that provides the appropriate implementation for Binary Storage persistence structure.
 
In the next future there will be other available managers that provides the appropriate implementation for Binary Storage persistence structure.
 +
 +
== Binary Storage API ==
 +
 +
<source lang="java">
 +
void store(String id, InputStream stream);
 +
void store(String id, byte[] blob)
 +
byte[] fetchAsByte(String id)
 +
InputStream fetchAsStream(String id)
 +
void remove(String id)
 +
int fetchSize(String id)
 +
</source>
 +
 +
== Binary Storage Usage ==
 +
 +
<source lang="java">
 +
BinaryStorageService binaryStorageService = ...; // Obtain the binary storage service
 +
String attacmentIdKey = ...; // Unique ID
 +
byte[] dataRecord = ... // Build record
 +
 +
binaryStorageService.store(attacmentIdKey, dataRecord);
 +
 +
final InputStream stream = binaryStorageService.fetchAsStream(attacmentIdKey);
 +
 +
final String newAttacmentIdKey = _attacmentIdKey + "0000";
 +
_binaryStorageService.store(newAttacmentIdKey, stream);
 +
stream.close();
 +
 +
final byte[] recordByte = _binaryStorageService.fetchAsByte(newAttacmentIdKey);
 +
final String returnedContent = new String(recordByte);
 +
 +
final int sizeInitial = _binaryStorageService.fetchSize(_attacmentIdKey);
 +
final int sizeFinal = _binaryStorageService.fetchSize(newAttacmentIdKey);
 +
 +
binaryStorageService.remove(attacmentIdKey);
 +
binaryStorageService.remove(newAttacmentIdKey);
 +
</source>

Revision as of 08:29, 11 November 2008

Overview

Binary Storage Service provides an easy way to store / access binary data documents.

Client components access the Binary Storage Service for persisting binary data (attachments) into the binary storage. The binary data are identified by a unique key / identifier as a String data type.

Binary Storage Configuration

Currently, Binary Storage is able to run and store data into a hierarchical structure (uses deterministically calculation based on the hash id passed by the client component, like the ID passed from the Blackboard Service) and flat structure.

To configure the needed persistence storage structure, simply edit the /configuration/binarystorageconfig.properties file and change the value of 'bss.manager.class' key field to one of the following available possibilities :

  • org.eclipse.smila.binarystorage.internal.impl.persistence.filesystem.IOHierarchicalManager
  • org.eclipse.smila.binarystorage.internal.impl.persistence.filesystem.IOFlatManager

In the next future there will be other available managers that provides the appropriate implementation for Binary Storage persistence structure.

Binary Storage API

void store(String id, InputStream stream);
void store(String id, byte[] blob)
byte[] fetchAsByte(String id)
InputStream fetchAsStream(String id)
void remove(String id)
int fetchSize(String id)

Binary Storage Usage

BinaryStorageService binaryStorageService = ...; // Obtain the binary storage service
String attacmentIdKey = ...; // Unique ID
byte[] dataRecord = ... // Build record
 
binaryStorageService.store(attacmentIdKey, dataRecord);
 
final InputStream stream = binaryStorageService.fetchAsStream(attacmentIdKey);
 
final String newAttacmentIdKey = _attacmentIdKey + "0000";
_binaryStorageService.store(newAttacmentIdKey, stream);
stream.close();
 
final byte[] recordByte = _binaryStorageService.fetchAsByte(newAttacmentIdKey);
final String returnedContent = new String(recordByte);
 
final int sizeInitial = _binaryStorageService.fetchSize(_attacmentIdKey);
final int sizeFinal = _binaryStorageService.fetchSize(newAttacmentIdKey);
 
binaryStorageService.remove(attacmentIdKey);
binaryStorageService.remove(newAttacmentIdKey);

Copyright © Eclipse Foundation, Inc. All Rights Reserved.