Search in sources :

Example 6 with ArrayByteIterable

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

the class GarbageCollectorInterleavingTest method fill.

private void fill(@NotNull final String table) {
    final ByteIterable val0 = StringBinding.stringToEntry("val0");
    env.executeInTransaction(new TransactionalExecutable() {

        @Override
        public void execute(@NotNull Transaction txn) {
            final StoreImpl store = env.openStore(table, getStoreConfig(), txn);
            for (int i = 0; i < getRecordsNumber(); ++i) {
                final ArrayByteIterable key = StringBinding.stringToEntry("key " + i);
                store.put(txn, key, val0);
            }
        }
    });
}
Also used : ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable)

Example 7 with ArrayByteIterable

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

the class GarbageCollectorInterleavingTest method check.

private void check(@NotNull final String table) {
    final ByteIterable val0 = StringBinding.stringToEntry("val0");
    env.executeInReadonlyTransaction(new TransactionalExecutable() {

        @Override
        public void execute(@NotNull Transaction txn) {
            final Store store = env.openStore(table, getStoreConfig(), txn);
            for (int i = 0; i < getRecordsNumber(); ++i) {
                final ArrayByteIterable key = StringBinding.stringToEntry("key " + i);
                Assert.assertTrue(store.exists(txn, key, val0));
            }
        }
    });
}
Also used : ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable)

Example 8 with ArrayByteIterable

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

the class GarbageCollectorTest method xd98.

@Test
public void xd98() {
    setLogFileSize(64);
    env.getEnvironmentConfig().setGcEnabled(false);
    final Store store = openStoreAutoCommit("store");
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < 100; ++i) {
        builder.append("01234567890123456789012345678901234567890123456789");
        final ArrayByteIterable value = StringBinding.stringToEntry(builder.toString());
        putAutoCommit(store, IntegerBinding.intToEntry(0), value);
    }
    env.getGC().cleanWholeLog();
    Assert.assertEquals(1L, env.getLog().getNumberOfFiles());
}
Also used : ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) Test(org.junit.Test)

Example 9 with ArrayByteIterable

use of jetbrains.exodus.ArrayByteIterable 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 10 with ArrayByteIterable

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

the class VfsSettings method get.

ByteIterable get(@Nullable final Transaction txn, @NotNull final String settingName) {
    final ArrayByteIterable key = StringBinding.stringToEntry(settingName);
    if (txn != null) {
        return settingStore.get(txn, key);
    }
    final ByteIterable[] result = new ByteIterable[1];
    env.executeInTransaction(new TransactionalExecutable() {

        @Override
        public void execute(@NotNull final Transaction txn) {
            result[0] = settingStore.get(txn, key);
        }
    });
    return result[0];
}
Also used : TransactionalExecutable(jetbrains.exodus.env.TransactionalExecutable) Transaction(jetbrains.exodus.env.Transaction) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable)

Aggregations

ArrayByteIterable (jetbrains.exodus.ArrayByteIterable)29 ByteIterable (jetbrains.exodus.ByteIterable)15 Transaction (jetbrains.exodus.env.Transaction)4 TransactionalExecutable (jetbrains.exodus.env.TransactionalExecutable)4 Nullable (org.jetbrains.annotations.Nullable)4 Test (org.junit.Test)4 File (java.io.File)3 ByteIterator (jetbrains.exodus.ByteIterator)3 Cursor (jetbrains.exodus.env.Cursor)3 Store (jetbrains.exodus.env.Store)3 CompressedUnsignedLongByteIterable (jetbrains.exodus.log.CompressedUnsignedLongByteIterable)2 ITreeCursor (jetbrains.exodus.tree.ITreeCursor)2 NotNull (org.jetbrains.annotations.NotNull)2 ArrayList (java.util.ArrayList)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 CompoundByteIterable (jetbrains.exodus.CompoundByteIterable)1 StringBinding.entryToString (jetbrains.exodus.bindings.StringBinding.entryToString)1 Pair (jetbrains.exodus.core.dataStructures.Pair)1 PersistentLong23TreeSet (jetbrains.exodus.core.dataStructures.persistent.PersistentLong23TreeSet)1 PersistentLongSet (jetbrains.exodus.core.dataStructures.persistent.PersistentLongSet)1