use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class IndexQueryTransactionStateTest method shouldExcludeExistingNodesWithCorrectPropertyAfterRemovingLabel.
@Test
public void shouldExcludeExistingNodesWithCorrectPropertyAfterRemovingLabel() throws Exception {
// Given
long nodeId = 1L;
when(indexReader.query(withValue)).then(answerAsPrimitiveLongIteratorFrom(asList(nodeId, 2L, 3L)));
when(statement.acquireSingleNodeCursor(nodeId)).thenReturn(asNodeCursor(nodeId, 40L, labels(labelId)));
mockStoreProperty();
txContext.nodeRemoveLabel(state, nodeId, labelId);
// When
PrimitiveLongIterator result = txContext.indexQuery(state, newIndexDescriptor, withValue);
// Then
assertThat(PrimitiveLongCollections.toSet(result), equalTo(asSet(2L, 3L)));
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class IndexQueryTransactionStateTest method shouldExcludeChangedNodesWithMissingLabelFromIndexQuery.
@Test
public void shouldExcludeChangedNodesWithMissingLabelFromIndexQuery() throws Exception {
// Given
when(indexReader.query(withValue)).then(answerAsPrimitiveLongIteratorFrom(asList(2L, 3L)));
state.txState().nodeDoAddProperty(1L, intProperty(propertyKeyId, 10));
// When
PrimitiveLongIterator result = txContext.indexQuery(state, newIndexDescriptor, withValue);
// Then
assertThat(PrimitiveLongCollections.toSet(result), equalTo(asSet(2L, 3L)));
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class IndexQueryTransactionStateTest method shouldExcludeNodesWithRemovedProperty.
@Test
public void shouldExcludeNodesWithRemovedProperty() throws Exception {
// Given
when(indexReader.query(withValue)).then(answerAsPrimitiveLongIteratorFrom(asList(2L, 3L)));
long nodeId = 1L;
state.txState().nodeDoAddProperty(nodeId, intProperty(propertyKeyId, 10));
when(statement.acquireSingleNodeCursor(nodeId)).thenReturn(asNodeCursor(nodeId, labels(labelId)));
txContext.nodeAddLabel(state, nodeId, labelId);
// When
PrimitiveLongIterator result = txContext.indexQuery(state, newIndexDescriptor, withValue);
// Then
assertThat(PrimitiveLongCollections.toSet(result), equalTo(asSet(2L, 3L)));
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class IndexQueryTransactionStateTest method shouldIncludeExistingNodesWithCorrectPropertyAfterAddingLabel.
@Test
public void shouldIncludeExistingNodesWithCorrectPropertyAfterAddingLabel() throws Exception {
// Given
when(indexReader.query(withValue)).then(answerAsPrimitiveLongIteratorFrom(asList(2L, 3L)));
long nodeId = 1L;
when(statement.acquireSingleNodeCursor(nodeId)).thenReturn(asNodeCursor(nodeId, 40L));
mockStoreProperty();
when(store.indexesGetForLabel(labelId)).thenReturn(indexes.iterator());
txContext.nodeAddLabel(state, nodeId, labelId);
// When
PrimitiveLongIterator result = txContext.indexQuery(state, newIndexDescriptor, withValue);
// Then
assertThat(PrimitiveLongCollections.toSet(result), equalTo(asSet(nodeId, 2L, 3L)));
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class StateHandlingStatementOperationsTest method shouldConsiderTransactionStateDuringIndexRangeSeekBySuffixWithIndexQuery.
@Test
public void shouldConsiderTransactionStateDuringIndexRangeSeekBySuffixWithIndexQuery() 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.StringSuffixPredicate indexQuery = IndexQuery.stringSuffix(index.schema().getPropertyId(), "suffix");
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));
}
Aggregations