Beispiel #1
0
        public override void DistinctValues(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient cursor, NodePropertyAccessor propertyAccessor, bool needsValues)
        {
            BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(cursor, _descriptor.schema().PropertyIds);

            cursor.Initialize(_descriptor, multiProgressor, new IndexQuery[0], IndexOrder.NONE, needsValues);
            InstanceSelector.forAll(reader => reader.distinctValues(multiProgressor, propertyAccessor, needsValues));
        }
Beispiel #2
0
 /// <summary>
 /// OBS this implementation can only provide values for properties of type <seealso cref="string"/>.
 /// Other property types will still be counted as distinct, but {@code client} won't receive <seealso cref="Value"/>
 /// instances for those. </summary>
 /// <param name="client"> <seealso cref="IndexProgressor.NodeValueClient"/> to get initialized with this progression. </param>
 /// <param name="propertyAccessor"> <seealso cref="NodePropertyAccessor"/> for reading property values. </param>
 /// <param name="needsValues"> whether or not to load string values. </param>
 public override void DistinctValues(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient client, NodePropertyAccessor propertyAccessor, bool needsValues)
 {
     try
     {
         IndexQuery[]            noQueries       = new IndexQuery[0];
         BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(client, _descriptor.schema().PropertyIds);
         Fields fields = MultiFields.getFields(IndexSearcher.IndexReader);
         foreach (ValueEncoding valueEncoding in ValueEncoding.values())
         {
             Terms terms = fields.terms(valueEncoding.key());
             if (terms != null)
             {
                 System.Func <BytesRef, Value> valueMaterializer = valueEncoding == ValueEncoding.String && needsValues ? term => Values.stringValue(term.utf8ToString()) : term => null;
                 TermsEnum termsIterator = terms.GetEnumerator();
                 if (valueEncoding == ValueEncoding.Number)
                 {
                     termsIterator = NumericUtils.filterPrefixCodedLongs(termsIterator);
                 }
                 multiProgressor.Initialize(_descriptor, new LuceneDistinctValuesProgressor(termsIterator, client, valueMaterializer), noQueries, IndexOrder.NONE, needsValues);
             }
         }
         client.Initialize(_descriptor, multiProgressor, noQueries, IndexOrder.NONE, needsValues);
     }
     catch (IOException e)
     {
         throw new UncheckedIOException(e);
     }
 }
Beispiel #3
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);
     }
 }
Beispiel #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");
            }

            if (predicates.Length != 1)
            {
                throw new System.ArgumentException("Only single property spatial indexes are supported.");
            }
            IndexQuery predicate = predicates[0];

            if (predicate is IndexQuery.ExistsPredicate)
            {
                LoadAll();
                BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(cursor, _descriptor.schema().PropertyIds);
                cursor.Initialize(_descriptor, multiProgressor, predicates, indexOrder, false);
                foreach (NativeIndexReader <SpatialIndexKey, NativeIndexValue> reader in this)
                {
                    reader.Query(multiProgressor, indexOrder, false, predicates);
                }
            }
            else
            {
                if (ValidPredicate(predicate))
                {
                    CoordinateReferenceSystem crs;
                    if (predicate is IndexQuery.ExactPredicate)
                    {
                        crs = (( PointValue )((IndexQuery.ExactPredicate)predicate).value()).CoordinateReferenceSystem;
                    }
                    else if (predicate is IndexQuery.GeometryRangePredicate)
                    {
                        crs = ((IndexQuery.GeometryRangePredicate)predicate).crs();
                    }
                    else
                    {
                        throw new System.ArgumentException("Wrong type of predicate, couldn't get CoordinateReferenceSystem");
                    }
                    SpatialIndexPartReader <NativeIndexValue> part = UncheckedSelect(crs);
                    if (part != null)
                    {
                        part.Query(cursor, indexOrder, false, predicates);
                    }
                    else
                    {
                        cursor.Initialize(_descriptor, IndexProgressor.EMPTY, predicates, indexOrder, false);
                    }
                }
                else
                {
                    cursor.Initialize(_descriptor, IndexProgressor.EMPTY, predicates, indexOrder, false);
                }
            }
        }
Beispiel #5
0
        public override void DistinctValues(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient cursor, NodePropertyAccessor propertyAccessor, bool needsValues)
        {
            LoadAll();
            BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(cursor, _descriptor.schema().PropertyIds);

            cursor.Initialize(_descriptor, multiProgressor, new IndexQuery[0], IndexOrder.NONE, needsValues);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (NativeIndexReader<?,NativeIndexValue> reader : this)
            foreach (NativeIndexReader <object, NativeIndexValue> reader in this)
            {
                reader.DistinctValues(multiProgressor, propertyAccessor, needsValues);
            }
        }
