use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class GarbageCollectorTestInMemory method testTextIndexLikeWithDeletions.
private void testTextIndexLikeWithDeletions(boolean useExpirationChecker) {
final long started = System.currentTimeMillis();
prepare(useExpirationChecker);
final Transaction txn = env.beginTransaction();
final Store store = env.openStore("store", getStoreConfig(false), txn);
final Store storeDups = env.openStore("storeDups", getStoreConfig(true), txn);
txn.commit();
try {
while (System.currentTimeMillis() - started < TEST_DURATION) {
env.executeInTransaction(new TransactionalExecutable() {
@Override
public void execute(@NotNull final Transaction txn) {
int randomInt = rnd.nextInt() & 0x3fffffff;
final int count = 4 + (randomInt) & 0x1f;
for (int j = 0; j < count; randomInt += ++j) {
final int intKey = randomInt & 0x3fff;
final ArrayByteIterable key = IntegerBinding.intToCompressedEntry(intKey);
final int valueLength = 50 + (randomInt % 100);
store.put(txn, key, new ArrayByteIterable(new byte[valueLength]));
storeDups.put(txn, key, IntegerBinding.intToEntry(randomInt % 32));
}
randomInt = (randomInt * randomInt) & 0x3fffffff;
for (int j = 0; j < count / 2; randomInt += ++j) {
final int intKey = randomInt & 0x3fff;
final ArrayByteIterable key = IntegerBinding.intToCompressedEntry(intKey);
store.delete(txn, key);
try (Cursor cursor = storeDups.openCursor(txn)) {
if (cursor.getSearchBoth(key, IntegerBinding.intToEntry(randomInt % 32))) {
cursor.deleteCurrent();
}
}
}
}
});
Thread.sleep(0);
}
} catch (Throwable t) {
memory.dump(new File(System.getProperty("user.home"), "dump"));
logger.error("User code exception: ", t);
Assert.assertTrue(false);
}
}
use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class GarbageCollectorTestInMemory method testTextIndexLike.
private void testTextIndexLike(boolean useExpirationChecker) {
final long started = System.currentTimeMillis();
prepare(useExpirationChecker);
final Transaction txn = env.beginTransaction();
final Store store = env.openStore("store", getStoreConfig(false), txn);
final Store storeDups = env.openStore("storeDups", getStoreConfig(true), txn);
txn.commit();
try {
while (System.currentTimeMillis() - started < TEST_DURATION) {
env.executeInTransaction(new TransactionalExecutable() {
@Override
public void execute(@NotNull final Transaction txn) {
int randomInt = rnd.nextInt() & 0x3fffffff;
final int count = 4 + (randomInt) & 0x1f;
for (int j = 0; j < count; randomInt += ++j) {
final int intKey = randomInt & 0x3fff;
final ArrayByteIterable key = IntegerBinding.intToCompressedEntry(intKey);
final int valueLength = 50 + (randomInt % 100);
store.put(txn, key, new ArrayByteIterable(new byte[valueLength]));
storeDups.put(txn, key, IntegerBinding.intToEntry(randomInt % 32));
}
}
});
Thread.sleep(0);
}
} catch (Throwable t) {
memory.dump(new File(System.getProperty("user.home"), "dump"));
logger.error("User code exception: ", t);
Assert.assertTrue(false);
}
}
use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class PersistentSequentialDictionary method rename.
public void rename(@NotNull final PersistentStoreTransaction txn, @NotNull final String oldName, @NotNull final String newName) {
if (oldName.equals(newName)) {
return;
}
final int id = getId(txn, oldName);
if (id < 0) {
throw new IllegalArgumentException("Old entity type doesn't exist: " + oldName);
}
final int newId = getId(txn, newName);
final ByteIterable idEntry = IntegerBinding.intToCompressedEntry(id);
synchronized (lock) {
operationsLog.add(new DictionaryOperation() {
@Override
void persist(final Transaction txn) {
table.delete(txn, StringBinding.stringToEntry(oldName), idEntry);
table.put(txn, StringBinding.stringToEntry(newName), idEntry);
}
});
cache.remove(oldName);
cache.put(newName, id);
reverseCache.remove(id);
if (newId >= 0) {
reverseCache.remove(newId);
}
}
}
use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class ExodusDirectory method listAll.
@Override
public String[] listAll() throws IOException {
final Transaction txn = env.getAndCheckCurrentTransaction();
final ArrayList<String> allFiles = new ArrayList<>((int) vfs.getNumberOfFiles(txn));
for (final File file : vfs.getFiles(txn)) {
allFiles.add(file.getPath());
}
return allFiles.toArray(new String[allFiles.size()]);
}
use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class VfsFileTests method testFileCreation.
@Test
public void testFileCreation() {
final Transaction txn = env.beginTransaction();
final File file0 = vfs.createFile(txn, "file0");
txn.commit();
Assert.assertEquals(0L, file0.getDescriptor());
}
Aggregations