Search in sources :

Example 1 with IndexConfig

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

the class LuceneFulltextIndexTest method completeConfigurationMustNotOverwriteExistingConfiguration.

@Test
void completeConfigurationMustNotOverwriteExistingConfiguration() {
    IndexConfig indexConfig = IndexConfig.with("A", Values.stringValue("B"));
    FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { 1 }, new int[] { 1 });
    IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
    IndexDescriptor descriptor = indexProvider.completeConfiguration(IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").materialise(1)).withIndexConfig(indexConfig);
    assertEquals(Values.stringValue("B"), descriptor.getIndexConfig().get("A"));
}
Also used : IndexConfig(org.neo4j.internal.schema.IndexConfig) 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 2 with IndexConfig

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

the class LuceneFulltextIndexTest method completeConfigurationMustInjectMissingConfigurations.

@Test
void completeConfigurationMustInjectMissingConfigurations() throws Exception {
    int label;
    int propertyKey;
    try (Transaction tx = db.beginTx()) {
        createNodeIndexableByPropertyValue(tx, LABEL, "bla");
        tx.commit();
    }
    try (KernelTransactionImplementation tx = getKernelTransaction()) {
        label = tx.tokenRead().nodeLabel(LABEL.name());
        propertyKey = tx.tokenRead().propertyKey(PROP);
        tx.success();
    }
    IndexConfig indexConfig = IndexConfig.with(EVENTUALLY_CONSISTENT, Values.booleanValue(true));
    FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { label }, new int[] { propertyKey });
    IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
    IndexDescriptor descriptor = indexProvider.completeConfiguration(IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").withIndexConfig(indexConfig).materialise(1));
    assertThat((Value) descriptor.getIndexConfig().get(ANALYZER)).isEqualTo(Values.stringValue("standard-no-stop-words"));
    assertThat((Value) descriptor.getIndexConfig().get(EVENTUALLY_CONSISTENT)).isEqualTo(Values.booleanValue(true));
    assertThat(asList(descriptor.getCapability().behaviours())).containsExactlyInAnyOrder(IndexBehaviour.EVENTUALLY_CONSISTENT, IndexBehaviour.SKIP_AND_LIMIT);
}
Also used : IndexConfig(org.neo4j.internal.schema.IndexConfig) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) Value(org.neo4j.values.storable.Value) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 3 with IndexConfig

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

the class SchemaStorageIT method shouldWriteAndReadIndexConfig.

@Test
void shouldWriteAndReadIndexConfig() throws KernelException {
    // given
    IndexConfig expected = IndexConfig.with(MapUtil.genericMap("value.string", Values.stringValue("value"), "value.int", Values.intValue(1), "value.doubleArray", Values.doubleArray(new double[] { 0.4, 0.6, 1.0 }), "value.boolean", Values.booleanValue(true)));
    var cursorContext = NULL;
    SchemaDescriptor schema = forLabel(labelId(LABEL1), propId(PROP1));
    long id = schemaStore.nextId(cursorContext);
    IndexDescriptor storeIndexDescriptor = forSchema(schema).withName("index_" + id).materialise(id).withIndexConfig(expected);
    storage.writeSchemaRule(storeIndexDescriptor, cursorContext, INSTANCE);
    // when
    IndexDescriptor schemaRule = (IndexDescriptor) storage.loadSingleSchemaRule(id, NULL);
    // Clean up after ourselves.
    storage.deleteSchemaRule(schemaRule, NULL);
    // then
    IndexConfig actual = schemaRule.getIndexConfig();
    assertEquals(expected, actual, "Read index config not same as written, expected " + expected + ", actual " + actual);
}
Also used : SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) IndexConfig(org.neo4j.internal.schema.IndexConfig) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 4 with IndexConfig

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

the class SpatialConfigExtractorTest method shouldBeAbleToExtractConfigFromHealthy35File.

@Test
void shouldBeAbleToExtractConfigFromHealthy35File() throws IOException {
    // given
    unzip(getClass(), ZIP_HEALTHY_SPATIAL_35_DIR, directory.homePath());
    Path spatialDir = directory.file(HEALTHY_SPATIAL_35_DIR);
    // and
    assertTrue(fs.fileExists(spatialDir));
    // when
    List<SpatialFile> spatialFiles = IndexMigration.getSpatialFiles(fs, spatialDir);
    IndexConfig indexConfig = SpatialConfigExtractor.indexConfigFromSpatialFile(pageCache, spatialFiles, NULL, NullLog.getInstance(), DEFAULT_DATABASE_NAME);
    // then
    assertExpectedIndexConfig(indexConfig);
}
Also used : Path(java.nio.file.Path) IndexConfig(org.neo4j.internal.schema.IndexConfig) Test(org.junit.jupiter.api.Test)

Example 5 with IndexConfig

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

the class SpatialIndexConfigTest method mustAddAndExtractSpatialConfigToIndexConfig.

@Test
void mustAddAndExtractSpatialConfigToIndexConfig() {
    IndexConfig indexConfig = IndexConfig.empty();
    Map<CoordinateReferenceSystem, SpaceFillingCurveSettings> expectedMap = new HashMap<>();
    for (CoordinateReferenceSystem crs : CoordinateReferenceSystem.all()) {
        Config config = Config.defaults();
        SpaceFillingCurveSettings spaceFillingCurveSettings = new ConfiguredSpaceFillingCurveSettingsCache(config).forCRS(crs);
        expectedMap.put(crs, spaceFillingCurveSettings);
        indexConfig = SpatialIndexConfig.addSpatialConfig(indexConfig, crs, spaceFillingCurveSettings);
    }
    Map<CoordinateReferenceSystem, SpaceFillingCurveSettings> extractedMap = SpatialIndexConfig.extractSpatialConfig(indexConfig);
    assertEquals(expectedMap, extractedMap);
}
Also used : IndexConfig(org.neo4j.internal.schema.IndexConfig) SpaceFillingCurveSettings(org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettings) HashMap(java.util.HashMap) Config(org.neo4j.configuration.Config) IndexConfig(org.neo4j.internal.schema.IndexConfig) ConfiguredSpaceFillingCurveSettingsCache(org.neo4j.kernel.impl.index.schema.config.ConfiguredSpaceFillingCurveSettingsCache) CoordinateReferenceSystem(org.neo4j.values.storable.CoordinateReferenceSystem) Test(org.junit.jupiter.api.Test)

Aggregations

IndexConfig (org.neo4j.internal.schema.IndexConfig)21 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)10 Test (org.junit.jupiter.api.Test)9 Value (org.neo4j.values.storable.Value)6 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)5 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)4 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)4 CoordinateReferenceSystem (org.neo4j.values.storable.CoordinateReferenceSystem)4 HashMap (java.util.HashMap)3 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)3 Path (java.nio.file.Path)2 StringJoiner (java.util.StringJoiner)2 Config (org.neo4j.configuration.Config)2 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)2 KernelTransactionImplementation (org.neo4j.kernel.impl.api.KernelTransactionImplementation)2 SpaceFillingCurveSettings (org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettings)2 BooleanValue (org.neo4j.values.storable.BooleanValue)2 DoubleArray (org.neo4j.values.storable.DoubleArray)2 IntValue (org.neo4j.values.storable.IntValue)2 StringValue (org.neo4j.values.storable.StringValue)2