use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class LongDiffSetsTest method shouldContainFilteredSourceForDiffSetsWithAddedElements.
@Test
public void shouldContainFilteredSourceForDiffSetsWithAddedElements() throws Exception {
// given
DiffSets<Long> diffSets = new DiffSets<>();
diffSets.add(17L);
diffSets.add(18L);
Iterator<Long> expected = diffSets.apply(iteratorSource(1L, 17L, 3L));
// when
PrimitiveLongIterator actual = diffSets.augment(iterator(1L, 17L, 3L));
// then
assertThat(expected, hasSamePrimitiveItems(actual));
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class NativeLabelScanReader method iteratorsForLabels.
private List<PrimitiveLongIterator> iteratorsForLabels(int[] labelIds) {
List<PrimitiveLongIterator> iterators = new ArrayList<>();
try {
ensureOpenCursorsClosed();
for (int labelId : labelIds) {
RawCursor<Hit<LabelScanKey, LabelScanValue>, IOException> cursor = seekerForLabel(labelId);
openCursors.offer(cursor);
iterators.add(new LabelScanValueIterator(cursor));
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return iterators;
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class StateHandlingStatementOperationsTest method shouldConsiderTransactionStateDuringIndexBetweenRangeSeekByStringWithIndexQuery.
@Test
public void shouldConsiderTransactionStateDuringIndexBetweenRangeSeekByStringWithIndexQuery() throws Exception {
// Given
TransactionState txState = mock(TransactionState.class);
KernelStatement statement = mock(KernelStatement.class);
when(statement.hasTxStateWithChanges()).thenReturn(true);
when(statement.txState()).thenReturn(txState);
when(txState.indexUpdatesForRangeSeekByString(index, "Anne", true, "Bill", false)).thenReturn(new DiffSets<>(Collections.singleton(42L), Collections.singleton(44L)));
when(txState.addedAndRemovedNodes()).thenReturn(new DiffSets<>(Collections.singleton(45L), Collections.singleton(46L)));
StoreReadLayer storeReadLayer = mock(StoreReadLayer.class);
IndexReader indexReader = addMockedIndexReader(statement);
IndexQuery.StringRangePredicate rangePredicate = IndexQuery.range(index.schema().getPropertyId(), "Anne", true, "Bill", false);
when(indexReader.query(rangePredicate)).thenReturn(PrimitiveLongCollections.resourceIterator(PrimitiveLongCollections.iterator(43L, 44L, 46L), null));
StateHandlingStatementOperations context = newTxStateOps(storeReadLayer);
// When
PrimitiveLongIterator results = context.indexQuery(statement, index, rangePredicate);
// Then
assertEquals(asSet(42L, 43L), PrimitiveLongCollections.toSet(results));
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class StateHandlingStatementOperationsTest method shouldConsiderTransactionStateDuringIndexRangeSeekByContainsWithIndexQuery.
@Test
public void shouldConsiderTransactionStateDuringIndexRangeSeekByContainsWithIndexQuery() throws Exception {
// Given
TransactionState txState = mock(TransactionState.class);
KernelStatement statement = mock(KernelStatement.class);
when(statement.hasTxStateWithChanges()).thenReturn(true);
when(statement.txState()).thenReturn(txState);
when(txState.indexUpdatesForScan(index)).thenReturn(new DiffSets<>(Collections.singleton(42L), Collections.singleton(44L)));
when(txState.addedAndRemovedNodes()).thenReturn(new DiffSets<>(Collections.singleton(45L), Collections.singleton(46L)));
StoreReadLayer storeReadLayer = mock(StoreReadLayer.class);
IndexReader indexReader = addMockedIndexReader(statement);
IndexQuery.StringContainsPredicate indexQuery = IndexQuery.stringContains(index.schema().getPropertyId(), "contains");
when(indexReader.query(indexQuery)).thenReturn(PrimitiveLongCollections.resourceIterator(PrimitiveLongCollections.iterator(43L, 44L, 46L), null));
StateHandlingStatementOperations context = newTxStateOps(storeReadLayer);
// When
PrimitiveLongIterator results = context.indexQuery(statement, index, indexQuery);
// Then
assertEquals(asSet(42L, 43L), PrimitiveLongCollections.toSet(results));
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class KernelIT method deletingNodeWithLabelsShouldHaveRemovalReflectedInLabelScans.
@Test
public void deletingNodeWithLabelsShouldHaveRemovalReflectedInLabelScans() throws Exception {
// GIVEN
Transaction tx = db.beginTx();
Label label = label("labello");
Node node = db.createNode(label);
tx.success();
tx.close();
// AND GIVEN I DELETE IT
tx = db.beginTx();
node.delete();
tx.success();
tx.close();
// WHEN
tx = db.beginTx();
Statement statement = statementContextSupplier.get();
int labelId = statement.readOperations().labelGetForName(label.name());
PrimitiveLongIterator nodes = statement.readOperations().nodesGetForLabel(labelId);
Set<Long> nodeSet = PrimitiveLongCollections.toSet(nodes);
tx.success();
tx.close();
// THEN
assertThat(nodeSet, equalTo(Collections.<Long>emptySet()));
}
Aggregations