Search in sources :

Example 1 with OIndexRIDContainerSBTree

use of com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainerSBTree in project orientdb by orientechnologies.

the class OStreamSerializerSBTreeIndexRIDContainer method serializeNativeObject.

@Override
public void serializeNativeObject(OIndexRIDContainer object, byte[] stream, int offset, Object... hints) {
    LONG_SERIALIZER.serializeNative(object.getFileId(), stream, offset + FILE_ID_OFFSET);
    final boolean embedded = object.isEmbedded();
    final boolean durable = object.isDurableNonTxMode();
    BOOLEAN_SERIALIZER.serializeNative(embedded, stream, offset + EMBEDDED_OFFSET);
    BOOLEAN_SERIALIZER.serializeNative(durable, stream, offset + DURABLE_OFFSET);
    if (embedded) {
        INT_SERIALIZER.serializeNative(object.size(), stream, offset + EMBEDDED_SIZE_OFFSET);
        int p = offset + EMBEDDED_VALUES_OFFSET;
        for (OIdentifiable ids : object) {
            LINK_SERIALIZER.serializeNativeObject(ids, stream, p);
            p += RID_SIZE;
        }
    } else {
        final OIndexRIDContainerSBTree underlying = (OIndexRIDContainerSBTree) object.getUnderlying();
        final OBonsaiBucketPointer rootPointer = underlying.getRootPointer();
        LONG_SERIALIZER.serializeNative(rootPointer.getPageIndex(), stream, offset + SBTREE_ROOTINDEX_OFFSET);
        INT_SERIALIZER.serializeNative(rootPointer.getPageOffset(), stream, offset + SBTREE_ROOTOFFSET_OFFSET);
    }
}
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)

Example 2 with OIndexRIDContainerSBTree

use of com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainerSBTree in project orientdb by orientechnologies.

the class OStreamSerializerSBTreeIndexRIDContainer method deserializeFromByteBufferObject.

/**
   * {@inheritDoc}
   */
@Override
public OIndexRIDContainer deserializeFromByteBufferObject(ByteBuffer buffer, OWALChanges walChanges, int offset) {
    final long fileId = walChanges.getLongValue(buffer, offset + FILE_ID_OFFSET);
    final boolean durable = walChanges.getByteValue(buffer, offset + DURABLE_OFFSET) > 0;
    if (walChanges.getByteValue(buffer, offset + EMBEDDED_OFFSET) > 0) {
        final int size = walChanges.getIntValue(buffer, 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.deserializeFromByteBufferObject(buffer, walChanges, p));
            p += RID_SIZE;
        }
        return new OIndexRIDContainer(fileId, underlying, durable);
    } else {
        final long pageIndex = walChanges.getLongValue(buffer, offset + SBTREE_ROOTINDEX_OFFSET);
        final int pageOffset = walChanges.getIntValue(buffer, 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 3 with OIndexRIDContainerSBTree

use of com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainerSBTree 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 4 with OIndexRIDContainerSBTree

use of com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainerSBTree 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 5 with OIndexRIDContainerSBTree

use of com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainerSBTree 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

OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)5 OIndexRIDContainerSBTree (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainerSBTree)5 OBonsaiBucketPointer (com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer)5 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)3 OIndexRIDContainer (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainer)3 HashSet (java.util.HashSet)3