use of org.neo4j.kernel.impl.index.schema.config.IndexSpecificSpaceFillingCurveSettings in project neo4j by neo4j.
the class IndexOrderTestBase method shouldNodeIndexScanInOrderWithPointsWithinSameTile.
@ParameterizedTest
@EnumSource(value = IndexOrder.class, names = { "ASCENDING", "DESCENDING" })
void shouldNodeIndexScanInOrderWithPointsWithinSameTile(IndexOrder indexOrder) throws Exception {
Config config = Config.defaults();
IndexSpecificSpaceFillingCurveSettings indexSettings = IndexSpecificSpaceFillingCurveSettings.fromConfig(config);
SpaceFillingCurve curve = indexSettings.forCrs(WGS84);
// given
// Many random points that all are close enough to each other to belong to the same tile on the space filling curve.
int nbrOfValues = 10000;
PointValue origin = Values.pointValue(WGS84, 0.0, 0.0);
Long derivedValueForCenterPoint = curve.derivedValueFor(origin.coordinate());
double[] centerPoint = curve.centerPointFor(derivedValueForCenterPoint);
double xWidthMultiplier = curve.getTileWidth(0, curve.getMaxLevel()) / 2;
double yWidthMultiplier = curve.getTileWidth(1, curve.getMaxLevel()) / 2;
List<Pair<Long, Value>> expected = new ArrayList<>();
try (KernelTransaction tx = beginTransaction()) {
// NOTE: strings come after points in natural ascending sort order
expected.add(entityWithProp(tx, "a"));
expected.add(entityWithProp(tx, "b"));
for (int i = 0; i < nbrOfValues / 8; i++) {
double x1 = (random.nextDouble() * 2 - 1) * xWidthMultiplier;
double x2 = (random.nextDouble() * 2 - 1) * xWidthMultiplier;
double y1 = (random.nextDouble() * 2 - 1) * yWidthMultiplier;
double y2 = (random.nextDouble() * 2 - 1) * yWidthMultiplier;
expected.add(entityWithProp(tx, Values.pointValue(WGS84, centerPoint[0] + x1, centerPoint[1] + y1)));
expected.add(entityWithProp(tx, Values.pointValue(WGS84, centerPoint[0] + x1, centerPoint[1] + y2)));
expected.add(entityWithProp(tx, Values.pointValue(WGS84, centerPoint[0] + x2, centerPoint[1] + y1)));
expected.add(entityWithProp(tx, Values.pointValue(WGS84, centerPoint[0] + x2, centerPoint[1] + y2)));
}
tx.commit();
}
createIndex();
// when
try (KernelTransaction tx = beginTransaction()) {
IndexReadSession index = tx.dataRead().indexReadSession(tx.schemaRead().indexGetForName(INDEX_NAME));
try (var cursor = getEntityValueIndexCursor(tx)) {
for (int i = 0; i < nbrOfValues / 8; i++) {
double x1 = (random.nextDouble() * 2 - 1) * xWidthMultiplier;
double x2 = (random.nextDouble() * 2 - 1) * xWidthMultiplier;
double y1 = (random.nextDouble() * 2 - 1) * yWidthMultiplier;
double y2 = (random.nextDouble() * 2 - 1) * yWidthMultiplier;
expected.add(entityWithProp(tx, Values.pointValue(WGS84, centerPoint[0] + x1, centerPoint[1] + y1)));
expected.add(entityWithProp(tx, Values.pointValue(WGS84, centerPoint[0] + x1, centerPoint[1] + y2)));
expected.add(entityWithProp(tx, Values.pointValue(WGS84, centerPoint[0] + x2, centerPoint[1] + y1)));
expected.add(entityWithProp(tx, Values.pointValue(WGS84, centerPoint[0] + x2, centerPoint[1] + y2)));
}
expected.add(entityWithProp(tx, "c"));
expected.add(entityWithProp(tx, "d"));
entityIndexScan(tx, index, cursor, constrained(indexOrder, true));
assertResultsInOrder(expected, cursor, indexOrder);
}
}
}
use of org.neo4j.kernel.impl.index.schema.config.IndexSpecificSpaceFillingCurveSettings in project neo4j by neo4j.
the class GenericNativeIndexProvider method layout.
@Override
GenericLayout layout(IndexDescriptor descriptor, Path storeFile) {
int numberOfSlots = descriptor.schema().getPropertyIds().length;
IndexConfig indexConfig = descriptor.getIndexConfig();
Map<CoordinateReferenceSystem, SpaceFillingCurveSettings> settings = SpatialIndexConfig.extractSpatialConfig(indexConfig);
return new GenericLayout(numberOfSlots, new IndexSpecificSpaceFillingCurveSettings(settings));
}
use of org.neo4j.kernel.impl.index.schema.config.IndexSpecificSpaceFillingCurveSettings in project neo4j by neo4j.
the class GenericNativeIndexAccessorTest method dropShouldDeleteEntireIndexFolder.
@Test
void dropShouldDeleteEntireIndexFolder() {
// given
Path root = testDirectory.directory("root");
IndexDirectoryStructure directoryStructure = IndexDirectoryStructure.directoriesByProvider(root).forProvider(GenericNativeIndexProvider.DESCRIPTOR);
long indexId = 8;
IndexDescriptor descriptor = forSchema(SchemaDescriptor.forLabel(1, 1)).withName("index").materialise(indexId);
IndexSpecificSpaceFillingCurveSettings spatialSettings = mock(IndexSpecificSpaceFillingCurveSettings.class);
IndexFiles indexFiles = new IndexFiles.Directory(fs, directoryStructure, descriptor.getId());
DatabaseIndexContext databaseIndexContext = DatabaseIndexContext.builder(pageCache, fs, DEFAULT_DATABASE_NAME).build();
GenericNativeIndexAccessor accessor = new GenericNativeIndexAccessor(databaseIndexContext, indexFiles, new GenericLayout(1, spatialSettings), immediate(), descriptor, spatialSettings, mock(SpaceFillingCurveConfiguration.class), SIMPLE_NAME_LOOKUP);
// when
accessor.drop();
// then
assertFalse(fs.fileExists(indexFiles.getBase()));
}
use of org.neo4j.kernel.impl.index.schema.config.IndexSpecificSpaceFillingCurveSettings in project neo4j by neo4j.
the class GenericBlockBasedIndexPopulatorTest method instantiatePopulator.
private GenericBlockBasedIndexPopulator instantiatePopulator(IndexDescriptor indexDescriptor) throws IOException {
Config config = Config.defaults();
IndexSpecificSpaceFillingCurveSettings spatialSettings = IndexSpecificSpaceFillingCurveSettings.fromConfig(config);
GenericLayout layout = new GenericLayout(1, spatialSettings);
SpaceFillingCurveConfiguration configuration = SpaceFillingCurveSettingsFactory.getConfiguredSpaceFillingCurveConfiguration(config);
GenericBlockBasedIndexPopulator populator = new GenericBlockBasedIndexPopulator(databaseIndexContext, indexFiles, layout, indexDescriptor, spatialSettings, configuration, false, heapBufferFactory((int) kibiBytes(40)), config, INSTANCE, tokenNameLookup);
populator.create();
return populator;
}
Aggregations