Search in sources :

Example 6 with OBonsaiCollectionPointer

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

the class OCollectionNetworkSerializer method readCollectionPointer.

public OBonsaiCollectionPointer readCollectionPointer(final OChannelBinary client) throws IOException {
    final long fileId = client.readLong();
    final OBonsaiBucketPointer rootPointer = readBonsaiBucketPointer(client);
    return new OBonsaiCollectionPointer(fileId, rootPointer);
}
Also used : OBonsaiBucketPointer(com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer) OBonsaiCollectionPointer(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OBonsaiCollectionPointer)

Example 7 with OBonsaiCollectionPointer

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

the class OSBTreeCollectionManagerRemoteTest method testLoadTree.

@Test
public void testLoadTree() throws Exception {
    OSBTreeCollectionManagerRemote remoteManager = new OSBTreeCollectionManagerRemote(storageMock, networkSerializerMock);
    OSBTreeBonsai<OIdentifiable, Integer> tree = remoteManager.loadTree(new OBonsaiCollectionPointer(EXPECTED_FILE_ID, EXPECTED_ROOT_POINTER));
    assertNotNull(tree);
    assertEquals(tree.getFileId(), EXPECTED_FILE_ID);
    assertEquals(tree.getRootBucketPointer(), EXPECTED_ROOT_POINTER);
}
Also used : OBonsaiCollectionPointer(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OBonsaiCollectionPointer) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) Test(org.testng.annotations.Test)

Example 8 with OBonsaiCollectionPointer

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

the class OSBTreeCollectionManagerRemoteTest method testCreateTree.

@Test(enabled = false)
public void testCreateTree() throws Exception {
    OSBTreeCollectionManagerRemote remoteManager = new OSBTreeCollectionManagerRemote(storageMock, networkSerializerMock);
    ODatabaseRecordThreadLocal.INSTANCE.set(dbMock);
    when(dbMock.getStorage()).thenReturn(storageMock);
    when(storageMock.getUnderlying()).thenReturn(storageMock);
    when(storageMock.beginRequest(Mockito.any(OChannelBinaryAsynchClient.class), eq(OChannelBinaryProtocol.REQUEST_CREATE_SBTREE_BONSAI), Mockito.any(OStorageRemoteSession.class))).thenReturn(clientMock);
    when(networkSerializerMock.readCollectionPointer(Mockito.<OChannelBinaryAsynchClient>any())).thenReturn(new OBonsaiCollectionPointer(EXPECTED_FILE_ID, EXPECTED_ROOT_POINTER));
    OSBTreeBonsaiRemote<OIdentifiable, Integer> tree = remoteManager.createTree(EXPECTED_CLUSTER_ID);
    assertNotNull(tree);
    assertEquals(tree.getFileId(), EXPECTED_FILE_ID);
    assertEquals(tree.getRootBucketPointer(), EXPECTED_ROOT_POINTER);
    verify(dbMock).getStorage();
    verifyNoMoreInteractions(dbMock);
    verify(storageMock).getUnderlying();
    verify(storageMock).beginRequest(Mockito.any(OChannelBinaryAsynchClient.class), eq(OChannelBinaryProtocol.REQUEST_CREATE_SBTREE_BONSAI), Mockito.any(OStorageRemoteSession.class));
    verify(clientMock).writeInt(eq(EXPECTED_CLUSTER_ID));
    verify(storageMock).endRequest(Matchers.same(clientMock));
    verify(storageMock).beginResponse(Matchers.same(clientMock), Mockito.any(OStorageRemoteSession.class));
    verify(networkSerializerMock).readCollectionPointer(Matchers.same(clientMock));
    verify(storageMock).endResponse(Matchers.same(clientMock));
    verifyNoMoreInteractions(storageMock);
}
Also used : OBonsaiCollectionPointer(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OBonsaiCollectionPointer) OChannelBinaryAsynchClient(com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) Test(org.testng.annotations.Test)

Example 9 with OBonsaiCollectionPointer

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

