use of org.eclipse.collections.api.list.primitive.MutableLongList in project eclipse-collections by eclipse.
the class PrimitiveStreamsTest method toLongList.
@Test
public void toLongList() {
MutableLongList list = PrimitiveStreams.mLongList(LongStream.rangeClosed(1, 10));
Assert.assertEquals(IntInterval.oneTo(10).collectLong(i -> (long) i, LongLists.mutable.empty()), list);
Assert.assertEquals(LongLists.immutable.ofAll(LongStream.rangeClosed(1, 10)), list);
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project eclipse-collections by eclipse.
the class AbstractListTestCase method collectLong.
@Override
public void collectLong() {
super.collectLong();
MutableLongList result = this.newWith(1, 2, 3, 4).collectLong(PrimitiveFunctions.unboxIntegerToLong());
Assert.assertEquals(LongLists.mutable.of(1L, 2L, 3L, 4L), result);
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class TxStateIndexChanges method indexUpdatesForRangeSeekByPrefix.
// PREFIX
static AddedAndRemoved indexUpdatesForRangeSeekByPrefix(ReadableTransactionState txState, IndexDescriptor descriptor, Value[] equalityPrefix, TextValue prefix, 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;
ValueTuple floor = getCompositeValueTuple(size, equalityPrefix, prefix, true);
ValueTuple maxString = getCompositeValueTuple(size, equalityPrefix, Values.MAX_STRING, false);
MutableLongList added = LongLists.mutable.empty();
MutableLongSet removed = LongSets.mutable.empty();
for (Map.Entry<ValueTuple, ? extends LongDiffSets> entry : sortedUpdates.subMap(floor, maxString).entrySet()) {
Value key = entry.getKey().valueAt(equalityPrefix.length);
// Needs to check type since the subMap might include non-TextValue for composite index
if (key.valueGroup() == ValueGroup.TEXT && ((TextValue) key).startsWith(prefix)) {
LongDiffSets diffSets = entry.getValue();
added.addAll(diffSets.getAdded());
removed.addAll(diffSets.getRemoved());
} else {
break;
}
}
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 IndexedIdGenerator method nextIdBatch.
@Override
public org.neo4j.internal.id.IdRange nextIdBatch(int size, boolean forceConsecutiveAllocation, CursorContext cursorContext) {
assertNotReadOnly();
if (forceConsecutiveAllocation) {
long startId;
do {
startId = highId.getAndAdd(size);
} while (IdValidator.hasReservedIdInRange(startId, startId + size));
return new org.neo4j.internal.id.IdRange(EMPTY_LONG_ARRAY, startId, size);
}
long prev = -1;
long startOfRange = -1;
int rangeLength = 0;
MutableLongList other = null;
for (int i = 0; i < size; i++) {
long id = nextId(cursorContext);
if (other != null) {
other.add(id);
} else {
if (i == 0) {
prev = id;
startOfRange = id;
rangeLength = 1;
} else {
if (id == prev + 1) {
prev = id;
rangeLength++;
} else {
other = LongLists.mutable.empty();
other.add(id);
}
}
}
}
return new org.neo4j.internal.id.IdRange(other != null ? other.toArray() : EMPTY_LONG_ARRAY, startOfRange, rangeLength);
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class TokenIndexAccessorTest method verifyReaderSeesAllUpdates.
private void verifyReaderSeesAllUpdates(MutableLongObjectMap<MutableLongList> entitiesPerToken) throws Exception {
for (long token : TOKENS) {
MutableLongList expectedEntities = entitiesPerToken.getIfAbsent(token, LongLists.mutable::empty);
assertReaderFindsExpected(token, expectedEntities);
}
}
Aggregations