Search in sources :

Example 51 with PrimitiveLongIterator

use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.

the class LabelScanStoreTest method assertNodesForLabel.

private void assertNodesForLabel(int labelId, long... expectedNodeIds) {
    Set<Long> nodeSet = new HashSet<>();
    PrimitiveLongIterator nodes = store.newReader().nodesWithLabel(labelId);
    while (nodes.hasNext()) {
        nodeSet.add(nodes.next());
    }
    for (long expectedNodeId : expectedNodeIds) {
        assertTrue("Expected node " + expectedNodeId + " not found in scan store", nodeSet.remove(expectedNodeId));
    }
    assertTrue("Unexpected nodes in scan store " + nodeSet, nodeSet.isEmpty());
}
Also used : PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) HashSet(java.util.HashSet)

Example 52 with PrimitiveLongIterator

use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.

the class DataStatementArgumentVerificationTest method shouldReturnEmptyIdIteratorFromNodesGetForLabelForNoSuchLabelConstant.

@Test
public void shouldReturnEmptyIdIteratorFromNodesGetForLabelForNoSuchLabelConstant() throws Exception {
    // given
    ReadOperations statement = stubStatement();
    // when
    PrimitiveLongIterator nodes = statement.nodesGetForLabel(StatementConstants.NO_SUCH_LABEL);
    // then
    assertFalse("should not contain any ids", nodes.hasNext());
}
Also used : PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) ReadOperations(org.neo4j.kernel.api.ReadOperations) Test(org.junit.Test)

Example 53 with PrimitiveLongIterator

use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.

the class LongDiffSetsTest method shouldContainAddedElementsForDiffSetsWithAddedElements.

@Test
public void shouldContainAddedElementsForDiffSetsWithAddedElements() throws Exception {
    // given
    DiffSets<Long> diffSets = new DiffSets<>();
    diffSets.add(19L);
    diffSets.add(20L);
    Iterator<Long> expected = diffSets.apply(iteratorSource(19L));
    // when
    PrimitiveLongIterator actual = diffSets.augment(iterator(19L));
    // then
    assertThat(expected, hasSamePrimitiveItems(actual));
}
Also used : PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) DiffSets(org.neo4j.kernel.impl.util.diffsets.DiffSets) Test(org.junit.Test)

Example 54 with PrimitiveLongIterator

use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.

the class LongDiffSetsTest method shouldContainFilteredSourceForDiffSetsWithRemovedElements.

@Test
public void shouldContainFilteredSourceForDiffSetsWithRemovedElements() throws Exception {
    // given
    DiffSets<Long> diffSets = new DiffSets<>();
    diffSets.remove(17L);
    diffSets.remove(18L);
    Iterator<Long> expected = diffSets.apply(iteratorSource(1L, 17L, 3L));
    // when
    PrimitiveLongIterator actual = diffSets.augment(iterator(1L, 17L, 3L));
    // then
    assertThat(expected, hasSamePrimitiveItems(actual));
}
Also used : PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) DiffSets(org.neo4j.kernel.impl.util.diffsets.DiffSets) Test(org.junit.Test)

Example 55 with PrimitiveLongIterator

use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.

the class IndexQueryTransactionStateTest method shouldExcludeRemovedNodesFromIndexQuery.

@Test
public void shouldExcludeRemovedNodesFromIndexQuery() throws Exception {
    // Given
    long nodeId = 2L;
    when(indexReader.query(withValue)).then(answerAsPrimitiveLongIteratorFrom(asList(1L, nodeId, 3L)));
    when(statement.acquireSingleNodeCursor(nodeId)).thenReturn(asNodeCursor(nodeId));
    txContext.nodeDelete(state, nodeId);
    // When
    PrimitiveLongIterator result = txContext.indexQuery(state, newIndexDescriptor, withValue);
    // Then
    assertThat(PrimitiveLongCollections.toSet(result), equalTo(asSet(1L, 3L)));
}
Also used : PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) Test(org.junit.Test)

Aggregations

PrimitiveLongIterator (org.neo4j.collection.primitive.PrimitiveLongIterator)65 Test (org.junit.Test)50 IndexReader (org.neo4j.storageengine.api.schema.IndexReader)18 IndexQuery (org.neo4j.kernel.api.schema_new.IndexQuery)11 TransactionState (org.neo4j.kernel.api.txstate.TransactionState)8 KernelStatement (org.neo4j.kernel.impl.api.KernelStatement)8 StateHandlingStatementOperations (org.neo4j.kernel.impl.api.StateHandlingStatementOperations)8 StoreReadLayer (org.neo4j.storageengine.api.StoreReadLayer)8 Transaction (org.neo4j.graphdb.Transaction)7 IndexReaderStub (org.neo4j.kernel.api.impl.index.IndexReaderStub)6 IOException (java.io.IOException)4 PrimitiveLongSet (org.neo4j.collection.primitive.PrimitiveLongSet)4 Statement (org.neo4j.kernel.api.Statement)4 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)4 DiffSets (org.neo4j.kernel.impl.util.diffsets.DiffSets)4 Cursor (org.neo4j.cursor.Cursor)3 ReadOperations (org.neo4j.kernel.api.ReadOperations)3 DocValuesCollector (org.neo4j.kernel.api.impl.index.collector.DocValuesCollector)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2