Search in sources :

Example 1 with DoubleArray

use of org.neo4j.values.storable.DoubleArray in project neo4j by neo4j.

the class IndexSettingUtilTest method assertDoubleArray.

private static void assertDoubleArray(IndexSetting setting, Object object, double[] expectedResult) {
    Value result = IndexSettingUtil.asIndexSettingValue(setting, object);
    assertTrue(result instanceof DoubleArray);
    assertArrayEquals(expectedResult, ((DoubleArray) result).asObjectCopy());
}
Also used : StringValue(org.neo4j.values.storable.StringValue) BooleanValue(org.neo4j.values.storable.BooleanValue) Value(org.neo4j.values.storable.Value) DoubleArray(org.neo4j.values.storable.DoubleArray)

Example 2 with DoubleArray

use of org.neo4j.values.storable.DoubleArray in project neo4j by neo4j.

the class GenericNativeIndexProviderTest method completeConfigurationMustNotOverrideExistingSettings.

@Test
void completeConfigurationMustNotOverrideExistingSettings() {
    // Given
    DatabaseIndexContext context = DatabaseIndexContext.builder(null, null, DEFAULT_DATABASE_NAME).build();
    GenericNativeIndexProvider provider = new GenericNativeIndexProvider(context, IndexDirectoryStructure.NONE, null, Config.defaults());
    Map<String, Value> existingSettings = new HashMap<>();
    CoordinateReferenceSystem existingCrs = CoordinateReferenceSystem.Cartesian;
    DoubleArray min = Values.doubleArray(new double[] { 0, 0 });
    DoubleArray max = Values.doubleArray(new double[] { 1, 1 });
    existingSettings.put(spatialMinSettingForCrs(existingCrs).getSettingName(), min);
    existingSettings.put(spatialMaxSettingForCrs(existingCrs).getSettingName(), max);
    IndexConfig existingIndexConfig = IndexConfig.with(existingSettings);
    LabelSchemaDescriptor incompleteSchema = SchemaDescriptor.forLabel(1, 1);
    IndexDescriptor incompleteDescriptor = IndexPrototype.forSchema(incompleteSchema, IndexProviderDescriptor.UNDECIDED).withName("index").materialise(1).withIndexConfig(existingIndexConfig);
    // When
    IndexDescriptor completedDescriptor = provider.completeConfiguration(incompleteDescriptor);
    // Then
    IndexConfig completedIndexConfig = completedDescriptor.getIndexConfig();
    for (CoordinateReferenceSystem crs : CoordinateReferenceSystem.all()) {
        if (crs.equals(existingCrs)) {
            // Assert value
            assertEquals(min, completedIndexConfig.get(spatialMinSettingForCrs(crs).getSettingName()));
            assertEquals(max, completedIndexConfig.get(spatialMaxSettingForCrs(crs).getSettingName()));
        } else {
            // Simply assert not null
            assertNotNull(completedIndexConfig.get(spatialMinSettingForCrs(crs).getSettingName()));
            assertNotNull(completedIndexConfig.get(spatialMaxSettingForCrs(crs).getSettingName()));
        }
    }
}
Also used : IndexConfig(org.neo4j.internal.schema.IndexConfig) HashMap(java.util.HashMap) Value(org.neo4j.values.storable.Value) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) CoordinateReferenceSystem(org.neo4j.values.storable.CoordinateReferenceSystem) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) DoubleArray(org.neo4j.values.storable.DoubleArray) Test(org.junit.jupiter.api.Test)

Aggregations

DoubleArray (org.neo4j.values.storable.DoubleArray)2 Value (org.neo4j.values.storable.Value)2 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1 IndexConfig (org.neo4j.internal.schema.IndexConfig)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)1 BooleanValue (org.neo4j.values.storable.BooleanValue)1 CoordinateReferenceSystem (org.neo4j.values.storable.CoordinateReferenceSystem)1 StringValue (org.neo4j.values.storable.StringValue)1