use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldPerformStringContainmentSearch.
@Test
void shouldPerformStringContainmentSearch() 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.stringContains(prop, stringValue("o")));
// then
assertThat(cursor.numberOfProperties()).isEqualTo(1);
assertFoundEntitiesAndValue(cursor, uniqueIds, stringCapability, needsValues, strOne, strTwo1, strTwo2);
}
}
use of org.eclipse.collections.api.set.primitive.MutableLongSet 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.eclipse.collections.api.set.primitive.MutableLongSet 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.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.
the class TxStateIndexChanges method indexUpdatesWithValuesScanAndFilter.
private static AddedWithValuesAndRemoved indexUpdatesWithValuesScanAndFilter(ReadableTransactionState txState, IndexDescriptor descriptor, PropertyIndexQuery filter, IndexOrder indexOrder) {
Map<ValueTuple, ? extends LongDiffSets> updates = getUpdates(txState, descriptor, indexOrder);
if (updates == null) {
return EMPTY_ADDED_AND_REMOVED_WITH_VALUES;
}
MutableList<EntityWithPropertyValues> added = Lists.mutable.empty();
MutableLongSet removed = LongSets.mutable.empty();
for (Map.Entry<ValueTuple, ? extends LongDiffSets> entry : updates.entrySet()) {
ValueTuple key = entry.getKey();
if (filter == null || filter.acceptsValue(key.valueAt(0))) {
Value[] values = key.getValues();
LongDiffSets diffSet = entry.getValue();
diffSet.getAdded().each(nodeId -> added.add(new EntityWithPropertyValues(nodeId, values)));
removed.addAll(diffSet.getRemoved());
}
}
return new AddedWithValuesAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed);
}
use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.
the class TxStateIndexChanges method indexUpdatesWithValuesForRangeSeek.
static AddedWithValuesAndRemoved indexUpdatesWithValuesForRangeSeek(ReadableTransactionState txState, IndexDescriptor descriptor, Value[] equalityPrefix, PropertyIndexQuery.RangePredicate<?> predicate, IndexOrder indexOrder) {
NavigableMap<ValueTuple, ? extends LongDiffSets> sortedUpdates = txState.getSortedIndexUpdates(descriptor.schema());
if (sortedUpdates == null) {
return EMPTY_ADDED_AND_REMOVED_WITH_VALUES;
}
int size = descriptor.schema().getPropertyIds().length;
RangeFilterValues rangeFilter = predicate == null ? RangeFilterValues.fromExists(size, equalityPrefix) : RangeFilterValues.fromRange(size, equalityPrefix, predicate);
MutableList<EntityWithPropertyValues> added = Lists.mutable.empty();
MutableLongSet removed = LongSets.mutable.empty();
Map<ValueTuple, ? extends LongDiffSets> inRange = sortedUpdates.subMap(rangeFilter.lower, true, rangeFilter.upper, true);
for (Map.Entry<ValueTuple, ? extends LongDiffSets> entry : inRange.entrySet()) {
ValueTuple values = entry.getKey();
Value rangeKey = values.valueAt(equalityPrefix.length);
Value[] valuesArray = values.getValues();
LongDiffSets diffForSpecificValue = entry.getValue();
// Needs to manually filter for if lower or upper should be included
// since we only wants to compare the first value of the key and not all of them for composite indexes
boolean allowed = rangeFilter.allowedEntry(rangeKey, equalityPrefix.length);
// The TreeMap cannot perfectly order multi-dimensional types (spatial) and need additional filtering out false positives
if (allowed && (predicate == null || predicate.isRegularOrder() || predicate.acceptsValue(rangeKey))) {
diffForSpecificValue.getAdded().each(nodeId -> added.add(new EntityWithPropertyValues(nodeId, valuesArray)));
removed.addAll(diffForSpecificValue.getRemoved());
}
}
return new AddedWithValuesAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed);
}
Aggregations