use of org.neo4j.internal.schema.IndexValueCapability in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldNotFindDeletedEntityInIndexScan.
@Test
void shouldNotFindDeletedEntityInIndexScan() throws Exception {
// Given
boolean needsValues = indexParams.indexProvidesAllValues();
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexValueCapability wildcardCapability = index.reference().getCapability().valueCapability(ValueCategory.UNKNOWN);
try (KernelTransaction tx = beginTransaction();
var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
MutableLongSet uniqueIds = new LongHashSet();
// when
entityParams.entityIndexScan(tx, index, cursor, unordered(needsValues));
assertThat(cursor.numberOfProperties()).isEqualTo(1);
assertFoundEntitiesAndValue(cursor, TOTAL_ENTITY_COUNT, uniqueIds, wildcardCapability, needsValues);
// then
entityParams.entityDelete(tx, strOne);
entityParams.entityIndexScan(tx, index, cursor, unordered(needsValues));
assertFoundEntitiesAndValue(cursor, TOTAL_ENTITY_COUNT - 1, uniqueIds, wildcardCapability, needsValues);
}
}
use of org.neo4j.internal.schema.IndexValueCapability in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldPerformIndexScan.
@Test
void shouldPerformIndexScan() throws Exception {
// given
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexValueCapability wildcardCapability = index.reference().getCapability().valueCapability(ValueCategory.UNKNOWN);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
MutableLongSet uniqueIds = new LongHashSet();
// when
entityParams.entityIndexScan(tx, index, cursor, unordered(indexParams.indexProvidesAllValues()));
// then
assertThat(cursor.numberOfProperties()).isEqualTo(1);
assertFoundEntitiesAndValue(cursor, TOTAL_ENTITY_COUNT, uniqueIds, wildcardCapability, indexParams.indexProvidesAllValues());
}
}
use of org.neo4j.internal.schema.IndexValueCapability in project neo4j by neo4j.
the class SchemaCacheTest method shouldCompleteConfigurationOfIndexesAddedToCache.
@Test
void shouldCompleteConfigurationOfIndexesAddedToCache() {
IndexCapability capability = new IndexCapability() {
@Override
public IndexOrderCapability orderCapability(ValueCategory... valueCategories) {
return IndexOrderCapability.NONE;
}
@Override
public IndexValueCapability valueCapability(ValueCategory... valueCategories) {
return IndexValueCapability.NO;
}
};
List<IndexDescriptor> completed = new ArrayList<>();
IndexConfigCompleter completer = index -> {
completed.add(index);
return index.withIndexCapability(capability);
};
SchemaCache cache = new SchemaCache(new ConstraintSemantics(), completer);
IndexDescriptor index1 = newIndexRule(1, 2, 3);
ConstraintDescriptor constraint1 = uniquenessConstraint(2, 2, 3, 1);
IndexDescriptor index2 = newIndexRule(3, 4, 5);
ConstraintDescriptor constraint2 = uniquenessConstraint(4, 4, 5, 3);
IndexDescriptor index3 = newIndexRule(5, 5, 5);
cache.load(asList(index1, constraint1));
cache.addSchemaRule(index2);
cache.addSchemaRule(constraint2);
cache.addSchemaRule(index3);
assertEquals(List.of(index1, index2, index3), completed);
assertEquals(capability, cache.getIndex(index1.getId()).getCapability());
assertEquals(capability, cache.getIndex(index2.getId()).getCapability());
assertEquals(capability, cache.getIndex(index3.getId()).getCapability());
}
use of org.neo4j.internal.schema.IndexValueCapability in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldPerformBooleanSearch.
@Test
void shouldPerformBooleanSearch() throws KernelException {
// given
boolean needsValues = indexParams.indexProvidesBooleanValues();
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.BOOLEAN.category());
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
MutableLongSet uniqueIds = new LongHashSet();
// when
entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.exact(prop, false));
// then
assertFoundEntitiesAndValue(cursor, 1, uniqueIds, capability, needsValues);
// when
entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.exact(prop, true));
// then
assertFoundEntitiesAndValue(cursor, 1, uniqueIds, capability, needsValues);
}
}
use of org.neo4j.internal.schema.IndexValueCapability 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);
}
}
Aggregations