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());
}
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());
}
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));
}
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;
}
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;
}
Aggregations