Search in sources :

Example 16 with PointValue

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

the class IndexConfigMigrationIT method shouldHaveCorrectDataAndIndexConfiguration.

@Test
void shouldHaveCorrectDataAndIndexConfiguration() throws IOException, IndexNotFoundKernelException {
    Path databaseDir = databaseLayout.databaseDirectory();
    unzip(getClass(), ZIP_FILE_3_5, databaseDir);
    // when
    DatabaseManagementServiceBuilder builder = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setConfig(GraphDatabaseSettings.allow_upgrade, true);
    DatabaseManagementService dbms = builder.build();
    try {
        GraphDatabaseAPI db = (GraphDatabaseAPI) dbms.database(DEFAULT_DATABASE_NAME);
        Set<CoordinateReferenceSystem> allCRS = Iterables.asSet(all());
        try (Transaction tx = db.beginTx()) {
            validateIndexes(tx);
            for (Node node : tx.getAllNodes()) {
                hasLabels(node, label1, label2, label3, label4);
                Object property = node.getProperty(propKey);
                if (property instanceof PointValue) {
                    allCRS.remove(((PointValue) property).getCoordinateReferenceSystem());
                }
            }
            assertTrue(allCRS.isEmpty(), "Expected all CRS to be represented in store, but missing " + allCRS);
            assertIndexConfiguration(db, tx);
            assertFulltextIndexConfiguration(db, tx);
            tx.commit();
        }
    } finally {
        dbms.shutdown();
    }
    // Assert old index files has been removed
    Path baseSchemaIndexFolder = IndexDirectoryStructure.baseSchemaIndexFolder(databaseDir);
    Set<Path> retiredIndexProviderDirectories = Set.of(baseSchemaIndexFolder.resolve("lucene"), baseSchemaIndexFolder.resolve("lucene-1.0"), baseSchemaIndexFolder.resolve("lucene_native-1.0"), baseSchemaIndexFolder.resolve("lucene_native-2.0"));
    try (Stream<Path> list = Files.list(baseSchemaIndexFolder)) {
        list.forEach(indexProviderDirectory -> assertFalse(retiredIndexProviderDirectories.contains(indexProviderDirectory), "Expected old index provider directories to be deleted during migration but store still had directory " + indexProviderDirectory));
    }
}
Also used : Path(java.nio.file.Path) PointValue(org.neo4j.values.storable.PointValue) Node(org.neo4j.graphdb.Node) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) CoordinateReferenceSystem(org.neo4j.values.storable.CoordinateReferenceSystem) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test)

Example 17 with PointValue

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

the class BatchInsertIndexTest method shouldThrowWhenPopulatingWithNonUniquePoints.

@ParameterizedTest
@EnumSource(SchemaIndex.class)
void shouldThrowWhenPopulatingWithNonUniquePoints(SchemaIndex schemaIndex) throws Exception {
    configure(schemaIndex);
    BatchInserter inserter = newBatchInserter();
    PointValue point = Values.pointValue(CoordinateReferenceSystem.WGS84, 0.0, 0.0);
    inserter.createNode(MapUtil.map("prop", point), LABEL_ONE);
    inserter.createNode(MapUtil.map("prop", point), LABEL_ONE);
    inserter.createDeferredConstraint(LABEL_ONE).assertPropertyIsUnique("prop").create();
    inserter.shutdown();
    GraphDatabaseService db = startGraphDatabaseService();
    try (Transaction tx = db.beginTx()) {
        assertThrows(IllegalStateException.class, () -> tx.schema().awaitIndexesOnline(10, TimeUnit.SECONDS));
    }
    try (Transaction tx = db.beginTx()) {
        var schema = tx.schema();
        Iterator<IndexDefinition> indexes = schema.getIndexes().iterator();
        assertTrue(indexes.hasNext());
        IndexDefinition index = indexes.next();
        Schema.IndexState indexState = schema.getIndexState(index);
        assertEquals(Schema.IndexState.FAILED, indexState);
        assertFalse(indexes.hasNext());
        tx.commit();
    }
}
Also used : BatchInserter(org.neo4j.batchinsert.BatchInserter) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) PointValue(org.neo4j.values.storable.PointValue) Schema(org.neo4j.graphdb.schema.Schema) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with PointValue

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

