Search in sources :

Example 6 with OBonsaiBucketPointer

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);
    }
}
Also used : OBonsaiBucketPointer(com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer) OIndexRIDContainer(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainer) OIndexRIDContainerSBTree(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainerSBTree) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal) HashSet(java.util.HashSet)

Example 7 with OBonsaiBucketPointer

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);
    }
}
Also used : OBonsaiBucketPointer(com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer) OIndexRIDContainer(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainer) OIndexRIDContainerSBTree(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainerSBTree) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal) HashSet(java.util.HashSet)

Example 8 with OBonsaiBucketPointer

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());
    }
}
Also used : OBonsaiBucketPointer(com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer) OIndexRIDContainerSBTree(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainerSBTree) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Aggregations

OBonsaiBucketPointer (com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer)8 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)5 OIndexRIDContainerSBTree (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainerSBTree)5 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)4 OIndexRIDContainer (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainer)3 HashSet (java.util.HashSet)3 OModifiableInteger (com.orientechnologies.common.types.OModifiableInteger)1 OBonsaiCollectionPointer (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OBonsaiCollectionPointer)1 Change (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OSBTreeRidBag.Change)1 ORecord (com.orientechnologies.orient.core.record.ORecord)1 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)1 ORecordSerializationContext (com.orientechnologies.orient.core.storage.impl.local.paginated.ORecordSerializationContext)1 ORidBagUpdateSerializationOperation (com.orientechnologies.orient.core.storage.impl.local.paginated.ORidBagUpdateSerializationOperation)1 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)1