Search in sources :

Example 26 with OWALChangesTree

use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree in project orientdb by orientechnologies.

the class OCompositeKeyTest method testWALChangesBinarySerializationCompositeKeyNull.

public void testWALChangesBinarySerializationCompositeKeyNull() {
    final int serializationOffset = 5;
    final OCompositeKey compositeKey = new OCompositeKey();
    compositeKey.addKey(1);
    compositeKey.addKey(null);
    compositeKey.addKey(2);
    final int len = OCompositeKeySerializer.INSTANCE.getObjectSize(compositeKey);
    final ByteBuffer buffer = ByteBuffer.allocateDirect(len + serializationOffset).order(ByteOrder.nativeOrder());
    final byte[] data = new byte[len];
    OCompositeKeySerializer.INSTANCE.serializeNativeObject(compositeKey, data, 0);
    final OWALChanges walChanges = new OWALChangesTree();
    walChanges.setBinaryValue(buffer, data, serializationOffset);
    Assert.assertEquals(OCompositeKeySerializer.INSTANCE.getObjectSizeInByteBuffer(buffer, walChanges, serializationOffset), len);
    Assert.assertEquals(OCompositeKeySerializer.INSTANCE.deserializeFromByteBufferObject(buffer, walChanges, serializationOffset), compositeKey);
}
Also used : OWALChangesTree(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree) OWALChanges(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChanges) ByteBuffer(java.nio.ByteBuffer)

Example 27 with OWALChangesTree

use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree in project orientdb by orientechnologies.

the class LinkSerializerTest method testSerializeWALChanges.

public void testSerializeWALChanges() {
    final int serializationOffset = 5;
    final ByteBuffer buffer = ByteBuffer.allocateDirect(FIELD_SIZE + serializationOffset);
    final byte[] data = new byte[FIELD_SIZE];
    linkSerializer.serializeNativeObject(OBJECT, data, 0);
    final OWALChanges walChanges = new OWALChangesTree();
    walChanges.setBinaryValue(buffer, data, serializationOffset);
    Assert.assertEquals(linkSerializer.getObjectSizeInByteBuffer(buffer, walChanges, serializationOffset), FIELD_SIZE);
    Assert.assertEquals(linkSerializer.deserializeFromByteBufferObject(buffer, walChanges, serializationOffset), OBJECT);
}
Also used : OWALChangesTree(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree) OWALChanges(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChanges) ByteBuffer(java.nio.ByteBuffer)

Example 28 with OWALChangesTree

use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree in project orientdb by orientechnologies.

the class OStreamSerializerSBTreeIndexRIDContainerTest method testSerializeWALChangesEmbeddedNonDurable.

public void testSerializeWALChangesEmbeddedNonDurable() {
    final OIndexRIDContainer indexRIDContainer = new OIndexRIDContainer("test", false);
    indexRIDContainer.setTopThreshold(100);
    for (int i = 0; i < 5; i++) {
        indexRIDContainer.add(new ORecordId(1, i));
    }
    Assert.assertTrue(indexRIDContainer.isEmbedded());
    final int len = streamSerializerSBTreeIndexRIDContainer.getObjectSize(indexRIDContainer);
    final int serializationOffset = 5;
    final ByteBuffer buffer = ByteBuffer.allocateDirect(len + serializationOffset).order(ByteOrder.nativeOrder());
    final byte[] data = new byte[len];
    streamSerializerSBTreeIndexRIDContainer.serializeNativeObject(indexRIDContainer, data, 0);
    final OWALChanges walChanges = new OWALChangesTree();
    walChanges.setBinaryValue(buffer, data, serializationOffset);
    Assert.assertEquals(streamSerializerSBTreeIndexRIDContainer.getObjectSizeInByteBuffer(buffer, walChanges, serializationOffset), len);
    OIndexRIDContainer newRidContainer = streamSerializerSBTreeIndexRIDContainer.deserializeFromByteBufferObject(buffer, walChanges, serializationOffset);
    Assert.assertNotSame(newRidContainer, indexRIDContainer);
    Assert.assertTrue(newRidContainer.isEmbedded());
    Assert.assertFalse(newRidContainer.isDurableNonTxMode());
    final Set<OIdentifiable> storedRids = new HashSet<OIdentifiable>(newRidContainer);
    final Set<OIdentifiable> newRids = new HashSet<OIdentifiable>(indexRIDContainer);
    Assert.assertEquals(newRids, storedRids);
}
Also used : OWALChangesTree(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree) OIndexRIDContainer(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainer) OWALChanges(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChanges) ByteBuffer(java.nio.ByteBuffer) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) HashSet(java.util.HashSet)

Example 29 with OWALChangesTree

use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree in project orientdb by orientechnologies.

the class OStreamSerializerSBTreeIndexRIDContainerTest method testSerializeWALChangesNonEmbeddedDurable.