the class SBTreeBagDeleteTest method testDeleteRidbagNoTx.

@Test
public void testDeleteRidbagNoTx() {
    ODocument doc = new ODocument();
    ORidBag bag = new ORidBag();
    int size = OGlobalConfiguration.INDEX_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.getValueAsInteger() * 2;
    for (int i = 0; i < size; i++) bag.add(new ORecordId(10, i));
    doc.field("bag", bag);
    ORID id = db.save(doc).getIdentity();
    bag = doc.field("bag");
    OBonsaiCollectionPointer pointer = bag.getPointer();
    db.delete(doc);
    doc = db.load(id);
    assertNull(doc);
    ((OSBTreeCollectionManagerShared) db.getSbTreeCollectionManager()).clear();
    OSBTreeBonsai<OIdentifiable, Integer> tree = db.getSbTreeCollectionManager().loadSBTree(pointer);
    assertNull(tree);
}
Also used : OBonsaiCollectionPointer(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OBonsaiCollectionPointer) ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) ORID(com.orientechnologies.orient.core.id.ORID) OSBTreeCollectionManagerShared(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OSBTreeCollectionManagerShared) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 10 with OBonsaiCollectionPointer

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

the class ONetworkProtocolBinary method sbTreeBonsaiFirstKey.

private void sbTreeBonsaiFirstKey(OClientConnection connection) throws IOException {
    setDataCommandInfo(connection, "SB-Tree bonsai get first key");
    OBonsaiCollectionPointer collectionPointer = OCollectionNetworkSerializer.INSTANCE.readCollectionPointer(channel);
    final OSBTreeCollectionManager sbTreeCollectionManager = connection.getDatabase().getSbTreeCollectionManager();
    final OSBTreeBonsai<OIdentifiable, Integer> tree = sbTreeCollectionManager.loadSBTree(collectionPointer);
    if (tree == null)
        throw new ORecordContentNotFoundException(collectionPointer);
    try {
        OIdentifiable result = tree.firstKey();
        final OBinarySerializer<? super OIdentifiable> keySerializer;
        if (result == null) {
            keySerializer = ONullSerializer.INSTANCE;
        } else {
            keySerializer = tree.getKeySerializer();
        }
        byte[] stream = new byte[OByteSerializer.BYTE_SIZE + keySerializer.getObjectSize(result)];
        OByteSerializer.INSTANCE.serialize(keySerializer.getId(), stream, 0);
        keySerializer.serialize(result, stream, OByteSerializer.BYTE_SIZE);
        beginResponse();
        try {
            sendOk(connection, clientTxId);
            channel.writeBytes(stream);
        } finally {
            endResponse(connection);
        }
    } finally {
        sbTreeCollectionManager.releaseSBTree(collectionPointer);
    }
}
Also used : OBonsaiCollectionPointer(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OBonsaiCollectionPointer) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) OSBTreeCollectionManager(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OSBTreeCollectionManager)

Aggregations

OBonsaiCollectionPointer (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OBonsaiCollectionPointer)14 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)9 OSBTreeCollectionManager (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OSBTreeCollectionManager)6 ORecordId (com.orientechnologies.orient.core.id.ORecordId)3 Test (org.testng.annotations.Test)3 OPair (com.orientechnologies.common.util.OPair)2 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)2 OSBTreeCollectionManagerShared (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OSBTreeCollectionManagerShared)2 ORID (com.orientechnologies.orient.core.id.ORID)2 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2 Test (org.junit.Test)2 OChannelBinaryAsynchClient (com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient)1 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)1 OSBTreeRidBag (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OSBTreeRidBag)1 OTreeInternal (com.orientechnologies.orient.core.index.sbtree.OTreeInternal)1 OBonsaiBucketPointer (com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer)1 OSBTreeBonsaiLocal (com.orientechnologies.orient.core.index.sbtreebonsai.local.OSBTreeBonsaiLocal)1 OAbstractPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage)1 OAtomicOperationsManager (com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperationsManager)1 Entry (java.util.Map.Entry)1