use of org.neo4j.storageengine.api.IndexEntryUpdate in project neo4j by neo4j.
the class UniqueDatabaseIndexPopulatorTest method addUpdates.
@Test
void addUpdates() throws Exception {
populator = newPopulator();
List<IndexEntryUpdate<?>> updates = Arrays.asList(add(1, schemaDescriptor, "aaa"), add(2, schemaDescriptor, "bbb"), add(3, schemaDescriptor, "ccc"));
populator.add(updates, NULL);
index.maybeRefreshBlocking();
try (var reader = index.getIndexReader();
NodeValueIterator allEntities = new NodeValueIterator()) {
reader.query(NULL_CONTEXT, allEntities, unconstrained(), PropertyIndexQuery.exists(1));
assertArrayEquals(new long[] { 1, 2, 3 }, PrimitiveLongCollections.asArray(allEntities));
}
}
use of org.neo4j.storageengine.api.IndexEntryUpdate in project neo4j by neo4j.
the class LuceneIndexAccessorIT method populateWithInitialNodes.
private void populateWithInitialNodes(IndexDescriptor indexDescriptor, int nodes, MutableLongSet expectedNodes) throws IndexEntryConflictException, IOException {
IndexPopulator populator = indexProvider.getPopulator(indexDescriptor, samplingConfig, ByteBufferFactory.heapBufferFactory((int) kibiBytes(100)), INSTANCE, mock(TokenNameLookup.class));
Collection<IndexEntryUpdate<IndexDescriptor>> initialData = new ArrayList<>();
populator.create();
for (long id = 0; id < nodes; id++) {
Value[] values = values(indexDescriptor, id);
initialData.add(add(id, indexDescriptor, values));
expectedNodes.add(id);
if (initialData.size() >= 100) {
populator.add(initialData, NULL);
initialData.clear();
}
}
if (!initialData.isEmpty()) {
populator.add(initialData, NULL);
}
populator.scanCompleted(nullInstance, mock(IndexPopulator.PopulationWorkScheduler.class), NULL);
populator.close(true, NULL);
}
use of org.neo4j.storageengine.api.IndexEntryUpdate in project neo4j by neo4j.
the class NonUniqueDatabaseIndexPopulatorTest method sampleIncludedUpdatesWithDuplicates.
@Test
void sampleIncludedUpdatesWithDuplicates() {
populator = newPopulator();
List<IndexEntryUpdate<?>> updates = Arrays.asList(add(1, labelSchemaDescriptor, "foo"), add(2, labelSchemaDescriptor, "bar"), add(3, labelSchemaDescriptor, "foo"));
populator.add(updates, NULL);
IndexSample sample = populator.sample(NULL);
assertEquals(new IndexSample(3, 2, 3), sample);
}
use of org.neo4j.storageengine.api.IndexEntryUpdate in project neo4j by neo4j.
the class OnlineIndexUpdatesTest method shouldContainFedRelationshipUpdate.
@Test
void shouldContainFedRelationshipUpdate() {
OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(nodeStore, schemaCache, propertyPhysicalToLogicalConverter, new RecordStorageReader(neoStores), CursorContext.NULL, INSTANCE);
long relId = 0;
RelationshipRecord inUse = getRelationship(relId, true, ENTITY_TOKEN);
Value propertyValue = Values.of("hej");
long propertyId = createRelationshipProperty(inUse, propertyValue, 1);
RelationshipRecord notInUse = getRelationship(relId, false, ENTITY_TOKEN);
relationshipStore.updateRecord(inUse, CursorContext.NULL);
Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand(inUse, notInUse);
PropertyRecord propertyBlocks = new PropertyRecord(propertyId);
propertyBlocks.setRelId(relId);
PropertyCommand propertyCommand = new PropertyCommand(recordAccess.getIfLoaded(propertyId).forReadingData(), propertyBlocks);
IndexDescriptor indexDescriptor = IndexPrototype.forSchema(fulltext(RELATIONSHIP, ENTITY_TOKENS, new int[] { 1, 4, 6 })).withName("index").materialise(0);
createIndexes(indexDescriptor);
onlineIndexUpdates.feed(nodeGroup(null), relationshipGroup(relationshipCommand, propertyCommand), -1);
assertTrue(onlineIndexUpdates.hasUpdates());
Iterator<IndexEntryUpdate<IndexDescriptor>> iterator = onlineIndexUpdates.iterator();
assertEquals(iterator.next(), IndexEntryUpdate.remove(relId, indexDescriptor, propertyValue, null, null));
assertFalse(iterator.hasNext());
}
use of org.neo4j.storageengine.api.IndexEntryUpdate in project neo4j by neo4j.
the class IndexRecoveryIT method createSomeBananas.
private Set<IndexEntryUpdate<?>> createSomeBananas(Label label) {
Set<IndexEntryUpdate<?>> updates = new HashSet<>();
try (Transaction tx = db.beginTx()) {
KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
int labelId = ktx.tokenRead().nodeLabel(label.name());
int propertyKeyId = ktx.tokenRead().propertyKey(key);
LabelSchemaDescriptor schemaDescriptor = SchemaDescriptor.forLabel(labelId, propertyKeyId);
for (int number : new int[] { 4, 10 }) {
Node node = tx.createNode(label);
node.setProperty(key, number);
updates.add(IndexEntryUpdate.add(node.getId(), schemaDescriptor, Values.of(number)));
}
tx.commit();
return updates;
}
}
Aggregations