use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class EntityTests method testRawProperty.
public void testRawProperty() {
final StoreTransaction txn = getStoreTransaction();
final Entity entity = txn.newEntity("Issue");
entity.setProperty("description", "it doesn't work");
txn.flush();
Assert.assertEquals("Issue", entity.getType());
Entity sameEntity = txn.getEntity(entity.getId());
Assert.assertNotNull(sameEntity);
Assert.assertEquals(entity.getType(), sameEntity.getType());
Assert.assertEquals(entity.getId(), sameEntity.getId());
ByteIterable rawValue = entity.getRawProperty("description");
Assert.assertNotNull(rawValue);
Assert.assertEquals("it doesn't work", getEntityStore().getPropertyTypes().entryToPropertyValue(rawValue).getData());
entity.setProperty("description", "it works");
txn.flush();
sameEntity = txn.getEntity(entity.getId());
Assert.assertNotNull(sameEntity);
Assert.assertEquals(entity.getType(), sameEntity.getType());
Assert.assertEquals(entity.getId(), sameEntity.getId());
rawValue = entity.getRawProperty("description");
Assert.assertNotNull(rawValue);
Assert.assertEquals("it works", getEntityStore().getPropertyTypes().entryToPropertyValue(rawValue).getData());
}
use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class PropertyValueIterable method isEmptyImpl.
@Override
public boolean isEmptyImpl(@NotNull PersistentStoreTransaction txn) {
final ByteIterable key = getStore().getPropertyTypes().dataToPropertyValue(value).dataToEntry();
final Cursor valueIdx = openCursor(txn);
return valueIdx == null || new SingleKeyCursorIsEmptyChecker(valueIdx, key).isEmpty();
}
use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class PropertiesTable method deleteNoFail.
public boolean deleteNoFail(@NotNull final PersistentStoreTransaction txn, final long localId, @NotNull final ByteIterable value, int propertyId, @NotNull final ComparableValueType type) {
final ByteIterable key = PropertyKey.propertyKeyToEntry(new PropertyKey(localId, propertyId));
final Transaction envTxn = txn.getEnvironmentTransaction();
final ByteIterable secondaryValue = LongBinding.longToCompressedEntry(localId);
return primaryStore.delete(envTxn, key) && deleteFromStore(envTxn, getOrCreateValueIndex(txn, propertyId), secondaryValue, createSecondaryKeys(store.getPropertyTypes(), value, type)) && deleteFromStore(envTxn, allPropsIndex, secondaryValue, IntegerBinding.intToCompressedEntry(propertyId));
}
use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class GarbageCollectorTest method updateSameKeyWithoutDuplicates.
@Test
public void updateSameKeyWithoutDuplicates() {
set1KbFileWithoutGC();
ByteIterable key = StringBinding.stringToEntry("key");
final Store store = openStoreAutoCommit("updateSameKey");
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 fillDuplicatesThenDeleteAlmostAllOfThem.
@Test
public void fillDuplicatesThenDeleteAlmostAllOfThem() {
set1KbFileWithoutGC();
Store store = openStoreAutoCommit("duplicates", getStoreConfig(true));
for (int i = 0; i < 32; ++i) {
for (int j = 0; j < 32; ++j) {
putAutoCommit(store, IntegerBinding.intToEntry(i), IntegerBinding.intToEntry(j));
}
}
for (int i = 0; i < 32; ++i) {
final Transaction txn = env.beginTransaction();
try {
try (Cursor cursor = store.openCursor(txn)) {
Assert.assertNotNull(cursor.getSearchKeyRange(IntegerBinding.intToEntry(i)));
for (int j = 0; j < 32; ++j, cursor.getNext()) {
cursor.deleteCurrent();
}
}
store.put(txn, IntegerBinding.intToEntry(i), IntegerBinding.intToEntry(100));
} finally {
txn.commit();
}
}
env.getGC().cleanWholeLog();
reopenEnvironment();
store = openStoreAutoCommit("duplicates", getStoreConfig(true));
for (int i = 0; i < 32; ++i) {
final ByteIterable it = getAutoCommit(store, IntegerBinding.intToEntry(i));
Assert.assertNotNull(it);
Assert.assertEquals(100, IntegerBinding.entryToInt(it));
}
}
Aggregations