//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));
                }
            }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustSelectNumberForRangeNumericPredicate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustSelectNumberForRangeNumericPredicate()
        {
            // given
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.internal.kernel.api.IndexQuery.RangePredicate<?> numberRange = org.neo4j.internal.kernel.api.IndexQuery.range(PROP_KEY, 0, true, 1, false);
            IndexQuery.RangePredicate <object> numberRange = IndexQuery.range(PROP_KEY, 0, true, 1, false);

            // then
            VerifyQueryWithCorrectReader(ExpectedForNumbers(), numberRange);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustSelectStringForRangeStringPredicate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustSelectStringForRangeStringPredicate()
        {
            // given
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.internal.kernel.api.IndexQuery.RangePredicate<?> stringRange = org.neo4j.internal.kernel.api.IndexQuery.range(PROP_KEY, "abc", true, "def", false);
            IndexQuery.RangePredicate <object> stringRange = IndexQuery.range(PROP_KEY, "abc", true, "def", false);

            // then
            VerifyQueryWithCorrectReader(ExpectedForStrings(), stringRange);
        }
Ejemplo n.º 4
0
        private DynamicTest RangeTest(ReadableTransactionState state, IndexOrder indexOrder, Value lo, bool includeLo, Value hi, bool includeHi, params NodeWithPropertyValues[] expected)
        {
            return(DynamicTest.dynamicTest(string.Format("range seek: lo={0} (incl: {1}), hi={2} (incl: {3})", lo, includeLo, hi, includeHi), () =>
            {
                // Internal production code relies on null for unbounded, and cannot cope with NO_VALUE in this case
                Debug.Assert(lo != NO_VALUE);
                Debug.Assert(hi != NO_VALUE);
                AddedAndRemoved changes = indexUpdatesForRangeSeek(state, _index, IndexQuery.range(-1, lo, includeLo, hi, includeHi), indexOrder);
                AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForRangeSeek(state, _index, IndexQuery.range(-1, lo, includeLo, hi, includeHi), indexOrder);

                AssertContains(indexOrder, changes, changesWithValues, expected);
            }));
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustSelectSpatialForRangeGeometricPredicate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustSelectSpatialForRangeGeometricPredicate()
        {
            // given
            assumeTrue(HasSpatialSupport());
            PointValue from = Values.pointValue(CoordinateReferenceSystem.Cartesian, 1.0, 1.0);
            PointValue to   = Values.pointValue(CoordinateReferenceSystem.Cartesian, 2.0, 2.0);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.internal.kernel.api.IndexQuery.RangePredicate<?> geometryRange = org.neo4j.internal.kernel.api.IndexQuery.range(PROP_KEY, from, true, to, false);
            IndexQuery.RangePredicate <object> geometryRange = IndexQuery.range(PROP_KEY, from, true, to, false);

            // then
            VerifyQueryWithCorrectReader(_readers[SPATIAL], geometryRange);
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rangeSeekByStringOverPartitions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RangeSeekByStringOverPartitions()
        {
            PartitionedIndexReader indexReader = CreatePartitionedReaderFromReaders();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.internal.kernel.api.IndexQuery.RangePredicate<?> query = org.neo4j.internal.kernel.api.IndexQuery.range(1, "a", false, "b", true);
            IndexQuery.RangePredicate <object> query = IndexQuery.range(1, "a", false, "b", true);
            when(_indexReader1.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 1));
            when(_indexReader2.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 2));
            when(_indexReader3.query(query)).thenReturn(PrimitiveLongResourceCollections.iterator(null, 3));

            LongSet results = PrimitiveLongCollections.asSet(indexReader.Query(query));

            VerifyResult(results);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldProvideResultInOrderIfCapable() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldProvideResultInOrderIfCapable()
        {
            int label = Token.nodeLabel("Node");
            int prop  = Token.propertyKey("prop");

            RandomValues   randomValues = RandomRule.randomValues();
            IndexReference index        = SchemaRead.index(label, prop);

            for (int i = 0; i < _nIterations; i++)
            {
                ValueType    type  = randomValues.Among(_targetedTypes);
                IndexOrder[] order = index.OrderCapability(type.valueGroup.category());
                foreach (IndexOrder indexOrder in order)
                {
                    if (indexOrder == IndexOrder.NONE)
                    {
                        continue;
                    }
                    NodeValueTuple from = new NodeValueTuple(this, long.MinValue, randomValues.NextValueOfType(type));
                    NodeValueTuple to   = new NodeValueTuple(this, long.MaxValue, randomValues.NextValueOfType(type));
                    if (COMPARATOR.compare(from, to) > 0)
                    {
                        NodeValueTuple tmp = from;
                        from = to;
                        to   = tmp;
                    }
                    bool fromInclusive = randomValues.NextBoolean();
                    bool toInclusive   = randomValues.NextBoolean();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.internal.kernel.api.IndexQuery.RangePredicate<?> range = org.neo4j.internal.kernel.api.IndexQuery.range(prop, from.getOnlyValue(), fromInclusive, to.getOnlyValue(), toInclusive);
                    IndexQuery.RangePredicate <object> range = IndexQuery.range(prop, from.OnlyValue, fromInclusive, to.OnlyValue, toInclusive);

                    using (NodeValueIndexCursor node = Cursors.allocateNodeValueIndexCursor())
                    {
                        Read.nodeIndexSeek(index, node, indexOrder, false, range);

                        IList <long> expectedIdsInOrder = expectedIdsInOrder(from, fromInclusive, to, toInclusive, indexOrder);
                        IList <long> actualIdsInOrder   = new List <long>();
                        while (node.Next())
                        {
                            actualIdsInOrder.Add(node.NodeReference());
                        }

                        assertEquals(expectedIdsInOrder, actualIdsInOrder, "actual node ids not in same order as expected");
                    }
                }
            }
        }
Ejemplo n.º 8
0
//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
            internal virtual void VerifyRandomRanges(ValueType[] types, SortedSet <ValueAndId> sortedValues)
            {
                for (int i = 0; i < 100; i++)
                {
                    Value     booleanValue = Random.randomValues().nextBooleanValue();
                    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();

                    // when
                    IList <long> expectedIds = expectedIds(sortedValues, booleanValue, from, to, fromInclusive, toInclusive);

                    // Depending on order capabilities we verify ids or order and ids.
                    IndexQuery[]    predicates      = new IndexQuery[] { IndexQuery.exact(100, booleanValue), IndexQuery.range(101, from, fromInclusive, to, toInclusive) };
                    ValueCategory[] valueCategories = GetValueCategories(predicates);
                    IndexOrder[]    indexOrders     = IndexProvider.getCapability(Descriptor).orderCapability(valueCategories);
                    foreach (IndexOrder order in indexOrders)
                    {
                        IList <long> actualIds = AssertInOrder(order, predicates);
                        actualIds.sort(long?.compare);
                        // then
                        assertThat(actualIds, equalTo(expectedIds));
                    }
                }
            }
Ejemplo n.º 9
0
 internal virtual IndexQuery RangeQuery(Value from, bool fromInclusive, Value to, bool toInclusive)
 {
     return(IndexQuery.range(0, from, fromInclusive, to, toInclusive));
 }