use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class TxStateIndexChanges method indexUpdatesForRangeSeek.
// RANGE SEEK
static AddedAndRemoved indexUpdatesForRangeSeek(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;
}
int size = descriptor.schema().getPropertyIds().length;
RangeFilterValues rangeFilter = predicate == null ? RangeFilterValues.fromExists(size, equalityPrefix) : RangeFilterValues.fromRange(size, equalityPrefix, predicate);
MutableLongList added = LongLists.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);
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))) {
added.addAll(diffForSpecificValue.getAdded());
removed.addAll(diffForSpecificValue.getRemoved());
}
}
return new AddedAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed);
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method createTestGraph.
@Override
public void createTestGraph(GraphDatabaseService graphDb) {
try (Transaction tx = graphDb.beginTx()) {
entityParams.createEntityIndex(tx, DEFAULT_ENTITY_TOKEN, PROP_NAME, PROP_INDEX_NAME);
entityParams.createEntityIndex(tx, DEFAULT_ENTITY_TOKEN, PROP_2_NAME, PROP_2_INDEX_NAME);
entityParams.createEntityIndex(tx, DEFAULT_ENTITY_TOKEN, PROP_3_NAME, PROP_3_INDEX_NAME);
tx.commit();
}
try (Transaction tx = graphDb.beginTx()) {
entityParams.createEntityIndex(tx, WHAT_TOKEN, EVER_PROP_NAME, WHAT_EVER_INDEX_NAME);
tx.commit();
}
try (Transaction tx = graphDb.beginTx()) {
entityParams.createCompositeEntityIndex(tx, PERSON_TOKEN, FIRSTNAME_PROP_NAME, SURNAME_PROP_NAME, COMPOSITE_INDEX_NAME);
tx.commit();
} catch (Exception e) {
throw new AssertionError(e);
}
try (Transaction tx = graphDb.beginTx()) {
tx.schema().awaitIndexesOnline(5, MINUTES);
tx.commit();
}
try (Transaction tx = graphDb.beginTx()) {
strOne = entityWithProp(tx, "one");
strTwo1 = entityWithProp(tx, "two");
strTwo2 = entityWithProp(tx, "two");
strThree1 = entityWithProp(tx, "three");
strThree2 = entityWithProp(tx, "three");
strThree3 = entityWithProp(tx, "three");
entityWithProp(tx, false);
boolTrue = entityWithProp(tx, true);
// Purposely mix ordering
entityWithProp(tx, 3);
entityWithProp(tx, 3);
entityWithProp(tx, 3);
entityWithProp(tx, 2);
entityWithProp(tx, 2);
entityWithProp(tx, 1);
entityWithProp(tx, 4);
num5 = entityWithProp(tx, 5);
num6 = entityWithProp(tx, 6);
num12a = entityWithProp(tx, 12.0);
num12b = entityWithProp(tx, 12.0);
entityWithProp(tx, 18);
entityWithProp(tx, 24);
entityWithProp(tx, 30);
entityWithProp(tx, 36);
entityWithProp(tx, 42);
if (entityParams.tokenlessEntitySupported()) {
strOneNoLabel = entityWithNoLabel(tx, "one");
} else {
strOneNoLabel = -1;
}
joeDalton = person(tx, "Joe", "Dalton");
williamDalton = person(tx, "William", "Dalton");
jackDalton = person(tx, "Jack", "Dalton");
averellDalton = person(tx, "Averell", "Dalton");
// Purposely mix order
entityWithProp(tx, Values.pointValue(Cartesian, 1, 0));
entityWithProp(tx, Values.pointValue(Cartesian, 0, 0));
entityWithProp(tx, Values.pointValue(Cartesian, 0, 0));
entityWithProp(tx, Values.pointValue(Cartesian, 0, 0));
entityWithProp(tx, Values.pointValue(Cartesian, 0, 1));
entityWithProp(tx, Values.pointValue(Cartesian_3D, 0, 0, 0));
entityWithProp(tx, Values.pointValue(WGS84, 0, 0));
entityWithProp(tx, Values.pointValue(WGS84_3D, 0, 0, 0));
// Purposely mix order
date891 = entityWithProp(tx, DateValue.date(1989, 3, 24));
date86 = entityWithProp(tx, DateValue.date(1986, 11, 18));
date892 = entityWithProp(tx, DateValue.date(1989, 3, 24));
entityWithProp(tx, new String[] { "first", "second", "third" });
entityWithProp(tx, new String[] { "fourth", "fifth", "sixth", "seventh" });
MutableLongList listOfIds = LongLists.mutable.empty();
listOfIds.add(entityWithWhatever(tx, "string"));
listOfIds.add(entityWithWhatever(tx, false));
listOfIds.add(entityWithWhatever(tx, 3));
listOfIds.add(entityWithWhatever(tx, 13.0));
whateverPoint = entityWithWhatever(tx, Values.pointValue(Cartesian, 1, 0));
listOfIds.add(whateverPoint);
listOfIds.add(entityWithWhatever(tx, DateValue.date(1989, 3, 24)));
listOfIds.add(entityWithWhatever(tx, new String[] { "first", "second", "third" }));
entitiesOfAllPropertyTypes = listOfIds.toArray();
assertSameDerivedValue(POINT_1, POINT_2);
entityWithProp(tx, "prop3", POINT_1.asObjectCopy());
entityWithProp(tx, "prop3", POINT_2.asObjectCopy());
entityWithProp(tx, "prop3", POINT_2.asObjectCopy());
tx.commit();
}
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class IndexSamplingController method indexesToSample.
private LongList indexesToSample(IndexSamplingMode mode, IndexMap indexMap) {
MutableLongList indexesToSample = LongLists.mutable.of();
LongIterator allIndexes = indexMap.indexIds();
while (allIndexes.hasNext()) {
long indexId = allIndexes.next();
if (shouldSampleIndex(mode, indexId)) {
indexesToSample.add(indexId);
}
}
return indexesToSample;
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class TokenIndexAccessorTest method convertToExpectedEntitiesPerToken.
private static MutableLongObjectMap<MutableLongList> convertToExpectedEntitiesPerToken(MutableLongObjectMap<long[]> trackingStructure) {
MutableLongObjectMap<MutableLongList> entitiesPerToken = LongObjectMaps.mutable.empty();
trackingStructure.forEachKeyValue((entityId, tokens) -> {
for (long token : tokens) {
MutableLongList entities = entitiesPerToken.getIfAbsentPut(token, LongLists.mutable.empty());
entities.add(entityId);
}
});
return entitiesPerToken;
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class RelationshipLockHelperTest method shouldKeepListSorted.
@Test
void shouldKeepListSorted() {
MutableLongList shuffle = LongLists.mutable.empty();
int numIds = 1000;
SortedLockList sortedListIterator = new SortedLockList(random.nextInt(numIds));
for (int i = 0; i < numIds; i++) {
int value = random.nextInt(numIds);
sortedListIterator.add(value);
shuffle.add(value);
assertThat(sortedListIterator.underlyingList().toArray()).isSorted();
}
shuffle.shuffleThis();
shuffle.forEach(value -> {
sortedListIterator.remove(value);
assertThat(sortedListIterator.underlyingList().toArray()).isSorted();
});
assertThat(sortedListIterator.underlyingList().toArray()).isEmpty();
}
Aggregations