Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87f63c0
commit d2e2a59
Showing
4 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialLayoutTestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.index.schema; | ||
|
||
import org.neo4j.gis.spatial.index.Envelope; | ||
import org.neo4j.gis.spatial.index.curves.HilbertSpaceFillingCurve2D; | ||
import org.neo4j.gis.spatial.index.curves.SpaceFillingCurve; | ||
import org.neo4j.index.internal.gbptree.Layout; | ||
import org.neo4j.internal.kernel.api.IndexQuery; | ||
import org.neo4j.kernel.api.index.IndexEntryUpdate; | ||
import org.neo4j.kernel.api.schema.index.IndexDescriptor; | ||
import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; | ||
import org.neo4j.values.storable.CoordinateReferenceSystem; | ||
import org.neo4j.values.storable.PointValue; | ||
import org.neo4j.values.storable.Value; | ||
import org.neo4j.values.storable.Values; | ||
|
||
class SpatialLayoutTestUtil extends LayoutTestUtil<SpatialSchemaKey,NativeSchemaValue> | ||
{ | ||
private CoordinateReferenceSystem crs = CoordinateReferenceSystem.WGS84; | ||
private SpaceFillingCurve curve = new HilbertSpaceFillingCurve2D( new Envelope( -180, 180, -90, 90 ) ); | ||
|
||
SpatialLayoutTestUtil() | ||
{ | ||
super( IndexDescriptorFactory.forLabel( 42, 666 ) ); | ||
} | ||
|
||
@Override | ||
Layout<SpatialSchemaKey,NativeSchemaValue> createLayout() | ||
{ | ||
return new SpatialLayoutNonUnique( crs, curve ); | ||
} | ||
|
||
@Override | ||
IndexEntryUpdate<IndexDescriptor>[] someUpdates() | ||
{ | ||
return someSpatialUpdatesWithDuplicateValues(); | ||
} | ||
|
||
@Override | ||
protected double fractionDuplicates() | ||
{ | ||
return 0.1; | ||
} | ||
|
||
@Override | ||
IndexQuery rangeQuery( Number from, boolean fromInclusive, Number to, boolean toInclusive ) | ||
{ | ||
return IndexQuery.range( 0, (PointValue) asValue( from ), fromInclusive, (PointValue) asValue( to ), toInclusive ); | ||
} | ||
|
||
@Override | ||
Value asValue( Number value ) | ||
{ | ||
return Values.pointValue( CoordinateReferenceSystem.WGS84, value.doubleValue(), value.doubleValue() ); | ||
} | ||
|
||
// TODO fix this comparison | ||
@Override | ||
int compareIndexedPropertyValue( SpatialSchemaKey key1, SpatialSchemaKey key2 ) | ||
{ | ||
int typeCompare = Byte.compare( key1.type, key2.type ); | ||
if ( typeCompare == 0 ) | ||
{ | ||
return Long.compare( key1.rawValueBits, key2.rawValueBits ); | ||
} | ||
return typeCompare; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueSchemaIndexAccessorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.index.schema; | ||
|
||
public class SpatialNonUniqueSchemaIndexAccessorTest extends SpatialSchemaIndexAccessorTest<SpatialSchemaKey,NativeSchemaValue> | ||
{ | ||
@Override | ||
protected LayoutTestUtil<SpatialSchemaKey,NativeSchemaValue> createLayoutTestUtil() | ||
{ | ||
return new SpatialLayoutTestUtil(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...rnel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialSchemaIndexAccessorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.index.schema; | ||
|
||
import java.io.IOException; | ||
|
||
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; | ||
|
||
import static org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.IMMEDIATE; | ||
|
||
public abstract class SpatialSchemaIndexAccessorTest<KEY extends SpatialSchemaKey, VALUE extends NativeSchemaValue> | ||
extends NativeSchemaIndexAccessorTest<KEY,VALUE> | ||
{ | ||
NativeSchemaIndexAccessor<KEY,VALUE> makeAccessorWithSamplingConfig( IndexSamplingConfig samplingConfig ) throws IOException | ||
{ | ||
return new SpatialSchemaIndexAccessor<>( pageCache, fs, indexFile, layout, IMMEDIATE, monitor, indexDescriptor, indexId, samplingConfig ); | ||
} | ||
} |