use of org.neo4j.internal.schema.FulltextSchemaDescriptor in project neo4j by neo4j.
the class SchemaStore35Test method storeAndLoad_Big_CompositeMultiTokenSchemaRule.
@Test
void storeAndLoad_Big_CompositeMultiTokenSchemaRule() throws Exception {
// GIVEN
FulltextSchemaDescriptor schema = fulltext(EntityType.RELATIONSHIP, range(1, 200).toArray(), range(1, 200).toArray());
long id = store.nextId(NULL);
IndexDescriptor indexRule = IndexPrototype.forSchema(schema, PROVIDER).withName("index_" + id).withIndexType(IndexType.FULLTEXT).materialise(id);
// WHEN
IndexDescriptor readIndexRule = (IndexDescriptor) SchemaRuleSerialization35.deserialize(indexRule.getId(), wrap(SchemaRuleSerialization35.serialize(indexRule, INSTANCE)));
// THEN
assertEquals(indexRule.getId(), readIndexRule.getId());
assertEquals(indexRule.schema(), readIndexRule.schema());
assertEquals(indexRule, readIndexRule);
assertEquals(indexRule.getIndexProvider(), readIndexRule.getIndexProvider());
}
use of org.neo4j.internal.schema.FulltextSchemaDescriptor in project neo4j by neo4j.
the class OnlineIndexUpdatesTest method shouldDifferentiateNodesAndRelationships.
@Test
void shouldDifferentiateNodesAndRelationships() {
OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(nodeStore, schemaCache, propertyPhysicalToLogicalConverter, new RecordStorageReader(neoStores), CursorContext.NULL, INSTANCE);
int nodeId = 0;
NodeRecord inUseNode = getNode(nodeId, true);
Value nodePropertyValue = Values.of("hej");
long nodePropertyId = createNodeProperty(inUseNode, nodePropertyValue, 1);
NodeRecord notInUseNode = getNode(nodeId, false);
nodeStore.updateRecord(inUseNode, CursorContext.NULL);
NodeCommand nodeCommand = new NodeCommand(inUseNode, notInUseNode);
PropertyRecord nodePropertyBlocks = new PropertyRecord(nodePropertyId);
nodePropertyBlocks.setNodeId(nodeId);
PropertyCommand nodePropertyCommand = new PropertyCommand(recordAccess.getIfLoaded(nodePropertyId).forReadingData(), nodePropertyBlocks);
IndexDescriptor nodeIndexDescriptor = IndexPrototype.forSchema(fulltext(NODE, ENTITY_TOKENS, new int[] { 1, 4, 6 })).withName("index").materialise(0);
createIndexes(nodeIndexDescriptor);
long relId = 0;
RelationshipRecord inUse = getRelationship(relId, true, ENTITY_TOKEN);
Value relationshipPropertyValue = Values.of("da");
long propertyId = createRelationshipProperty(inUse, relationshipPropertyValue, 1);
RelationshipRecord notInUse = getRelationship(relId, false, ENTITY_TOKEN);
relationshipStore.updateRecord(inUse, CursorContext.NULL);
Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand(inUse, notInUse);
PropertyRecord relationshipPropertyBlocks = new PropertyRecord(propertyId);
relationshipPropertyBlocks.setRelId(relId);
PropertyCommand relationshipPropertyCommand = new PropertyCommand(recordAccess.getIfLoaded(propertyId).forReadingData(), relationshipPropertyBlocks);
FulltextSchemaDescriptor schema = fulltext(RELATIONSHIP, ENTITY_TOKENS, new int[] { 1, 4, 6 });
IndexDescriptor relationshipIndexDescriptor = IndexPrototype.forSchema(schema).withName("index").materialise(1);
createIndexes(relationshipIndexDescriptor);
onlineIndexUpdates.feed(nodeGroup(nodeCommand, nodePropertyCommand), relationshipGroup(relationshipCommand, relationshipPropertyCommand), -1);
assertTrue(onlineIndexUpdates.hasUpdates());
assertThat(onlineIndexUpdates).contains(IndexEntryUpdate.remove(relId, relationshipIndexDescriptor, relationshipPropertyValue, null, null), IndexEntryUpdate.remove(nodeId, nodeIndexDescriptor, nodePropertyValue, null, null));
}
use of org.neo4j.internal.schema.FulltextSchemaDescriptor in project neo4j by neo4j.
the class LuceneFulltextIndexTest method completeConfigurationMustBeIdempotent.
@Test
void completeConfigurationMustBeIdempotent() {
FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { 1 }, new int[] { 1 });
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
IndexDescriptor onceCompleted = indexProvider.completeConfiguration(IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").materialise(1));
IndexDescriptor twiceCompleted = indexProvider.completeConfiguration(onceCompleted);
assertEquals(onceCompleted.getIndexConfig(), twiceCompleted.getIndexConfig());
}
use of org.neo4j.internal.schema.FulltextSchemaDescriptor in project neo4j by neo4j.
the class LuceneFulltextIndexTest method mustAssignCapabilitiesToDescriptorsThatHaveNone.
@Test
void mustAssignCapabilitiesToDescriptorsThatHaveNone() {
FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { 1 }, new int[] { 1 });
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
IndexDescriptor completed = indexProvider.completeConfiguration(IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").materialise(1));
assertNotEquals(NO_CAPABILITY, completed.getCapability());
completed = completed.withIndexCapability(NO_CAPABILITY);
completed = indexProvider.completeConfiguration(completed);
assertNotEquals(NO_CAPABILITY, completed.getCapability());
}
use of org.neo4j.internal.schema.FulltextSchemaDescriptor in project neo4j by neo4j.
the class LuceneFulltextIndexTest method mustNotOverwriteExistingCapabilities.
@Test
void mustNotOverwriteExistingCapabilities() {
IndexCapability capability = new IndexCapability() {
@Override
public IndexOrderCapability orderCapability(ValueCategory... valueCategories) {
return IndexOrderCapability.NONE;
}
@Override
public IndexValueCapability valueCapability(ValueCategory... valueCategories) {
return IndexValueCapability.NO;
}
};
FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { 1 }, new int[] { 1 });
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
IndexDescriptor index = IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").materialise(1).withIndexCapability(capability);
IndexDescriptor completed = indexProvider.completeConfiguration(index);
assertSame(capability, completed.getCapability());
}
Aggregations