Ejemplo n.º 1
0
        private static void InitToForRange <T1>(int stateSlot, IndexQuery.RangePredicate <T1> rangePredicate, GenericKey treeKeyTo)
        {
            Value toValue = rangePredicate.ToValue();

            if (toValue == Values.NO_VALUE)
            {
                treeKeyTo.InitValueAsHighest(stateSlot, rangePredicate.ValueGroup());
            }
            else
            {
                treeKeyTo.InitFromValue(stateSlot, toValue, ToInclusion(rangePredicate));
                treeKeyTo.CompareId = true;
            }
        }
Ejemplo n.º 2
0
        private static void InitFromForRange <T1>(int stateSlot, IndexQuery.RangePredicate <T1> rangePredicate, GenericKey treeKeyFrom)
        {
            Value fromValue = rangePredicate.FromValue();

            if (fromValue == Values.NO_VALUE)
            {
                treeKeyFrom.InitValueAsLowest(stateSlot, rangePredicate.ValueGroup());
            }
            else
            {
                treeKeyFrom.InitFromValue(stateSlot, fromValue, FromInclusion(rangePredicate));
                treeKeyFrom.CompareId = true;
            }
        }
Ejemplo n.º 3
0
        internal static AddedWithValuesAndRemoved IndexUpdatesWithValuesForRangeSeek <T1>(ReadableTransactionState txState, IndexDescriptor descriptor, IndexQuery.RangePredicate <T1> predicate, IndexOrder indexOrder)
        {
            Value lower = predicate.FromValue();
            Value upper = predicate.ToValue();

            if (lower == null || upper == null)
            {
                throw new System.InvalidOperationException("Use Values.NO_VALUE to encode the lack of a bound");
            }

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.NavigableMap<org.neo4j.values.storable.ValueTuple, ? extends org.neo4j.storageengine.api.txstate.LongDiffSets> sortedUpdates = txState.getSortedIndexUpdates(descriptor.schema());
            NavigableMap <ValueTuple, ? extends LongDiffSets> sortedUpdates = txState.GetSortedIndexUpdates(descriptor.Schema());

            if (sortedUpdates == null)
            {
                return(_emptyAddedAndRemovedWithValues);
            }

            ValueTuple selectedLower;
            bool       selectedIncludeLower;

            ValueTuple selectedUpper;
            bool       selectedIncludeUpper;

            if (lower == NO_VALUE)
            {
                selectedLower        = ValueTuple.of(Values.minValue(predicate.ValueGroup(), upper));
                selectedIncludeLower = true;
            }
            else
            {
                selectedLower        = ValueTuple.of(lower);
                selectedIncludeLower = predicate.FromInclusive();
            }

            if (upper == NO_VALUE)
            {
                selectedUpper        = ValueTuple.of(Values.maxValue(predicate.ValueGroup(), lower));
                selectedIncludeUpper = false;
            }
            else
            {
                selectedUpper        = ValueTuple.of(upper);
                selectedIncludeUpper = predicate.ToInclusive();
            }

            MutableList <NodeWithPropertyValues> added = Lists.mutable.empty();
            MutableLongSet removed = LongSets.mutable.empty();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> inRange = sortedUpdates.subMap(selectedLower, selectedIncludeLower, selectedUpper, selectedIncludeUpper);
            IDictionary <ValueTuple, ? extends LongDiffSets> inRange = sortedUpdates.subMap(selectedLower, selectedIncludeLower, selectedUpper, selectedIncludeUpper);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.util.Map.Entry<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> entry : inRange.entrySet())
            foreach (KeyValuePair <ValueTuple, ? extends LongDiffSets> entry in inRange.SetOfKeyValuePairs())
            {
                ValueTuple   values               = entry.Key;
                Value[]      valuesArray          = values.Values;
                LongDiffSets diffForSpecificValue = entry.Value;

                // The TreeMap cannot perfectly order multi-dimensional types (spatial) and need additional filtering out false positives
                // TODO: If the composite index starts to be able to handle spatial types the line below needs enhancement
                if (predicate.RegularOrder || predicate.AcceptsValue(values.OnlyValue))
                {
                    diffForSpecificValue.Added.each(nodeId => added.add(new NodeWithPropertyValues(nodeId, valuesArray)));
                    removed.addAll(diffForSpecificValue.Removed);
                }
            }
            return(new AddedWithValuesAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed));
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void verifyRandomRanges(org.neo4j.values.storable.ValueType[] types, java.util.TreeSet<ValueAndId> sortedValues) throws Exception
        private void VerifyRandomRanges(ValueType[] types, SortedSet <ValueAndId> sortedValues)
        {
            for (int i = 0; i < 100; i++)
            {
                // Construct a random range query of random value type
                ValueType type = Random.among(types);
                Value     from = Random.randomValues().nextValueOfType(type);
                Value     to   = Random.randomValues().nextValueOfType(type);
                if (Values.COMPARATOR.Compare(from, to) > 0)
                {
                    Value tmp = from;
                    from = to;
                    to   = tmp;
                }
                bool fromInclusive = Random.nextBoolean();
                bool toInclusive   = Random.nextBoolean();

                // Expected result based on query
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.internal.kernel.api.IndexQuery.RangePredicate<?> predicate = org.neo4j.internal.kernel.api.IndexQuery.range(0, from, fromInclusive, to, toInclusive);
                IndexQuery.RangePredicate <object> predicate = IndexQuery.range(0, from, fromInclusive, to, toInclusive);
                IList <long> expectedIds = expectedIds(sortedValues, from, to, fromInclusive, toInclusive);

                // Depending on order capabilities we verify ids or order and ids.
                IndexOrder[] indexOrders = IndexProvider.getCapability(Descriptor).orderCapability(predicate.ValueGroup().category());
                foreach (IndexOrder order in indexOrders)
                {
                    IList <long> actualIds = AssertInOrder(order, predicate);
                    actualIds.sort(long?.compare);
                    // then
                    assertThat(actualIds, equalTo(expectedIds));
                }
            }
        }