Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void comparePointsMustOnlyReturnZeroForEqualPoints()
        internal virtual void ComparePointsMustOnlyReturnZeroForEqualPoints()
        {
            PointValue firstPoint             = _random.randomValues().nextPointValue();
            PointValue equalPoint             = Values.point(firstPoint);
            CoordinateReferenceSystem crs     = firstPoint.CoordinateReferenceSystem;
            SpaceFillingCurve         curve   = _noSpecificIndexSettings.forCrs(crs, false);
            long?      spaceFillingCurveValue = curve.DerivedValueFor(firstPoint.Coordinate());
            PointValue centerPoint            = Values.pointValue(crs, curve.CenterPointFor(spaceFillingCurveValue.Value));

            GenericKey firstKey = NewKeyState();

            firstKey.WriteValue(firstPoint, NEUTRAL);
            GenericKey equalKey = NewKeyState();

            equalKey.WriteValue(equalPoint, NEUTRAL);
            GenericKey centerKey = NewKeyState();

            centerKey.WriteValue(centerPoint, NEUTRAL);
            GenericKey noCoordsKey = NewKeyState();

            noCoordsKey.WriteValue(equalPoint, NEUTRAL);
            GeometryType.NoCoordinates = noCoordsKey;

            assertEquals(0, firstKey.CompareValueTo(equalKey), "expected keys to be equal");
            assertEquals(firstPoint.CompareTo(centerPoint) != 0, firstKey.CompareValueTo(centerKey) != 0, "expected keys to be equal if and only if source points are equal");
            assertEquals(0, firstKey.CompareValueTo(noCoordsKey), "expected keys to be equal");
        }
Exemplo n.º 2
0
        private void Remove(int count, ValuesMap actualMap, MutableLongObjectMap <Value> expectedMap)
        {
            for (int i = 0; i < count / 2; i++)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long key = rnd.nextLong(count);
                long key = _rnd.nextLong(count);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.values.storable.Value value = rnd.randomValues().nextValue();
                Value value = _rnd.randomValues().nextValue();
                actualMap.Put(key, value);
                expectedMap.put(key, value);
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void randomizedTest()
        internal virtual void RandomizedTest()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int count = 10000 + rnd.nextInt(1000);
            int count = 10000 + _rnd.Next(1000);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<org.eclipse.collections.api.tuple.primitive.ObjectLongPair<org.neo4j.values.storable.Value>> valueRefPairs = new java.util.ArrayList<>();
            IList <ObjectLongPair <Value> > valueRefPairs = new List <ObjectLongPair <Value> >();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.list.MutableList<org.eclipse.collections.api.tuple.primitive.ObjectLongPair<org.neo4j.values.storable.Value>> toRemove = new org.eclipse.collections.impl.list.mutable.FastList<>();
            MutableList <ObjectLongPair <Value> > toRemove = new FastList <ObjectLongPair <Value> >();

            for (int i = 0; i < count; i++)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.values.storable.Value value = rnd.randomValues().nextValue();
                Value value = _rnd.randomValues().nextValue();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long ref = container.add(value);
                long @ref = _container.add(value);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.tuple.primitive.ObjectLongPair<org.neo4j.values.storable.Value> pair = pair(value, ref);
                ObjectLongPair <Value> pair = pair(value, @ref);
                if (_rnd.nextBoolean())
                {
                    toRemove.add(pair);
                }
                else
                {
                    valueRefPairs.Add(pair);
                }
            }

            toRemove.shuffleThis(_rnd.random());
            foreach (ObjectLongPair <Value> valueRefPair in toRemove)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.values.storable.Value removed = container.remove(valueRefPair.getTwo());
                Value removed = _container.remove(valueRefPair.Two);
                assertEquals(valueRefPair.One, removed);
                assertThrows(typeof(System.ArgumentException), () => _container.remove(valueRefPair.Two));
                assertThrows(typeof(System.ArgumentException), () => _container.get(valueRefPair.Two));
            }

            foreach (ObjectLongPair <Value> valueRefPair in valueRefPairs)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.values.storable.Value actualValue = container.get(valueRefPair.getTwo());
                Value actualValue = _container.get(valueRefPair.Two);
                assertEquals(valueRefPair.One, actualValue);
            }
        }
Exemplo n.º 4
0
        private GenericKey RandomKey(int entityId)
        {
            GenericKey key = _layout.newKey();

            key.Initialize(entityId);
            for (int i = 0; i < _numberOfSlots; i++)
            {
                Value value = Random.randomValues().nextValue();
                key.InitFromValue(i, value, NEUTRAL);
            }
            return(key);
        }
Exemplo n.º 5
0
        /// <summary>
        /// This test verify that the documented formula for calculating size limit for string array
        /// actually calculate correctly.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testDocumentedStringArrayKeySizeFormulaIsCorrect()
        internal virtual void TestDocumentedStringArrayKeySizeFormulaIsCorrect()
        {
            CompositeGenericKey key = new CompositeGenericKey(1, mock(typeof(IndexSpecificSpaceFillingCurveSettingsCache)));
            int maxArrayLength      = Random.Next(500);
            int maxStringLength     = Random.Next(100);

            for (int i = 0; i < 100; i++)
            {
                string[] strings = Random.randomValues().nextStringArrayRaw(0, maxArrayLength, 0, maxStringLength);
                key.initialize(i);
                key.WriteValue(0, Values.of(strings), NativeIndexKey.Inclusion.Neutral);
                assertThat(IncludingEntityId(CalculateKeySize(strings)), equalTo(key.Size()));
            }
        }
        public override void CreateTestGraph(GraphDatabaseService graphDb)
        {
            using (Transaction tx = graphDb.BeginTx())
            {
                graphDb.Schema().indexFor(label("Node")).on("prop").create();
                graphDb.Schema().indexFor(label("Node")).on("prop").on("prip").create();
                tx.Success();
            }
            using (Transaction tx = graphDb.BeginTx())
            {
                graphDb.Schema().awaitIndexesOnline(5, MINUTES);
                tx.Success();
            }

            using (Transaction tx = graphDb.BeginTx())
            {
                RandomValues randomValues = RandomRule.randomValues();

                ValueType[] allExceptNonSortable = RandomValues.excluding(ValueType.STRING, ValueType.STRING_ARRAY);

                for (int i = 0; i < _nNodes; i++)
                {
                    Node  node      = graphDb.CreateNode(label("Node"));
                    Value propValue = randomValues.NextValueOfTypes(allExceptNonSortable);
                    node.SetProperty("prop", propValue.AsObject());
                    Value pripValue = randomValues.NextValue();
                    node.SetProperty("prip", pripValue.AsObject());

                    _singlePropValues.Add(propValue);
                    _doublePropValues.Add(ValueTuple.of(propValue, pripValue));
                }
                tx.Success();
            }

            _singlePropValues.sort(Values.COMPARATOR);
            _doublePropValues.sort(ValueTuple.COMPARATOR);
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            _generators = new LimitedRecordGenerators(_random.randomValues(), _entityBits, _propertyBits, 40, 16, -1);
        }