Search in sources :

Example 21 with ByteIterable

use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.

the class GarbageCollectorTest method updateSameKeyDeleteWithDuplicates.

@Test
public void updateSameKeyDeleteWithDuplicates() {
    set1KbFileWithoutGC();
    ByteIterable key = StringBinding.stringToEntry("key");
    final Store store = openStoreAutoCommit("updateSameKey", getStoreConfig(true));
    for (int i = 0; i < 1000; ++i) {
        putAutoCommit(store, key, key);
    }
    deleteAutoCommit(store, key);
    Assert.assertTrue(env.getLog().getNumberOfFiles() > 1);
    env.getGC().cleanWholeLog();
    Assert.assertEquals(1L, env.getLog().getNumberOfFiles());
}
Also used : ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) Test(org.junit.Test)

Example 22 with ByteIterable

use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.

the class GarbageCollectorTest method updateSameKeyWithDuplicates.

@Test
public void updateSameKeyWithDuplicates() {
    set1KbFileWithoutGC();
    ByteIterable key = StringBinding.stringToEntry("key");
    final Store store = openStoreAutoCommit("updateSameKey", getStoreConfig(true));
    for (int i = 0; i < 1000; ++i) {
        putAutoCommit(store, key, key);
    }
    Assert.assertTrue(env.getLog().getNumberOfFiles() > 1);
    env.getGC().cleanWholeLog();
    Assert.assertEquals(1L, env.getLog().getNumberOfFiles());
}
Also used : ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) Test(org.junit.Test)

Example 23 with ByteIterable

use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.

the class GarbageCollectorTest method reopenDbAfterGcWithBackgroundCleaner.

@Test
public void reopenDbAfterGcWithBackgroundCleaner() {
    set1KbFileWithoutGC();
    // enable background GC
    env.getEnvironmentConfig().setGcEnabled(true);
    ByteIterable key = StringBinding.stringToEntry("key");
    Store store = openStoreAutoCommit("updateSameKey");
    for (int i = 0; i < 1000; ++i) {
        putAutoCommit(store, key, key);
    }
    Assert.assertEquals(1, countAutoCommit(store));
    env.getGC().cleanWholeLog();
    store = openStoreAutoCommit("updateSameKey", StoreConfig.USE_EXISTING);
    Assert.assertEquals(1, countAutoCommit(store));
    reopenEnvironment();
    store = openStoreAutoCommit("updateSameKey", StoreConfig.USE_EXISTING);
    Assert.assertEquals(1, countAutoCommit(store));
}
Also used : ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) Test(org.junit.Test)

Example 24 with ByteIterable

use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.

the class ImmutableNode method extractLazyIterable.

private static ByteIterable extractLazyIterable(@NotNull final ByteIterableWithAddress data, @NotNull final ByteIteratorWithAddress it) {
    final int length = CompressedUnsignedLongByteIterable.getInt(it);
    if (length == 1) {
        return ArrayByteIterable.fromByte(it.next());
    }
    if (length < LAZY_KEY_VALUE_ITERABLE_MIN_LENGTH) {
        return new ArrayByteIterable(it, length);
    }
    final ByteIterable result = data.subIterable((int) (it.getAddress() - data.getDataAddress()), length);
    it.skip(length);
    return result;
}
Also used : ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) CompressedUnsignedLongByteIterable(jetbrains.exodus.log.CompressedUnsignedLongByteIterable) ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable)

Example 25 with ByteIterable

use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.

the class PatriciaCursorDecorator method getPrevLazy.

private boolean getPrevLazy() {
    if (prevKeyLength < 0) {
        // UNKNOWN
        if (patriciaCursor.getPrev()) {
            final ByteIterable keyLengthIterable = patriciaCursor.getValue();
            final ByteIterable noDupKey = new UnEscapingByteIterable(patriciaCursor.getKey());
            prevKeyBytes = noDupKey.getBytesUnsafe();
            prevKeyLength = CompressedUnsignedLongByteIterable.getInt(keyLengthIterable);
            prevValueLength = noDupKey.getLength() - prevKeyLength - 1;
            return true;
        }
        return false;
    }
    return prevKeyBytes != null;
}
Also used : CompressedUnsignedLongByteIterable(jetbrains.exodus.log.CompressedUnsignedLongByteIterable) ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable)

Aggregations

ByteIterable (jetbrains.exodus.ByteIterable)86 ArrayByteIterable (jetbrains.exodus.ArrayByteIterable)45 Test (org.junit.Test)26 CompressedUnsignedLongByteIterable (jetbrains.exodus.log.CompressedUnsignedLongByteIterable)15 Nullable (org.jetbrains.annotations.Nullable)11 ITreeCursor (jetbrains.exodus.tree.ITreeCursor)8 Cursor (jetbrains.exodus.env.Cursor)7 RandomAccessLoggable (jetbrains.exodus.log.RandomAccessLoggable)7 CompoundByteIterable (jetbrains.exodus.CompoundByteIterable)6 Store (jetbrains.exodus.env.Store)4 TreeSet (java.util.TreeSet)3 Transaction (jetbrains.exodus.env.Transaction)3 Exchange (com.persistit.Exchange)2 ExodusException (jetbrains.exodus.ExodusException)2 TokyoCabinetBenchmark (jetbrains.exodus.benchmark.TokyoCabinetBenchmark)2 Pair (jetbrains.exodus.core.dataStructures.Pair)2 HashSet (jetbrains.exodus.core.dataStructures.hash.HashSet)2 PersistentLongSet (jetbrains.exodus.core.dataStructures.persistent.PersistentLongSet)2 PersistentStoreTransaction (jetbrains.exodus.entitystore.PersistentStoreTransaction)2 Loggable (jetbrains.exodus.log.Loggable)2