public void testSerializeWALChangesNonEmbeddedDurable() {
    final OIndexRIDContainer indexRIDContainer = new OIndexRIDContainer("test", true);
    indexRIDContainer.setTopThreshold(1);
    for (int i = 0; i < 5; i++) {
        indexRIDContainer.add(new ORecordId(1, i * 4));
    }
    Assert.assertFalse(indexRIDContainer.isEmbedded());
    final int len = streamSerializerSBTreeIndexRIDContainer.getObjectSize(indexRIDContainer);
    final int serializationOffset = 5;
    final ByteBuffer buffer = ByteBuffer.allocateDirect(len + serializationOffset).order(ByteOrder.nativeOrder());
    final byte[] data = new byte[len];
    streamSerializerSBTreeIndexRIDContainer.serializeNativeObject(indexRIDContainer, data, 0);
    final OWALChanges walChanges = new OWALChangesTree();
    walChanges.setBinaryValue(buffer, data, serializationOffset);
    Assert.assertEquals(streamSerializerSBTreeIndexRIDContainer.getObjectSizeInByteBuffer(buffer, walChanges, serializationOffset), len);
    OIndexRIDContainer newRidContainer = streamSerializerSBTreeIndexRIDContainer.deserializeFromByteBufferObject(buffer, walChanges, serializationOffset);
    Assert.assertNotSame(newRidContainer, indexRIDContainer);
    Assert.assertFalse(newRidContainer.isEmbedded());
    Assert.assertTrue(newRidContainer.isDurableNonTxMode());
    final Set<OIdentifiable> storedRids = new HashSet<OIdentifiable>(newRidContainer);
    final Set<OIdentifiable> newRids = new HashSet<OIdentifiable>(indexRIDContainer);
    Assert.assertEquals(newRids, storedRids);
}
Also used : OWALChangesTree(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree) OIndexRIDContainer(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainer) OWALChanges(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChanges) ByteBuffer(java.nio.ByteBuffer) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) HashSet(java.util.HashSet)

Example 30 with OWALChangesTree

use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree in project orientdb by orientechnologies.

the class OStreamSerializerSBTreeIndexRIDContainerTest method testSerializeWALChangesNonEmbeddedNonDurable.

public void testSerializeWALChangesNonEmbeddedNonDurable() {
    final OIndexRIDContainer indexRIDContainer = new OIndexRIDContainer("test", false);
    indexRIDContainer.setTopThreshold(1);
    for (int i = 0; i < 5; i++) {
        indexRIDContainer.add(new ORecordId(1, i * 3));
    }
    Assert.assertFalse(indexRIDContainer.isEmbedded());
    final int len = streamSerializerSBTreeIndexRIDContainer.getObjectSize(indexRIDContainer);
    final int serializationOffset = 5;
    final ByteBuffer buffer = ByteBuffer.allocateDirect(len + serializationOffset).order(ByteOrder.nativeOrder());
    final byte[] data = new byte[len];
    streamSerializerSBTreeIndexRIDContainer.serializeNativeObject(indexRIDContainer, data, 0);
    final OWALChanges walChanges = new OWALChangesTree();
    walChanges.setBinaryValue(buffer, data, serializationOffset);
    Assert.assertEquals(streamSerializerSBTreeIndexRIDContainer.getObjectSizeInByteBuffer(buffer, walChanges, serializationOffset), len);
    OIndexRIDContainer newRidContainer = streamSerializerSBTreeIndexRIDContainer.deserializeFromByteBufferObject(buffer, walChanges, serializationOffset);
    Assert.assertNotSame(newRidContainer, indexRIDContainer);
    Assert.assertFalse(newRidContainer.isEmbedded());
    Assert.assertFalse(newRidContainer.isDurableNonTxMode());
    final Set<OIdentifiable> storedRids = new HashSet<OIdentifiable>(newRidContainer);
    final Set<OIdentifiable> newRids = new HashSet<OIdentifiable>(indexRIDContainer);
    Assert.assertEquals(newRids, storedRids);
}
Also used : OWALChangesTree(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree) OIndexRIDContainer(com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainer) OWALChanges(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChanges) ByteBuffer(java.nio.ByteBuffer) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) HashSet(java.util.HashSet)

Aggregations

OWALChangesTree (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree)41 ByteBuffer (java.nio.ByteBuffer)41 OWALChanges (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChanges)21 OByteBufferPool (com.orientechnologies.common.directmemory.OByteBufferPool)19 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)19 OCachePointer (com.orientechnologies.orient.core.storage.cache.OCachePointer)19 OLogSequenceNumber (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber)19 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)4 OIndexRIDContainer (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainer)4 ORecordId (com.orientechnologies.orient.core.id.ORecordId)4 HashSet (java.util.HashSet)4 Calendar (java.util.Calendar)1