use of org.neo4j.storageengine.api.ValueIndexEntryUpdate in project neo4j by neo4j.
the class MultipleIndexPopulatorTest method updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan.
@Test
void updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan() throws IndexEntryConflictException, FlipFailedKernelException {
// given
createIndexPopulator();
multipleIndexPopulator.create(NULL);
IndexUpdater updater = mock(IndexUpdater.class);
IndexPopulator populator = createIndexPopulator(updater);
IndexUpdater indexUpdater = mock(IndexUpdater.class);
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(1, 1);
addPopulator(populator, 1);
// when external updates comes in
ValueIndexEntryUpdate<LabelSchemaDescriptor> lowUpdate = IndexEntryUpdate.add(10, schema, intValue(99));
ValueIndexEntryUpdate<LabelSchemaDescriptor> highUpdate = IndexEntryUpdate.add(20, schema, intValue(101));
multipleIndexPopulator.queueConcurrentUpdate(lowUpdate);
multipleIndexPopulator.queueConcurrentUpdate(highUpdate);
// and we ask to apply them, given an entity in between the two
multipleIndexPopulator.applyExternalUpdates(15);
// then only the lower one should be applied, the higher one ignored
verify(populator, times(1)).newPopulatingUpdater(any(), any());
verify(updater).process(lowUpdate);
verify(updater, never()).process(highUpdate);
verify(indexUpdater, never()).process(any(IndexEntryUpdate.class));
}
use of org.neo4j.storageengine.api.ValueIndexEntryUpdate in project neo4j by neo4j.
the class SimpleRandomizedIndexAccessorCompatibility method testExactMatchOnRandomValues.
@Test
public void testExactMatchOnRandomValues() throws Exception {
// given
ValueType[] types = randomSetOfSupportedTypes();
List<Value> values = generateValuesFromType(types, new HashSet<>(), 30_000);
List<ValueIndexEntryUpdate<?>> updates = generateUpdatesFromValues(values, new MutableLong());
updateAndCommit(updates);
// when
for (ValueIndexEntryUpdate<?> update : updates) {
// then
List<Long> hits = query(PropertyIndexQuery.exact(0, update.values()[0]));
assertEquals(hits.toString(), 1, hits.size());
assertThat(single(hits)).isEqualTo(update.getEntityId());
}
}
use of org.neo4j.storageengine.api.ValueIndexEntryUpdate in project neo4j by neo4j.
the class SimpleRandomizedIndexAccessorCompatibility method testRangeMatchInOrderOnRandomValues.
@Test
public void testRangeMatchInOrderOnRandomValues() throws Exception {
Assume.assumeTrue("Assume support for granular composite queries", testSuite.supportsGranularCompositeQueries());
// given
ValueType[] types = randomSetOfSupportedAndSortableTypes();
Set<Value> uniqueValues = new HashSet<>();
TreeSet<ValueAndId> sortedValues = new TreeSet<>((v1, v2) -> Values.COMPARATOR.compare(v1.value, v2.value));
MutableLong nextId = new MutableLong();
// A couple of rounds of updates followed by lots of range verifications
for (int i = 0; i < 5; i++) {
List<ValueIndexEntryUpdate<?>> updates = new ArrayList<>();
if (i == 0) {
// The initial batch of data can simply be additions
updates = generateUpdatesFromValues(generateValuesFromType(types, uniqueValues, 20_000), nextId);
sortedValues.addAll(updates.stream().map(u -> new ValueAndId(u.values()[0], u.getEntityId())).collect(Collectors.toList()));
} else {
// Then do all sorts of updates
for (int j = 0; j < 1_000; j++) {
int type = random.intBetween(0, 2);
if (type == 0) {
// add
Value value = generateUniqueRandomValue(types, uniqueValues);
long id = nextId.getAndIncrement();
sortedValues.add(new ValueAndId(value, id));
updates.add(add(id, descriptor.schema(), value));
} else if (type == 1) {
// update
ValueAndId existing = random.among(sortedValues.toArray(new ValueAndId[0]));
sortedValues.remove(existing);
Value newValue = generateUniqueRandomValue(types, uniqueValues);
uniqueValues.remove(existing.value);
sortedValues.add(new ValueAndId(newValue, existing.id));
updates.add(change(existing.id, descriptor.schema(), existing.value, newValue));
} else {
// remove
ValueAndId existing = random.among(sortedValues.toArray(new ValueAndId[0]));
sortedValues.remove(existing);
uniqueValues.remove(existing.value);
updates.add(remove(existing.id, descriptor.schema(), existing.value));
}
}
}
updateAndCommit(updates);
verifyRandomRanges(types, sortedValues);
}
}
use of org.neo4j.storageengine.api.ValueIndexEntryUpdate in project neo4j by neo4j.
the class SimpleRandomizedIndexAccessorCompatibility method generateUpdatesFromValues.
private List<ValueIndexEntryUpdate<?>> generateUpdatesFromValues(List<Value> values, MutableLong nextId) {
List<ValueIndexEntryUpdate<?>> updates = new ArrayList<>();
for (Value value : values) {
ValueIndexEntryUpdate<SchemaDescriptor> update = add(nextId.getAndIncrement(), descriptor.schema(), value);
updates.add(update);
}
return updates;
}
use of org.neo4j.storageengine.api.ValueIndexEntryUpdate 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());
}
}
Aggregations