use of com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer in project orientdb by orientechnologies.
the class OStreamSerializerSBTreeIndexRIDContainer method deserializeFromByteBufferObject.
/**
* {@inheritDoc}
*/
@Override
public OIndexRIDContainer deserializeFromByteBufferObject(ByteBuffer buffer) {
final long fileId = buffer.getLong();
final boolean embedded = buffer.get() > 0;
final boolean durable = buffer.get() > 0;
if (embedded) {
final int size = buffer.getInt();
final Set<OIdentifiable> underlying = new HashSet<OIdentifiable>(Math.max((int) (size / .75f) + 1, 16));
for (int i = 0; i < size; i++) {
underlying.add(LINK_SERIALIZER.deserializeFromByteBufferObject(buffer));
}
return new OIndexRIDContainer(fileId, underlying, durable);
} else {
final long pageIndex = buffer.getLong();
final int pageOffset = buffer.getInt();
final OBonsaiBucketPointer rootPointer = new OBonsaiBucketPointer(pageIndex, pageOffset);
final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get();
final OIndexRIDContainerSBTree underlying = new OIndexRIDContainerSBTree(fileId, rootPointer, durable, (OAbstractPaginatedStorage) db.getStorage().getUnderlying());
return new OIndexRIDContainer(fileId, underlying, durable);
}
}
use of com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer in project orientdb by orientechnologies.
the class OStreamSerializerSBTreeIndexRIDContainer method deserializeNativeObject.
@Override
public OIndexRIDContainer deserializeNativeObject(byte[] stream, int offset) {
final long fileId = LONG_SERIALIZER.deserializeNative(stream, offset + FILE_ID_OFFSET);
final boolean durable = BOOLEAN_SERIALIZER.deserializeNative(stream, offset + DURABLE_OFFSET);
if (BOOLEAN_SERIALIZER.deserializeNative(stream, offset + EMBEDDED_OFFSET)) {
final int size = INT_SERIALIZER.deserializeNative(stream, offset + EMBEDDED_SIZE_OFFSET);
final Set<OIdentifiable> underlying = new HashSet<OIdentifiable>(Math.max((int) (size / .75f) + 1, 16));
int p = offset + EMBEDDED_VALUES_OFFSET;
for (int i = 0; i < size; i++) {
underlying.add(LINK_SERIALIZER.deserializeNativeObject(stream, p));
p += RID_SIZE;
}
return new OIndexRIDContainer(fileId, underlying, durable);
} else {
final long pageIndex = LONG_SERIALIZER.deserializeNative(stream, offset + SBTREE_ROOTINDEX_OFFSET);
final int pageOffset = INT_SERIALIZER.deserializeNative(stream, offset + SBTREE_ROOTOFFSET_OFFSET);
final OBonsaiBucketPointer rootPointer = new OBonsaiBucketPointer(pageIndex, pageOffset);
final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get();
final OIndexRIDContainerSBTree underlying = new OIndexRIDContainerSBTree(fileId, rootPointer, durable, (OAbstractPaginatedStorage) db.getStorage().getUnderlying());
return new OIndexRIDContainer(fileId, underlying, durable);
}
}
use of com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer in project orientdb by orientechnologies.
the class OStreamSerializerSBTreeIndexRIDContainer method serializeInByteBufferObject.
/**
* {@inheritDoc}
*/
@Override
public void serializeInByteBufferObject(OIndexRIDContainer object, ByteBuffer buffer, Object... hints) {
buffer.putLong(object.getFileId());
final boolean embedded = object.isEmbedded();
final boolean durable = object.isDurableNonTxMode();
buffer.put((byte) (embedded ? 1 : 0));
buffer.put((byte) (durable ? 1 : 0));
if (embedded) {
buffer.putInt(object.size());
for (OIdentifiable ids : object) {
LINK_SERIALIZER.serializeInByteBufferObject(ids, buffer);
}
} else {
final OIndexRIDContainerSBTree underlying = (OIndexRIDContainerSBTree) object.getUnderlying();
final OBonsaiBucketPointer rootPointer = underlying.getRootPointer();
buffer.putLong(rootPointer.getPageIndex());
buffer.putInt(rootPointer.getPageOffset());
}
}
Aggregations