Search in sources :

Example 96 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class SchemaRuleSerialization35Test method assertParseIndexRule.

private static void assertParseIndexRule(String serialized, String name) throws Exception {
    // GIVEN
    long ruleId = 24;
    IndexPrototype prototype = forLabel(512, 4).withIndexProvider(PROVIDER_25);
    byte[] bytes = decodeBase64(serialized);
    // WHEN
    IndexDescriptor deserialized = assertIndexRule(SchemaRuleSerialization35.deserialize(ruleId, ByteBuffer.wrap(bytes)));
    // THEN
    assertThat(deserialized.getId()).isEqualTo(ruleId);
    assertThat(deserialized).isEqualTo(prototype.withName(name).materialise(ruleId));
    assertThat(deserialized.schema()).isEqualTo(prototype.schema());
    assertThat(deserialized.getIndexProvider().getKey()).isEqualTo(PROVIDER_KEY);
    assertThat(deserialized.getIndexProvider().getVersion()).isEqualTo(PROVIDER_VERSION_25);
    assertThat(deserialized.getName()).isEqualTo(name);
    assertTrue(deserialized.getOwningConstraintId().isEmpty());
}
Also used : IndexPrototype(org.neo4j.internal.schema.IndexPrototype) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 97 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class SchemaStore35Test method storeAndLoad_Big_CompositeSchemaRule.

@Test
void storeAndLoad_Big_CompositeSchemaRule() throws Exception {
    // GIVEN
    long id = store.nextId(NULL);
    IndexDescriptor indexRule = IndexPrototype.forSchema(forLabel(2, range(1, 200).toArray()), PROVIDER).withName("index_" + id).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 : IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 98 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor 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 99 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class SchemaStore35Test method storeAndLoadMultiTokenSchemaRule.

@Test
void storeAndLoadMultiTokenSchemaRule() throws Exception {
    // GIVEN
    int[] propertyIds = { 4, 5, 6, 7 };
    int[] entityTokens = { 2, 3, 4 };
    long id = store.nextId(NULL);
    IndexDescriptor indexRule = IndexPrototype.forSchema(fulltext(EntityType.RELATIONSHIP, entityTokens, propertyIds), 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 : IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 100 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class SchemaStore35Test method storeAndLoadCompositeSchemaRule.

@Test
void storeAndLoadCompositeSchemaRule() throws Exception {
    // GIVEN
    int[] propertyIds = { 4, 5, 6, 7 };
    long id = store.nextId(NULL);
    IndexDescriptor indexRule = IndexPrototype.forSchema(forLabel(2, propertyIds), PROVIDER).withName("index_" + id).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 : IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)404 Test (org.junit.jupiter.api.Test)231 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)81 Value (org.neo4j.values.storable.Value)43 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)33 ArrayList (java.util.ArrayList)31 Transaction (org.neo4j.graphdb.Transaction)31 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)31 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)30 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)30 TokenRead (org.neo4j.internal.kernel.api.TokenRead)29 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 SchemaRead (org.neo4j.internal.kernel.api.SchemaRead)26 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)25 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)25 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)23 IndexNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)23 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)23 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)22 KernelException (org.neo4j.exceptions.KernelException)20