Beispiel #6
0
        public override void Query(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient cursor, IndexOrder indexOrder, bool needsValues, params IndexQuery[] predicates)
        {
            if (predicates.Length != 1)
            {
                throw new System.ArgumentException("Only single property temporal indexes are supported.");
            }
            IndexQuery predicate = predicates[0];

            if (predicate is IndexQuery.ExistsPredicate)
            {
                LoadAll();
                BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(cursor, _descriptor.schema().PropertyIds);
                cursor.Initialize(_descriptor, multiProgressor, predicates, indexOrder, needsValues);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (NativeIndexReader<?,NativeIndexValue> reader : this)
                foreach (NativeIndexReader <object, NativeIndexValue> reader in this)
                {
                    reader.Query(multiProgressor, indexOrder, needsValues, predicates);
                }
            }
            else
            {
                if (ValidPredicate(predicate))
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: NativeIndexReader<?,NativeIndexValue> part = uncheckedSelect(predicate.valueGroup());
                    NativeIndexReader <object, NativeIndexValue> part = UncheckedSelect(predicate.ValueGroup());
                    if (part != null)
                    {
                        part.Query(cursor, indexOrder, needsValues, predicates);
                    }
                    else
                    {
                        cursor.Initialize(_descriptor, IndexProgressor.EMPTY, predicates, indexOrder, needsValues);
                    }
                }
                else
                {
                    cursor.Initialize(_descriptor, IndexProgressor.EMPTY, predicates, indexOrder, needsValues);
                }
            }
        }
 public override void Query(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient client, IndexOrder indexOrder, bool needsValues, params IndexQuery[] query)
 {
     IndexQuery.GeometryRangePredicate geometryRangePredicate = GetGeometryRangePredicateIfAny(query);
     if (geometryRangePredicate != null)
     {
         ValidateQuery(indexOrder, query);
         try
         {
             // If there's a GeometryRangeQuery among the predicates then this query changes from a straight-forward: build from/to and seek...
             // into a query that is split into multiple sub-queries. Predicates both before and after will have to be accompanied each sub-query.
             BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(client, Descriptor.schema().PropertyIds);
             client.Initialize(Descriptor, multiProgressor, query, indexOrder, needsValues);
             double[] from = geometryRangePredicate.From() == null ? null : geometryRangePredicate.From().coordinate();
             double[] to   = geometryRangePredicate.To() == null ? null : geometryRangePredicate.To().coordinate();
             CoordinateReferenceSystem           crs    = geometryRangePredicate.Crs();
             SpaceFillingCurve                   curve  = _spaceFillingCurveSettings.forCrs(crs, false);
             IList <SpaceFillingCurve.LongRange> ranges = curve.GetTilesIntersectingEnvelope(from, to, _configuration);
             foreach (SpaceFillingCurve.LongRange range in ranges)
             {
                 // Here's a sub-query that we'll have to do for this geometry range. Build this query from all predicates
                 // and when getting to the geometry range predicate that sparked these sub-query chenanigans, swap in this sub-query in its place.
                 GenericKey treeKeyFrom = Layout.newKey();
                 GenericKey treeKeyTo   = Layout.newKey();
                 InitializeFromToKeys(treeKeyFrom, treeKeyTo);
                 bool needFiltering = InitializeRangeForGeometrySubQuery(treeKeyFrom, treeKeyTo, query, crs, range);
                 StartSeekForInitializedRange(multiProgressor, treeKeyFrom, treeKeyTo, query, indexOrder, needFiltering, needsValues);
             }
         }
         catch (System.ArgumentException)
         {
             // Invalid query ranges will cause this state (eg. min>max)
             client.Initialize(Descriptor, IndexProgressor.EMPTY, query, indexOrder, needsValues);
         }
     }
     else
     {
         base.Query(client, indexOrder, needsValues, query);
     }
 }
Beispiel #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void query(org.neo4j.storageengine.api.schema.IndexProgressor_NodeValueClient cursor, org.neo4j.internal.kernel.api.IndexOrder indexOrder, boolean needsValues, org.neo4j.internal.kernel.api.IndexQuery... predicates) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException
        public override void Query(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient cursor, IndexOrder indexOrder, bool needsValues, params IndexQuery[] predicates)
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IndexSlot slot = SlotSelector.selectSlot(predicates, IndexQuery::valueGroup);

            if (slot != null)
            {
                InstanceSelector.select(slot).query(cursor, indexOrder, needsValues, predicates);
            }
            else
            {
                if (indexOrder != IndexOrder.NONE)
                {
                    throw new System.NotSupportedException(format("Tried to query index with unsupported order %s. Supported orders for query %s are %s.", indexOrder, Arrays.ToString(predicates), IndexOrder.NONE));
                }
                BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(cursor, _descriptor.schema().PropertyIds);
                cursor.Initialize(_descriptor, multiProgressor, predicates, indexOrder, needsValues);
                try
                {
                    InstanceSelector.forAll(reader =>
                    {
                        try
                        {
                            reader.query(multiProgressor, indexOrder, needsValues, predicates);
                        }
                        catch (IndexNotApplicableKernelException e)
                        {
                            throw new InnerException(e);
                        }
                    });
                }
                catch (InnerException e)
                {
                    throw e.InnerException;
                }
            }
        }