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...rombert:f
eatures/nodestore-multiplex?expand=1
[2]: https://github.com/rombert/jackrabbit-oak/blob/99cd3d8b81213fa03a2
ebee2ad754081dbd5977f/oak-
it/src/test/java/org/apache/jackrabbit/oak/plugins/memory/multiplex/Mul
tiplexingMemoryNodeStoreTest.java

Reply via email to