Esempio n. 1
0
 private void StartSeekForRange(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient client, IndexQuery.GeometryRangePredicate rangePredicate, IndexQuery[] query)
 {
     try
     {
         BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(client, descriptor.schema().PropertyIds);
         client.Initialize(descriptor, multiProgressor, query, IndexOrder.NONE, false);
         SpaceFillingCurve curve = _spatial.SpaceFillingCurve;
         double[]          from  = rangePredicate.From() == null ? null : rangePredicate.From().coordinate();
         double[]          to    = rangePredicate.To() == null ? null : rangePredicate.To().coordinate();
         IList <SpaceFillingCurve.LongRange> ranges = curve.GetTilesIntersectingEnvelope(from, to, _configuration);
         foreach (SpaceFillingCurve.LongRange range in ranges)
         {
             SpatialIndexKey treeKeyFrom = layout.newKey();
             SpatialIndexKey treeKeyTo   = layout.newKey();
             InitializeKeys(treeKeyFrom, treeKeyTo);
             treeKeyFrom.FromDerivedValue(long.MinValue, range.Min);
             treeKeyTo.FromDerivedValue(long.MaxValue, range.Max + 1);
             RawCursor <Hit <SpatialIndexKey, VALUE>, IOException> seeker = makeIndexSeeker(treeKeyFrom, treeKeyTo, IndexOrder.NONE);
             IndexProgressor hitProgressor = new NativeHitIndexProgressor <>(seeker, client, openSeekers);
             multiProgressor.Initialize(descriptor, hitProgressor, query, IndexOrder.NONE, false);
         }
     }
     catch (System.ArgumentException)
     {
         // Invalid query ranges will cause this state (eg. min>max)
         client.Initialize(descriptor, IndexProgressor.EMPTY, query, IndexOrder.NONE, false);
     }
     catch (IOException e)
     {
         throw new UncheckedIOException(e);
     }
 }
 private static void InitializeKeys(SpatialIndexKey from, SpatialIndexKey to)
 {
     from.initialize(long.MinValue);
     to.initialize(long.MaxValue);
     from.InitValueAsLowest(ValueGroup.GEOMETRY);
     to.InitValueAsHighest(ValueGroup.GEOMETRY);
 }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static void verify(org.neo4j.storageengine.api.NodePropertyAccessor nodePropertyAccessor, IndexLayout<SpatialIndexKey,NativeIndexValue> layout, org.neo4j.index.internal.gbptree.GBPTree<SpatialIndexKey,NativeIndexValue> tree, org.neo4j.storageengine.api.schema.StoreIndexDescriptor descriptor) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        internal static void Verify(NodePropertyAccessor nodePropertyAccessor, IndexLayout <SpatialIndexKey, NativeIndexValue> layout, GBPTree <SpatialIndexKey, NativeIndexValue> tree, StoreIndexDescriptor descriptor)
        {
            SpatialIndexKey from = layout.newKey();
            SpatialIndexKey to   = layout.newKey();

            InitializeKeys(from, to);
            try
            {
                using (RawCursor <Hit <SpatialIndexKey, NativeIndexValue>, IOException> seek = tree.Seek(from, to))
                {
                    ScanAndVerifyDuplicates(nodePropertyAccessor, descriptor, seek);
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
Esempio n. 4
0
        public override void Query(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient cursor, IndexOrder indexOrder, bool needsValues, params IndexQuery[] predicates)
        {
            // Spatial does not support providing values
            if (needsValues)
            {
                throw new System.InvalidOperationException("Spatial index does not support providing values");
            }

            ValidateQuery(indexOrder, predicates);
            IndexQuery predicate = predicates[0];

            SpatialIndexKey treeKeyFrom = layout.newKey();
            SpatialIndexKey treeKeyTo   = layout.newKey();

            InitializeKeys(treeKeyFrom, treeKeyTo);

            switch (predicate.Type())
            {
            case exists:
                StartSeekForExists(treeKeyFrom, treeKeyTo, cursor, predicate);
                break;

            case exact:
                StartSeekForExact(treeKeyFrom, treeKeyTo, cursor, ((IndexQuery.ExactPredicate)predicate).value(), predicate);
                break;

            case range:
                IndexQuery.GeometryRangePredicate rangePredicate = (IndexQuery.GeometryRangePredicate)predicate;
                if (!rangePredicate.Crs().Equals(_spatial.crs))
                {
                    throw new System.ArgumentException("IndexQuery on spatial index with mismatching CoordinateReferenceSystem: " + rangePredicate.Crs() + " != " + _spatial.crs);
                }
                StartSeekForRange(cursor, rangePredicate, predicates);
                break;

            default:
                throw new System.ArgumentException("IndexQuery of type " + predicate.Type() + " is not supported.");
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void scanAndVerifyDuplicates(org.neo4j.storageengine.api.NodePropertyAccessor nodePropertyAccessor, org.neo4j.storageengine.api.schema.StoreIndexDescriptor descriptor, org.neo4j.cursor.RawCursor<org.neo4j.index.internal.gbptree.Hit<SpatialIndexKey,NativeIndexValue>,java.io.IOException> seek) throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        private static void ScanAndVerifyDuplicates(NodePropertyAccessor nodePropertyAccessor, StoreIndexDescriptor descriptor, RawCursor <Hit <SpatialIndexKey, NativeIndexValue>, IOException> seek)
        {
            LongArrayList nodesWithCollidingPoints = new LongArrayList();
            long          prevRawBits = long.MinValue;

            // Bootstrap starting state
            if (seek.Next())
            {
                Hit <SpatialIndexKey, NativeIndexValue> hit = seek.get();
                prevRawBits = hit.Key().RawValueBits;
                nodesWithCollidingPoints.add(hit.Key().EntityId);
            }

            while (seek.Next())
            {
                Hit <SpatialIndexKey, NativeIndexValue> hit = seek.get();
                SpatialIndexKey key            = hit.Key();
                long            currentRawBits = key.RawValueBits;
                long            currentNodeId  = key.EntityId;
                if (prevRawBits != currentRawBits)
                {
                    if (nodesWithCollidingPoints.size() > 1)
                    {
                        VerifyConstraintOn(nodesWithCollidingPoints, nodePropertyAccessor, descriptor);
                    }
                    nodesWithCollidingPoints.clear();
                }
                nodesWithCollidingPoints.add(currentNodeId);
                prevRawBits = currentRawBits;
            }

            // Verify the last batch if needed
            if (nodesWithCollidingPoints.size() > 1)
            {
                VerifyConstraintOn(nodesWithCollidingPoints, nodePropertyAccessor, descriptor);
            }
        }
Esempio n. 6
0
        public override void DistinctValues(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient client, NodePropertyAccessor propertyAccessor, bool needsValues)
        {
            // This is basically a version of the basic implementation, but with added consulting of the PropertyAccessor
            // since these are lossy spatial values.
            SpatialIndexKey lowest = layout.newKey();

            lowest.initialize(long.MinValue);
            lowest.initValuesAsLowest();
            SpatialIndexKey highest = layout.newKey();

            highest.initialize(long.MaxValue);
            highest.initValuesAsHighest();
            try
            {
                RawCursor <Hit <SpatialIndexKey, VALUE>, IOException> seeker = tree.seek(lowest, highest);
                IComparer <SpatialIndexKey> comparator = new PropertyLookupFallbackComparator <SpatialIndexKey>(layout, propertyAccessor, descriptor.schema().PropertyId);
                NativeDistinctValuesProgressor <SpatialIndexKey, VALUE> progressor = new NativeDistinctValuesProgressorAnonymousInnerClass(this, seeker, client, openSeekers, layout, comparator, propertyAccessor);
                client.Initialize(descriptor, progressor, new IndexQuery[0], IndexOrder.NONE, false);
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
Esempio n. 7
0
 internal override bool InitializeRangeForQuery(SpatialIndexKey treeKeyFrom, SpatialIndexKey treeKeyTo, IndexQuery[] predicates)
 {
     throw new System.NotSupportedException("Cannot initialize 1D range in multidimensional spatial index reader");
 }
Esempio n. 8
0
 private void InitializeKeys(SpatialIndexKey treeKeyFrom, SpatialIndexKey treeKeyTo)
 {
     treeKeyFrom.initialize(long.MinValue);
     treeKeyTo.initialize(long.MaxValue);
 }
Esempio n. 9
0
        internal override void StartSeekForInitializedRange(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient client, SpatialIndexKey treeKeyFrom, SpatialIndexKey treeKeyTo, IndexQuery[] query, IndexOrder indexOrder, bool needFilter, bool needsValues)
        {
            // Spatial does not support providing values
            Debug.Assert(!needsValues);

            if (layout.compare(treeKeyFrom, treeKeyTo) > 0)
            {
                client.Initialize(descriptor, IndexProgressor.EMPTY, query, IndexOrder.NONE, false);
                return;
            }
            try
            {
                RawCursor <Hit <SpatialIndexKey, VALUE>, IOException> seeker = makeIndexSeeker(treeKeyFrom, treeKeyTo, indexOrder);
                IndexProgressor hitProgressor = new NativeHitIndexProgressor <>(seeker, client, openSeekers);
                client.Initialize(descriptor, hitProgressor, query, IndexOrder.NONE, false);
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
Esempio n. 10
0
 private void StartSeekForExact(SpatialIndexKey treeKeyFrom, SpatialIndexKey treeKeyTo, Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient client, Value value, params IndexQuery[] predicates)
 {
     treeKeyFrom.From(value);
     treeKeyTo.From(value);
     StartSeekForInitializedRange(client, treeKeyFrom, treeKeyTo, predicates, IndexOrder.NONE, false, false);
 }
Esempio n. 11
0
 private void StartSeekForExists(SpatialIndexKey treeKeyFrom, SpatialIndexKey treeKeyTo, Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient client, params IndexQuery[] predicates)
 {
     treeKeyFrom.InitValueAsLowest(ValueGroup.GEOMETRY);
     treeKeyTo.InitValueAsHighest(ValueGroup.GEOMETRY);
     StartSeekForInitializedRange(client, treeKeyFrom, treeKeyTo, predicates, IndexOrder.NONE, false, false);
 }