On 8.8.16 12:46 , Robert Munteanu wrote:
On Mon, 2016-08-08 at 12:45 +0200, Michael Dürig wrote:
The segment node store inlines blobs up to a size of 16512 bytes.
This
is probably the reason you are not able to get them from the blob
store.
Good point. So it's expected that this happens and to test blob
handling I would need to use 'large' blobs?
If you want them to go into the blob store, yes.
Michael
Robert
Michael
On 8.8.16 12:38 , Robert Munteanu wrote:
Hi,
I'm trying to understand the behaviour of NodeStore.createBlob and
NodeStore.getBlob. For context, I'm experimenting with creating a
MultiplexingNodeStore [1] , and this multiplexing would neet to
include
the blob handling as well.
But before that, I'm trying to understand something basic :-)
I have created a SegmentNodeStore with a FileBlobStore
BlobStore blobStore = new FileBlobStore(blobStorePath);
FileStore store =
FileStore.builder(storePath).withBlobStore(blobStore).build();
SegmentNodeStore instance =
SegmentNodeStore.builder(store).build();
After that I have tried to retrieve a blob from the same store
Blob createdBlob = globalStore.createBlob(SMALL_BLOB);
Blob retrievedBlob =
globalStore.getBlob(createdBlob.getReference());
where
private static final InputStream SMALL_BLOB = new
ByteArrayInputStream("hello, world".getBytes());
To my surprise, retrievedBlob is null, since it has a null id.
I've traced the calls to understand what is going on, and in
SegmentBlob.getBlobId() the blobId is null, since the 'head'
variable
is the following code has the value 0.
byte head = segment.readByte(offset);
if ((head & 0xf0) == 0xe0) {
// 1110 xxxx: external value, small blob ID
return readShortBlobId(segment, offset, head);
} else if ((head & 0xf8) == 0xf0) {
// 1111 0xxx: external value, long blob ID
return readLongBlobId(segment, offset);
} else {
return null;
}
Now, this works as expected for a DocumentNodeStore backed by H2,
so
something is not entirely right.
So my question is - why does this happen?
1) Is this sequence of calls (createBlob/getBlob) not supposed to
be
symmetric?
2) Am I configuring the SegmentNodeStore incorrectly?
3) Is it a bug to file against the SegmentNodeStore?
If you're curious, the full test code is at [2], although I haven't
committed the variant which checks the SegmentNodeStore for blob
handling consistency.
Thanks,
Robert
[1]: https://github.com/apache/jackrabbit-oak/compare/trunk...rombe
rt:f
eatures/nodestore-multiplex?expand=1
[2]: https://github.com/rombert/jackrabbit-oak/blob/99cd3d8b81213fa
03a2
ebee2ad754081dbd5977f/oak-
it/src/test/java/org/apache/jackrabbit/oak/plugins/memory/multiplex
/Mul
tiplexingMemoryNodeStoreTest.java