Keys, Values and Entries

In a Bocas repository values a just opaque binary objects and the keys are hashes of those values.


An entry key is represented by a ByteString, which is an immutable byte array class provided by Derquinse Commons, based on the one included in the Google's Protocol Buffer code.   


In order to support arbitrary access methods to the values, they are not represented by a byte array but using streams. To further simply the management of those stream the InputSupplier abstraction from Guava is used. However, methods for obtaining entries from the repository wrap the data in a BocasValue, in order to provide some additional functionality:
The gadget spec URL could not be found

The basic operations are obtaining the size of the value (if known) and copying the value to a byte array. Please be warned that a new array is allocated and a new copy is performed each time this method is called. There are three kinds of values, depending on the origin of the supplied streams:
  • For the default BocasValues, the stream origin is completely undefined. It may be memory, a file system, a remote resource,...
  • There are also loaded values, which are backed by a byte array allocated in the Java heap.
  • Finally, there are direct values, backed by direct buffers, which are stored outside of the Java managed heap and are the base for "big memory" support in Derquinse Bocas.
The BocasValue class provides methods to turn any value into a loaded or direct one:
The gadget spec URL could not be found


There are also three types representing entries (key and value) in the repository that are used mainly as a support for implementations:
The gadget spec URL could not be found

These three types, BocasEntry, LoadedBocasEntry and DirectBocasEntry, correspond to the three kind of values.