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));
}
}
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();
}
}
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));
}
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);
}
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));
}
Aggregations