use of org.neo4j.values.storable.ValueType in project neo4j by neo4j.
the class CompositeIndexAccessorCompatibility method testExactMatchOnRandomCompositeValues.
@Test
public void testExactMatchOnRandomCompositeValues() throws Exception {
// given
ValueType[] types = randomSetOfSupportedTypes();
List<ValueIndexEntryUpdate<?>> updates = new ArrayList<>();
Set<ValueTuple> duplicateChecker = new HashSet<>();
for (long id = 0; id < 10_000; id++) {
ValueIndexEntryUpdate<SchemaDescriptor> update;
do {
update = add(id, descriptor.schema(), random.randomValues().nextValueOfTypes(types), random.randomValues().nextValueOfTypes(types));
} while (!duplicateChecker.add(ValueTuple.of(update.values())));
updates.add(update);
}
updateAndCommit(updates);
// when
InMemoryTokens tokenNameLookup = new InMemoryTokens();
for (ValueIndexEntryUpdate<?> update : updates) {
// then
List<Long> hits = query(exact(0, update.values()[0]), exact(1, update.values()[1]));
assertEquals(update.describe(tokenNameLookup) + " " + hits, 1, hits.size());
assertThat(single(hits)).isEqualTo(update.getEntityId());
}
}
use of org.neo4j.values.storable.ValueType in project neo4j by neo4j.
the class CompositeIndexAccessorCompatibility method shouldRemoveEntries.
@Test
public void shouldRemoveEntries() throws Exception {
ValueType[] valueTypes = testSuite.supportedValueTypes();
long entityId = random.nextLong(1_000_000_000);
for (ValueType valueType : valueTypes) {
// given
Value[] value = new Value[] { random.nextValue(valueType), random.nextValue(valueType) };
updateAndCommit(singletonList(IndexEntryUpdate.add(entityId, descriptor.schema(), value)));
assertEquals(singletonList(entityId), query(exactQuery(value)));
// when
updateAndCommit(singletonList(IndexEntryUpdate.remove(entityId, descriptor.schema(), value)));
// then
assertEquals(emptyList(), query(exactQuery(value)));
}
}
use of org.neo4j.values.storable.ValueType in project neo4j by neo4j.
the class NativeIndexAccessorTests method respectIndexOrder.
@Test
void respectIndexOrder() throws Exception {
// given
int nUpdates = 10000;
ValueType[] types = supportedTypesExcludingNonOrderable();
Iterator<ValueIndexEntryUpdate<IndexDescriptor>> randomUpdateGenerator = valueCreatorUtil.randomUpdateGenerator(random, types);
// noinspection unchecked
ValueIndexEntryUpdate<IndexDescriptor>[] someUpdates = new ValueIndexEntryUpdate[nUpdates];
for (int i = 0; i < nUpdates; i++) {
someUpdates[i] = randomUpdateGenerator.next();
}
processAll(someUpdates);
Value[] allValues = ValueCreatorUtil.extractValuesFromUpdates(someUpdates);
// when
try (var reader = accessor.newValueReader()) {
ValueGroup valueGroup = random.among(allValues).valueGroup();
PropertyIndexQuery.RangePredicate<?> supportedQuery = PropertyIndexQuery.range(0, valueGroup);
IndexOrderCapability supportedOrders = indexCapability().orderCapability(valueGroup.category());
if (supportedOrders.supportsAsc()) {
expectIndexOrder(allValues, valueGroup, reader, IndexOrder.ASCENDING, supportedQuery);
}
if (supportedOrders.supportsDesc()) {
expectIndexOrder(allValues, valueGroup, reader, IndexOrder.DESCENDING, supportedQuery);
}
}
}
Aggregations