use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class PropertyValueIterable method getIteratorImpl.
@Override
@NotNull
public EntityIteratorBase getIteratorImpl(@NotNull final PersistentStoreTransaction txn) {
final EntityIterableBase it = getPropertyValueIndex();
if (it.isCachedInstance()) {
final UpdatablePropertiesCachedInstanceIterable cached = (UpdatablePropertiesCachedInstanceIterable) it;
if (value.getClass() != cached.getPropertyValueClass()) {
return EntityIteratorBase.EMPTY;
}
return cached.getPropertyValueIterator(value);
}
final Cursor valueIdx = openCursor(txn);
if (valueIdx == null) {
return EntityIteratorBase.EMPTY;
}
return new PropertyValueIterator(valueIdx);
}
use of jetbrains.exodus.env.Cursor 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.env.Cursor in project xodus by JetBrains.
the class CursorTestBase method check.
protected void check(ITree tm, GetNext r) {
Cursor c = tm.openCursor();
assertEquals(false, c.getKey().iterator().hasNext());
assertEquals(false, c.getValue().iterator().hasNext());
for (int i = 0; i < s; i++) {
assertEquals(true, r.n(c));
assertEquals(c.getValue(), value("v" + i));
assertEquals(c.getKey(), key(i));
}
assertEquals(false, r.n(c));
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorConcurrentModificationTest method testConcurrentDeleteBefore.
@Test
public void testConcurrentDeleteBefore() {
Cursor c = tm.openCursor();
c.getSearchKey(key(2));
deleteImpl(key(1));
assertTrue(c.getNext());
assertEquals(key(3), c.getKey());
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorDuplicatesTest method testGetSearchKey.
@Test
public void testGetSearchKey() throws IOException {
final TreeAwareRunnable getSearchKey = new TreeAwareRunnable(getTreeMutable()) {
@Override
public void run() {
Cursor c = _t.openCursor();
for (INode ln : valuesNoDup) {
assertEquals(ln.getValue(), c.getSearchKey(ln.getKey()));
assertEquals(ln.getValue(), c.getValue());
assertEquals(ln.getKey(), c.getKey());
}
assertEquals(null, c.getSearchKey(key(0)));
assertEquals(null, c.getSearchKey(key(4)));
assertEquals(null, c.getSearchKey(key(13)));
// prev state due to failed search
assertEquals(values.get(values.size() - 1).getValue(), c.getValue());
assertEquals(values.get(values.size() - 1).getKey(), c.getKey());
}
};
getSearchKey.run();
long a = saveTree();
getSearchKey.run();
reopen();
getSearchKey.setTree(openTree(a, true));
getSearchKey.run();
}
Aggregations