use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class DatabaseCompositeIndexAccessorTest method multipleIndexReadersFromDifferentPointsInTimeCanSeeDifferentResults.
@Test
public void multipleIndexReadersFromDifferentPointsInTimeCanSeeDifferentResults() throws Exception {
// WHEN
updateAndCommit(asList(add(nodeId, values)));
IndexReader firstReader = accessor.newReader();
updateAndCommit(asList(add(nodeId2, values2)));
IndexReader secondReader = accessor.newReader();
// THEN
assertEquals(asSet(nodeId), PrimitiveLongCollections.toSet(firstReader.query(IndexQuery.exact(PROP_ID1, values[0]), IndexQuery.exact(PROP_ID2, values[1]))));
assertEquals(asSet(), PrimitiveLongCollections.toSet(firstReader.query(IndexQuery.exact(PROP_ID1, values2[0]), IndexQuery.exact(PROP_ID2, values2[1]))));
assertEquals(asSet(nodeId), PrimitiveLongCollections.toSet(secondReader.query(IndexQuery.exact(PROP_ID1, values[0]), IndexQuery.exact(PROP_ID2, values[1]))));
assertEquals(asSet(nodeId2), PrimitiveLongCollections.toSet(secondReader.query(IndexQuery.exact(PROP_ID1, values2[0]), IndexQuery.exact(PROP_ID2, values2[1]))));
firstReader.close();
secondReader.close();
}
use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class DatabaseIndexAccessorTest method multipleIndexReadersFromDifferentPointsInTimeCanSeeDifferentResults.
@Test
public void multipleIndexReadersFromDifferentPointsInTimeCanSeeDifferentResults() throws Exception {
// WHEN
updateAndCommit(asList(add(nodeId, value)));
IndexReader firstReader = accessor.newReader();
updateAndCommit(asList(add(nodeId2, value2)));
IndexReader secondReader = accessor.newReader();
// THEN
assertEquals(asSet(nodeId), PrimitiveLongCollections.toSet(firstReader.query(exact(PROP_ID, value))));
assertEquals(asSet(), PrimitiveLongCollections.toSet(firstReader.query(exact(PROP_ID, value2))));
assertEquals(asSet(nodeId), PrimitiveLongCollections.toSet(secondReader.query(exact(PROP_ID, value))));
assertEquals(asSet(nodeId2), PrimitiveLongCollections.toSet(secondReader.query(exact(PROP_ID, value2))));
firstReader.close();
secondReader.close();
}
use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class DatabaseIndexAccessorTest method indexReaderShouldSupportScan.
@Test
public void indexReaderShouldSupportScan() throws Exception {
// GIVEN
updateAndCommit(asList(add(nodeId, value), add(nodeId2, value2)));
IndexReader reader = accessor.newReader();
// WHEN
PrimitiveLongIterator results = reader.query(IndexQuery.exists(PROP_ID));
// THEN
assertEquals(asSet(nodeId, nodeId2), PrimitiveLongCollections.toSet(results));
assertEquals(asSet(nodeId), PrimitiveLongCollections.toSet(reader.query(IndexQuery.exact(PROP_ID, value))));
reader.close();
}
use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class DatabaseIndexAccessorTest method indexStringRangeQuery.
@Test
public void indexStringRangeQuery() throws Exception {
updateAndCommit(asList(add(PROP_ID, "A"), add(2, "B"), add(3, "C"), add(4, "")));
IndexReader reader = accessor.newReader();
PrimitiveLongIterator rangeFromBInclusive = reader.query(range(PROP_ID, "B", true, null, false));
assertThat(PrimitiveLongCollections.asArray(rangeFromBInclusive), LongArrayMatcher.of(2, 3));
PrimitiveLongIterator rangeFromANonInclusive = reader.query(range(PROP_ID, "A", false, null, false));
assertThat(PrimitiveLongCollections.asArray(rangeFromANonInclusive), LongArrayMatcher.of(2, 3));
PrimitiveLongIterator emptyLowInclusive = reader.query(range(PROP_ID, "", true, null, false));
assertThat(PrimitiveLongCollections.asArray(emptyLowInclusive), LongArrayMatcher.of(PROP_ID, 2, 3, 4));
PrimitiveLongIterator emptyUpperNonInclusive = reader.query(range(PROP_ID, "B", true, "", false));
assertThat(PrimitiveLongCollections.asArray(emptyUpperNonInclusive), LongArrayMatcher.emptyArrayMatcher());
PrimitiveLongIterator emptyInterval = reader.query(range(PROP_ID, "", true, "", true));
assertThat(PrimitiveLongCollections.asArray(emptyInterval), LongArrayMatcher.of(4));
PrimitiveLongIterator emptyAllNonInclusive = reader.query(range(PROP_ID, "", false, null, false));
assertThat(PrimitiveLongCollections.asArray(emptyAllNonInclusive), LongArrayMatcher.of(PROP_ID, 2, 3));
PrimitiveLongIterator nullNonInclusive = reader.query(range(PROP_ID, (String) null, false, null, false));
assertThat(PrimitiveLongCollections.asArray(nullNonInclusive), LongArrayMatcher.of(PROP_ID, 2, 3, 4));
PrimitiveLongIterator nullInclusive = reader.query(range(PROP_ID, (String) null, false, null, false));
assertThat(PrimitiveLongCollections.asArray(nullInclusive), LongArrayMatcher.of(PROP_ID, 2, 3, 4));
}
use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class DatabaseIndexAccessorTest method canAddNewData.
@Test
public void canAddNewData() throws Exception {
// WHEN
updateAndCommit(asList(add(nodeId, value), add(nodeId2, value2)));
IndexReader reader = accessor.newReader();
// THEN
assertEquals(asSet(nodeId), PrimitiveLongCollections.toSet(reader.query(exact(PROP_ID, value))));
reader.close();
}
Aggregations