use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldNotFindEntityWithRemovedLabelInCompositeIndex.
@Test
void shouldNotFindEntityWithRemovedLabelInCompositeIndex() throws Exception {
assumeTrue(entityParams.tokenlessEntitySupported());
// Given
boolean needsValues = false;
int label = entityParams.entityTokenId(tx, PERSON_TOKEN);
int firstName = token.propertyKey(FIRSTNAME_PROP_NAME);
int surname = token.propertyKey(SURNAME_PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(COMPOSITE_INDEX_NAME));
try (KernelTransaction tx = beginTransaction();
var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
// when
entityParams.entityRemoveToken(tx, joeDalton, label);
entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.exact(firstName, "Joe"), PropertyIndexQuery.exact(surname, "Dalton"));
// then
assertFalse(cursor.next());
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldNotFindUpdatedEntityInPrefixSearch.
@Test
void shouldNotFindUpdatedEntityInPrefixSearch() throws Exception {
// Given
boolean needsValues = indexParams.indexProvidesStringValues();
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
try (KernelTransaction tx = beginTransaction();
var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
// when
entityParams.entitySetProperty(tx, strOne, prop, "ett");
entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.stringPrefix(prop, stringValue("on")));
// then
assertFalse(cursor.next());
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldPerformNumericRangeSearch.
@Test
void shouldPerformNumericRangeSearch() throws Exception {
// given
boolean needsValues = indexParams.indexProvidesNumericValues();
IndexQueryConstraints constraints = unordered(needsValues);
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexValueCapability numberCapability = index.reference().getCapability().valueCapability(ValueCategory.NUMBER);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
MutableLongSet uniqueIds = new LongHashSet();
// when
entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, 5, true, 12, true));
// then
assertFoundEntitiesAndValue(cursor, uniqueIds, numberCapability, needsValues, num5, num6, num12a, num12b);
// when
entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, 5, true, 12, false));
// then
assertFoundEntitiesAndValue(cursor, uniqueIds, numberCapability, needsValues, num5, num6);
// when
entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, 5, false, 12, true));
// then
assertFoundEntitiesAndValue(cursor, uniqueIds, numberCapability, needsValues, num6, num12a, num12b);
// when
entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, 5, false, 12, false));
// then
assertFoundEntitiesAndValue(cursor, uniqueIds, numberCapability, needsValues, num6);
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldHandleOrderedExactSeekWithNeedsValuesTrue.
@Test
void shouldHandleOrderedExactSeekWithNeedsValuesTrue() throws Exception {
// given
int prop = token.propertyKey("prop");
IndexReadSession index = tx.dataRead().indexReadSession(tx.schemaRead().indexGetForName(PROP_INDEX_NAME));
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.ASCENDING, true), PropertyIndexQuery.exact(prop, 5));
// then
assertTrue(cursor.next());
assertTrue(cursor.hasValue());
assertEquals(cursor.propertyValue(0), intValue(5));
assertFalse(cursor.next());
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldNotFindEntityWithRemovedLabelInRangeSearch.
@Test
void shouldNotFindEntityWithRemovedLabelInRangeSearch() throws Exception {
assumeTrue(entityParams.tokenlessEntitySupported());
// Given
boolean needsValues = indexParams.indexProvidesStringValues();
int label = entityParams.entityTokenId(tx, DEFAULT_ENTITY_TOKEN);
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
try (KernelTransaction tx = beginTransaction();
var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
// when
entityParams.entityRemoveToken(tx, strOne, label);
entityParams.entityRemoveToken(tx, strThree1, label);
entityParams.entityRemoveToken(tx, strThree2, label);
entityParams.entityRemoveToken(tx, strThree3, label);
entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.range(prop, "one", true, "three", true));
// then
assertFalse(cursor.next());
}
}
Aggregations