use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldFindSwappedEntityInPrefixSearch.
@Test
void shouldFindSwappedEntityInPrefixSearch() 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.entityAddToken(tx, strOneNoLabel, label);
entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.stringPrefix(prop, stringValue("on")));
// then
assertTrue(cursor.next());
assertEquals(strOneNoLabel, entityParams.entityReference(cursor));
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldPerformStringSuffixSearch.
@Test
void shouldPerformStringSuffixSearch() throws Exception {
// given
boolean needsValues = indexParams.indexProvidesStringValues();
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexValueCapability stringCapability = index.reference().getCapability().valueCapability(ValueCategory.TEXT);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
MutableLongSet uniqueIds = new LongHashSet();
// when
entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.stringSuffix(prop, stringValue("e")));
// then
assertThat(cursor.numberOfProperties()).isEqualTo(1);
assertFoundEntitiesAndValue(cursor, uniqueIds, stringCapability, needsValues, strOne, strThree1, strThree2, strThree3);
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldNotFindEntityWithRemovedLabelInPrefixSearch.
@Test
void shouldNotFindEntityWithRemovedLabelInPrefixSearch() 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.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 shouldFindUpdatedEntityInIndexSeek.
@Test
void shouldFindUpdatedEntityInIndexSeek() throws Exception {
// Given
boolean needsValues = false;
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.exact(prop, "ett"));
// then
assertTrue(cursor.next());
assertEquals(strOne, entityParams.entityReference(cursor));
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldNotFindUpdatedEntityInRangeSearch.
@Test
void shouldNotFindUpdatedEntityInRangeSearch() 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.entitySetProperty(tx, strThree1, prop, "tre");
entityParams.entitySetProperty(tx, strThree2, prop, "tre");
entityParams.entitySetProperty(tx, strThree3, prop, "tre");
entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.range(prop, "one", true, "three", true));
// then
assertFalse(cursor.next());
}
}
Aggregations