use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldPerformTextArraySearch.
@Test
void shouldPerformTextArraySearch() throws KernelException {
// given
boolean needsValues = indexParams.indexProvidesArrayValues();
IndexQueryConstraints constraints = unordered(needsValues);
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexValueCapability capability = index.reference().getCapability().valueCapability(ValueGroup.TEXT_ARRAY.category());
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
MutableLongSet uniqueIds = new LongHashSet();
// when
entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.exact(prop, new String[] { "first", "second", "third" }));
// then
assertFoundEntitiesAndValue(cursor, 1, uniqueIds, capability, needsValues);
// when
entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.exact(prop, new String[] { "fourth", "fifth", "sixth", "seventh" }));
// then
assertFoundEntitiesAndValue(cursor, 1, uniqueIds, capability, needsValues);
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldNotFindDeletedEntityInCompositeIndex.
@Test
void shouldNotFindDeletedEntityInCompositeIndex() throws Exception {
// Given
boolean needsValues = false;
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.entityDelete(tx, jackDalton);
entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.exact(firstName, "Jack"), 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 shouldRespectOrderCapabilitiesForSpatial.
@Test
void shouldRespectOrderCapabilitiesForSpatial() throws KernelException {
// given
boolean needsValues = indexParams.indexProvidesSpatialValues();
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexOrderCapability orderCapabilities = index.reference().getCapability().orderCapability(ValueCategory.GEOMETRY);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
if (orderCapabilities.supportsAsc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.ASCENDING, needsValues), PropertyIndexQuery.range(prop, CoordinateReferenceSystem.Cartesian));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.ASCENDING);
}
if (orderCapabilities.supportsDesc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.DESCENDING, needsValues), PropertyIndexQuery.range(prop, CoordinateReferenceSystem.Cartesian));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.DESCENDING);
}
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldRespectOrderCapabilitiesForTemporal.
@Test
void shouldRespectOrderCapabilitiesForTemporal() throws KernelException {
// given
boolean needsValues = indexParams.indexProvidesTemporalValues();
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexOrderCapability orderCapabilities = index.reference().getCapability().orderCapability(ValueCategory.TEMPORAL);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
if (orderCapabilities.supportsAsc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.ASCENDING, needsValues), PropertyIndexQuery.range(prop, DateValue.date(1986, 11, 18), true, DateValue.date(1989, 3, 24), true));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.ASCENDING);
}
if (orderCapabilities.supportsDesc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.DESCENDING, needsValues), PropertyIndexQuery.range(prop, DateValue.date(1986, 11, 18), true, DateValue.date(1989, 3, 24), true));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.DESCENDING);
}
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldProvideValuesForAllTypes.
@Test
void shouldProvideValuesForAllTypes() throws Exception {
// given
assumeTrue(indexParams.indexProvidesAllValues());
int prop = token.propertyKey(EVER_PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(WHAT_EVER_INDEX_NAME));
IndexValueCapability valueCapability = index.reference().getCapability().valueCapability(ValueCategory.UNKNOWN);
assertEquals(IndexValueCapability.YES, valueCapability);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
MutableLongSet uniqueIds = new LongHashSet();
// when
entityParams.entityIndexSeek(tx, index, cursor, unorderedValues(), PropertyIndexQuery.exists(prop));
// then
assertFoundEntitiesAndValue(cursor, uniqueIds, valueCapability, true, entitiesOfAllPropertyTypes);
}
}
Aggregations