the class CompositeIndexAccessorCompatibility method testIndexScanAndSeekExactWithExactByPoint.

@Test
public void testIndexScanAndSeekExactWithExactByPoint() throws Exception {
    Assume.assumeTrue("Assume support for spatial", testSuite.supportsSpatial());
    PointValue gps = pointValue(WGS84, 12.6, 56.7);
    PointValue car = pointValue(Cartesian, 12.6, 56.7);
    PointValue gps3d = pointValue(CoordinateReferenceSystem.WGS84_3D, 12.6, 56.7, 100.0);
    PointValue car3d = pointValue(CoordinateReferenceSystem.Cartesian_3D, 12.6, 56.7, 100.0);
    updateAndCommit(asList(add(1L, descriptor.schema(), gps, gps), add(2L, descriptor.schema(), car, car), add(3L, descriptor.schema(), gps, car), add(4L, descriptor.schema(), gps3d, gps3d), add(5L, descriptor.schema(), car3d, car3d), add(6L, descriptor.schema(), gps, car3d)));
    assertThat(query(exact(0, gps), exact(1, gps))).isEqualTo(singletonList(1L));
    assertThat(query(exact(0, car), exact(1, car))).isEqualTo(singletonList(2L));
    assertThat(query(exact(0, gps), exact(1, car))).isEqualTo(singletonList(3L));
    assertThat(query(exact(0, gps3d), exact(1, gps3d))).isEqualTo(singletonList(4L));
    assertThat(query(exact(0, car3d), exact(1, car3d))).isEqualTo(singletonList(5L));
    assertThat(query(exact(0, gps), exact(1, car3d))).isEqualTo(singletonList(6L));
    assertThat(query(exists(1))).isEqualTo(asList(1L, 2L, 3L, 4L, 5L, 6L));
}
Also used : PointValue(org.neo4j.values.storable.PointValue) Test(org.junit.Test)

Example 19 with PointValue

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

the class AnyValueComparatorTest method shouldTernaryComparePoints.

@Test
void shouldTernaryComparePoints() {
    PointValue pointValue1 = pointValue(CoordinateReferenceSystem.Cartesian, 1.0, 1.0);
    PointValue pointValue2 = pointValue(CoordinateReferenceSystem.Cartesian, 1.0, 2.0);
    assertTernaryCompare(pointValue1, pointValue1, EQUAL);
    assertTernaryCompare(pointValue1, pointValue2, SMALLER_THAN_AND_EQUAL);
    assertTernaryCompare(pointValue1, Values.doubleArray(new double[] { 1.0, 1.0 }), UNDEFINED);
    assertTernaryCompare(pointValue1, pointValue(CoordinateReferenceSystem.WGS84, 1.0, 1.0), UNDEFINED);
}
Also used : PointValue(org.neo4j.values.storable.PointValue) Test(org.junit.jupiter.api.Test)

Example 20 with PointValue

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

the class Neo4jPackV2Test method testPackingPointsWithWrongDimensions.

private void testPackingPointsWithWrongDimensions(int dimensions) {
    PointValue point = randomPoint(0, dimensions);
    assertThrows(IllegalArgumentException.class, () -> pack(point));
}
Also used : PointValue(org.neo4j.values.storable.PointValue) Values.unsafePointValue(org.neo4j.values.storable.Values.unsafePointValue)

Aggregations

PointValue (org.neo4j.values.storable.PointValue)32 Test (org.junit.jupiter.api.Test)16 ArrayList (java.util.ArrayList)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 Value (org.neo4j.values.storable.Value)9 EnumSource (org.junit.jupiter.params.provider.EnumSource)7 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)7 Transaction (org.neo4j.graphdb.Transaction)6 Pair (org.neo4j.internal.helpers.collection.Pair)6 CoordinateReferenceSystem (org.neo4j.values.storable.CoordinateReferenceSystem)6 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)5 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)5 Values.stringValue (org.neo4j.values.storable.Values.stringValue)5 Path (java.nio.file.Path)4 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)4 Node (org.neo4j.graphdb.Node)4 TextValue (org.neo4j.values.storable.TextValue)4 Values.pointValue (org.neo4j.values.storable.Values.pointValue)4 SpaceFillingCurve (org.neo4j.gis.spatial.index.curves.SpaceFillingCurve)3 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)3