Search in sources :

Example 6 with FulltextSchemaDescriptor

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());
}
Also used : FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 7 with FulltextSchemaDescriptor

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));
}
Also used : RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) NodeCommand(org.neo4j.internal.recordstorage.Command.NodeCommand) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) Value(org.neo4j.values.storable.Value) NodeCommand(org.neo4j.internal.recordstorage.Command.NodeCommand) Test(org.junit.jupiter.api.Test)

Example 8 with FulltextSchemaDescriptor

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());
}
Also used : IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 9 with FulltextSchemaDescriptor

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());
}
Also used : IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 10 with FulltextSchemaDescriptor

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());
}
Also used : ValueCategory(org.neo4j.values.storable.ValueCategory) IndexCapability(org.neo4j.internal.schema.IndexCapability) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)12 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)12 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)9 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)5 SchemaWrite (org.neo4j.internal.kernel.api.SchemaWrite)3 TokenWrite (org.neo4j.internal.kernel.api.TokenWrite)3 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)3 IndexConfig (org.neo4j.internal.schema.IndexConfig)2 Value (org.neo4j.values.storable.Value)2 Transaction (org.neo4j.graphdb.Transaction)1 NodeCommand (org.neo4j.internal.recordstorage.Command.NodeCommand)1 PropertyCommand (org.neo4j.internal.recordstorage.Command.PropertyCommand)1 IndexCapability (org.neo4j.internal.schema.IndexCapability)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1 KernelTransactionImplementation (org.neo4j.kernel.impl.api.KernelTransactionImplementation)1 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)1 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)1 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)1 ValueCategory (org.neo4j.values.storable.ValueCategory)1