Example #1
0
        internal static AddedWithValuesAndRemoved IndexUpdatesWithValuesForRangeSeekByPrefix(ReadableTransactionState txState, IndexDescriptor descriptor, TextValue prefix, IndexOrder indexOrder)
        {
//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 floor = ValueTuple.of(prefix);

            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: for (java.util.Map.Entry<org.neo4j.values.storable.ValueTuple,? extends org.neo4j.storageengine.api.txstate.LongDiffSets> entry : sortedUpdates.tailMap(floor).entrySet())
            foreach (KeyValuePair <ValueTuple, ? extends LongDiffSets> entry in sortedUpdates.tailMap(floor).entrySet())
            {
                ValueTuple key = entry.Key;
                if ((( TextValue )key.OnlyValue).startsWith(prefix))
                {
                    LongDiffSets diffSets = entry.Value;
                    Value[]      values   = key.Values;
                    diffSets.Added.each(nodeId => added.add(new NodeWithPropertyValues(nodeId, values)));
                    removed.addAll(diffSets.Removed);
                }
                else
                {
                    break;
                }
            }
            return(new AddedWithValuesAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed));
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testExactMatchOnRandomCompositeValues() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void TestExactMatchOnRandomCompositeValues()
            {
                // given
                ValueType[] types = RandomSetOfSupportedTypes();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<IndexEntryUpdate<?>> updates = new java.util.ArrayList<>();
                IList <IndexEntryUpdate <object> > updates = new List <IndexEntryUpdate <object> >();
                ISet <ValueTuple> duplicateChecker         = new HashSet <ValueTuple>();

                for (long id = 0; id < 30_000; id++)
                {
                    IndexEntryUpdate <SchemaDescriptor> update;
                    do
                    {
                        update = IndexQueryHelper.Add(id, Descriptor.schema(), Random.randomValues().nextValueOfTypes(types), Random.randomValues().nextValueOfTypes(types), Random.randomValues().nextValueOfTypes(types), Random.randomValues().nextValueOfTypes(types));
                    } while (!duplicateChecker.Add(ValueTuple.of(update.Values())));
                    updates.Add(update);
                }
                UpdateAndCommit(updates);

                // when
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (IndexEntryUpdate<?> update : updates)
                foreach (IndexEntryUpdate <object> update in updates)
                {
                    // then
                    IList <long> hits = Query(exact(100, update.Values()[0]), exact(101, update.Values()[1]), exact(102, update.Values()[2]), exact(103, update.Values()[3]));
                    assertEquals(update + " " + hits.ToString(), 1, hits.Count);
                    assertThat(single(hits), equalTo(update.EntityId));
                }
            }
Example #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void process(org.neo4j.kernel.api.index.IndexEntryUpdate<?> update) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void Process <T1>(IndexEntryUpdate <T1> update)
        {
            _actual.process(update);
            if (update.UpdateMode() != REMOVED)
            {
                _touchedTuples.Add(ValueTuple.of(update.Values()));
            }
        }
Example #4
0
            internal virtual ValueTuple GenerateUniqueRandomValue(ValueType[] types, ISet <ValueTuple> duplicateChecker)
            {
                ValueTuple value;

                do
                {
                    value = ValueTuple.of(Random.randomValues().nextBooleanValue(), Random.randomValues().nextValueOfTypes(types));
                } while (!duplicateChecker.Add(value));
                return(value);
            }
Example #5
0
            /// <summary>
            /// All entries in composite index look like (booleanValue, randomValue ).
            /// Range queries in composite only work if all predicates before it is exact.
            /// We use boolean values for exact part so that we get some real ranges to work
            /// on in second composite slot where the random values are.
            /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testRangeMatchOnRandomValues() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void TestRangeMatchOnRandomValues()
            {
                Assume.assumeTrue("Assume support for granular composite queries", TestSuite.supportsGranularCompositeQueries());
                // given
                ValueType[]            types        = RandomSetOfSupportedAndSortableTypes();
                ISet <ValueTuple>      uniqueValues = new HashSet <ValueTuple>();
                SortedSet <ValueAndId> sortedValues = new SortedSet <ValueAndId>((v1, v2) => ValueTuple.COMPARATOR.Compare(v1.value, v2.value));
                MutableLong            nextId       = new MutableLong();

                for (int i = 0; i < 5; i++)
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<IndexEntryUpdate<?>> updates = new java.util.ArrayList<>();
                    IList <IndexEntryUpdate <object> > updates = new List <IndexEntryUpdate <object> >();
                    if (i == 0)
                    {
                        // The initial batch of data can simply be additions
                        updates = GenerateUpdatesFromValues(GenerateValuesFromType(types, uniqueValues, 20_000), nextId);
                        sortedValues.addAll(updates.Select(u => new ValueAndId(ValueTuple.of(u.values()), u.EntityId)).ToList());
                    }
                    else
                    {
                        // Then do all sorts of updates
                        for (int j = 0; j < 1_000; j++)
                        {
                            int type = Random.intBetween(0, 2);
                            if (type == 0)
                            {                                             // add
                                ValueTuple value = GenerateUniqueRandomValue(types, uniqueValues);
                                long       id    = nextId.AndIncrement;
                                sortedValues.Add(new ValueAndId(value, id));
                                updates.Add(IndexEntryUpdate.Add(id, Descriptor.schema(), value.Values));
                            }
                            else if (type == 1)
                            {                                             // update
                                ValueAndId existing = Random.among(sortedValues.toArray(new ValueAndId[0]));
                                sortedValues.remove(existing);
                                ValueTuple newValue = GenerateUniqueRandomValue(types, uniqueValues);
                                uniqueValues.remove(existing.Value);
                                sortedValues.Add(new ValueAndId(newValue, existing.Id));
                                updates.Add(IndexEntryUpdate.Change(existing.Id, Descriptor.schema(), existing.Value.Values, newValue.Values));
                            }
                            else
                            {                                             // remove
                                ValueAndId existing = Random.among(sortedValues.toArray(new ValueAndId[0]));
                                sortedValues.remove(existing);
                                uniqueValues.remove(existing.Value);
                                updates.Add(IndexEntryUpdate.Remove(existing.Id, Descriptor.schema(), existing.Value.Values));
                            }
                        }
                    }
                    UpdateAndCommit(updates);
                    VerifyRandomRanges(types, sortedValues);
                }
            }
Example #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void checkForDuplicate(org.neo4j.values.storable.Value[] values, long nodeId) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
            public override void CheckForDuplicate(Value[] values, long nodeId)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.values.storable.ValueTuple key = org.neo4j.values.storable.ValueTuple.of(values);
                ValueTuple key = ValueTuple.of(values);

                if (ValueNodeIdMap.containsKey(key))
                {
                    throw new IndexEntryConflictException(ValueNodeIdMap.get(key), nodeId, key);
                }
                ValueNodeIdMap.put(key, nodeId);
            }
Example #7
0
            internal virtual TxStateBuilder WithRemoved(long id, params object[] value)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.values.storable.ValueTuple valueTuple = org.neo4j.values.storable.ValueTuple.of((Object[]) value);
                ValueTuple valueTuple = ValueTuple.of(( object[] )value);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.util.diffsets.MutableLongDiffSetsImpl changes = updates.computeIfAbsent(valueTuple, ignore -> new org.neo4j.kernel.impl.util.diffsets.MutableLongDiffSetsImpl(org.neo4j.kernel.impl.util.collection.OnHeapCollectionsFactory.INSTANCE));
                MutableLongDiffSetsImpl changes = Updates.computeIfAbsent(valueTuple, ignore => new MutableLongDiffSetsImpl(OnHeapCollectionsFactory.INSTANCE));

                changes.Remove(id);
                return(this);
            }
Example #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldComputeIndexUpdatesForSeekWhenThereAreNewNodes()
        internal virtual void ShouldComputeIndexUpdatesForSeekWhenThereAreNewNodes()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = new TxStateBuilder().withAdded(42L, "foo").withAdded(43L, "bar").build();
            ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, "foo").withAdded(43L, "bar").build();

            // WHEN
            AddedAndRemoved changes = indexUpdatesForSeek(state, _index, ValueTuple.of("bar"));

            // THEN
            AssertContains(changes.Added, 43L);
        }
Example #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void stressIt() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void StressIt()
        {
            Race race = new Race();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.atomic.AtomicReferenceArray<java.util.List<? extends org.neo4j.kernel.api.index.IndexEntryUpdate<?>>> lastBatches = new java.util.concurrent.atomic.AtomicReferenceArray<>(THREADS);
            AtomicReferenceArray <IList <IndexEntryUpdate <object> > > lastBatches = new AtomicReferenceArray <IList <IndexEntryUpdate <object> > >(THREADS);

            Generator[] generators = new Generator[THREADS];

            _populator.create();
            System.Threading.CountdownEvent insertersDone = new System.Threading.CountdownEvent(THREADS);
            ReadWriteLock updateLock = new ReentrantReadWriteLock(true);

            for (int i = 0; i < THREADS; i++)
            {
                race.AddContestant(Inserter(lastBatches, generators, insertersDone, updateLock, i), 1);
            }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Collection<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = new java.util.ArrayList<>();
            ICollection <IndexEntryUpdate <object> > updates = new List <IndexEntryUpdate <object> >();

            race.AddContestant(Updater(lastBatches, insertersDone, updateLock, updates));

            race.Go();
            _populator.close(true);
            _populator = null;               // to let the after-method know that we've closed it ourselves

            // then assert that a tree built by a single thread ends up exactly the same
            BuildReferencePopulatorSingleThreaded(generators, updates);
            using (IndexAccessor accessor = _indexProvider.getOnlineAccessor(Descriptor, _samplingConfig), IndexAccessor referenceAccessor = _indexProvider.getOnlineAccessor(_descriptor2, _samplingConfig), IndexReader reader = accessor.NewReader(), IndexReader referenceReader = referenceAccessor.NewReader())
            {
                SimpleNodeValueClient entries          = new SimpleNodeValueClient();
                SimpleNodeValueClient referenceEntries = new SimpleNodeValueClient();
                reader.Query(entries, IndexOrder.NONE, HasValues, IndexQuery.exists(0));
                referenceReader.Query(referenceEntries, IndexOrder.NONE, HasValues, IndexQuery.exists(0));
                while (referenceEntries.Next())
                {
                    assertTrue(entries.Next());
                    assertEquals(referenceEntries.Reference, entries.Reference);
                    if (HasValues)
                    {
                        assertEquals(ValueTuple.of(referenceEntries.Values), ValueTuple.of(entries.Values));
                    }
                }
                assertFalse(entries.Next());
            }
        }
Example #10
0
        internal virtual void OnPropertyChange(NodeCursor node, PropertyCursor propertyCursor, long[] labels, int propertyKeyId, int[] existingPropertyKeyIds, Value beforeValue, Value afterValue)
        {
            Debug.Assert(NoSchemaChangedInTx());
            ICollection <SchemaDescriptor> indexes = _indexingService.getRelatedIndexes(labels, propertyKeyId, NODE);

            if (indexes.Count > 0)
            {
                MutableIntObjectMap <Value> materializedProperties = IntObjectMaps.mutable.empty();
                NodeSchemaMatcher.OnMatchingSchema(indexes.GetEnumerator(), propertyKeyId, existingPropertyKeyIds, index =>
                {
                    int[] propertyIds   = index.PropertyIds;
                    Value[] valuesAfter = GetValueTuple(node, propertyCursor, propertyKeyId, afterValue, propertyIds, materializedProperties);

                    // The valuesBefore tuple is just like valuesAfter, except is has the afterValue instead of the beforeValue
                    Value[] valuesBefore = valuesAfter.Clone();
                    int k           = ArrayUtils.IndexOf(propertyIds, propertyKeyId);
                    valuesBefore[k] = beforeValue;

                    _indexingService.validateBeforeCommit(index, valuesAfter);
                    _read.txState().indexDoUpdateEntry(index, node.NodeReference(), ValueTuple.of(valuesBefore), ValueTuple.of(valuesAfter));
                });
            }
        }
            /// <summary>
            /// This is also checked by the UniqueConstraintCompatibility test, only not on this abstraction level.
            /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldProvidePopulatorThatEnforcesUniqueConstraints() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void ShouldProvidePopulatorThatEnforcesUniqueConstraints()
            {
                // when
                Value value   = Values.of("value1");
                int   nodeId1 = 1;
                int   nodeId2 = 2;

                WithPopulator(IndexProvider.getPopulator(Descriptor, IndexSamplingConfig, heapBufferFactory(1024)), p =>
                {
                    try
                    {
                        p.add(Arrays.asList(add(nodeId1, Descriptor.schema(), value), add(nodeId2, Descriptor.schema(), value)));
                        TestNodePropertyAccessor propertyAccessor = new TestNodePropertyAccessor(nodeId1, Descriptor.schema(), value);
                        propertyAccessor.AddNode(nodeId2, Descriptor.schema(), value);
                        p.scanCompleted(PhaseTracker.nullInstance);
                        p.verifyDeferredConstraints(propertyAccessor);

                        fail("expected exception");
                    }
                    // then
                    catch (Exception e)
                    {
                        Exception root = Exceptions.rootCause(e);
                        if (root is IndexEntryConflictException)
                        {
                            IndexEntryConflictException conflict = ( IndexEntryConflictException )root;
                            assertEquals(nodeId1, conflict.ExistingNodeId);
                            assertEquals(ValueTuple.of(value), conflict.PropertyValues);
                            assertEquals(nodeId2, conflict.AddedNodeId);
                        }
                        else
                        {
                            throw e;
                        }
                    }
                }, false);
            }
        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);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGetAllDoublePropertyValues() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldGetAllDoublePropertyValues()
        {
            int            label = Token.nodeLabel("Node");
            int            prop  = Token.propertyKey("prop");
            int            prip  = Token.propertyKey("prip");
            IndexReference index = SchemaRead.index(label, prop, prip);

            using (NodeValueIndexCursor node = Cursors.allocateNodeValueIndexCursor())
            {
                Read.nodeIndexScan(index, node, IndexOrder.NONE, true);

                IList <ValueTuple> values = new List <ValueTuple>();
                while (node.Next())
                {
                    values.Add(ValueTuple.of(node.PropertyValue(0), node.PropertyValue(1)));
                }

                values.sort(ValueTuple.COMPARATOR);
                for (int i = 0; i < _doublePropValues.Count; i++)
                {
                    assertEquals(_doublePropValues[i], values[i]);
                }
            }
        }
Example #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSeekWhenThereAreNewNumberNodes()
            internal virtual void ShouldSeekWhenThereAreNewNumberNodes()
            {
                // GIVEN
                ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, 42001.0, 42002.0).withAdded(43L, 43001.0, 43002.0).build();

                // WHEN
                AddedAndRemoved changes = indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of(43001.0, 43002.0));

                // THEN
                outerInstance.AssertContains(changes.Added, 43L);
            }
Example #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSeekOnAnEmptyTxState()
            internal virtual void ShouldSeekOnAnEmptyTxState()
            {
                // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = org.mockito.Mockito.mock(org.neo4j.storageengine.api.txstate.ReadableTransactionState.class);
                ReadableTransactionState state = Mockito.mock(typeof(ReadableTransactionState));

                // WHEN
                AddedAndRemoved changes = indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of("43value1", "43value2"));

                // THEN
                assertTrue(changes.Empty);
            }
Example #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void duplicateFoundAmongUniqueStringSingleProperty() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DuplicateFoundAmongUniqueStringSingleProperty()
        {
            for (int i = 0; i < RandomNumberOfEntries(); i++)
            {
                string    propertyValue = i.ToString();
                TextValue stringValue   = Values.stringValue(propertyValue);
                _checkStrategy.checkForDuplicate(stringValue, i);
            }

            int       duplicateTarget = BUCKET_STRATEGY_ENTRIES_THRESHOLD - 2;
            string    duplicate       = duplicateTarget.ToString();
            TextValue duplicatedValue = Values.stringValue(duplicate);

            ExpectedException.expect(typeof(IndexEntryConflictException));
            ExpectedException.expectMessage(format("Both node %d and node 3 share the property value %s", duplicateTarget, ValueTuple.of(duplicatedValue)));
            _checkStrategy.checkForDuplicate(duplicatedValue, 3);
        }
Example #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void duplicateFoundAmongUniqueNumberSingleProperty() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DuplicateFoundAmongUniqueNumberSingleProperty()
        {
            double propertyValue = 0;

            for (int i = 0; i < RandomNumberOfEntries(); i++)
            {
                Value doubleValue = Values.doubleValue(propertyValue);
                _checkStrategy.checkForDuplicate(doubleValue, i);
                propertyValue += 1;
            }

            int    duplicateTarget = BUCKET_STRATEGY_ENTRIES_THRESHOLD - 8;
            double duplicateValue  = duplicateTarget;
            Value  duplicate       = Values.doubleValue(duplicateValue);

            ExpectedException.expect(typeof(IndexEntryConflictException));
            ExpectedException.expectMessage(format("Both node %d and node 3 share the property value %s", duplicateTarget, ValueTuple.of(duplicate)));
            _checkStrategy.checkForDuplicate(duplicate, 3);
        }
Example #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void checkNumericSinglePropertyDuplicates() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CheckNumericSinglePropertyDuplicates()
        {
            double duplicatedNumber = 0.33d;
            Value  property         = Values.doubleValue(duplicatedNumber);

            ExpectedException.expect(typeof(IndexEntryConflictException));
            ExpectedException.expectMessage(format("Both node 3 and node 4 share the property value %s", ValueTuple.of(property)));

            _checkStrategy.checkForDuplicate(property, 3);
            _checkStrategy.checkForDuplicate(property, 4);
        }
Example #19
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));
        }
Example #20
0
        // multiple

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void checkStringMultiplePropertiesDuplicates() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CheckStringMultiplePropertiesDuplicates()
        {
            string duplicateA = "duplicateA";
            string duplicateB = "duplicateB";
            Value  propertyA  = Values.stringValue(duplicateA);
            Value  propertyB  = Values.stringValue(duplicateB);

            ExpectedException.expect(typeof(IndexEntryConflictException));
            ExpectedException.expectMessage(format("Both node 1 and node 2 share the property value %s", ValueTuple.of(duplicateA, duplicateB)));

            _checkStrategy.checkForDuplicate(new Value[] { propertyA, propertyB }, 1);
            _checkStrategy.checkForDuplicate(new Value[] { propertyA, propertyB }, 2);
        }
Example #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void checkNumericMultiplePropertiesDuplicates() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CheckNumericMultiplePropertiesDuplicates()
        {
            Number duplicatedNumberA = 0.33d;
            Number duplicatedNumberB = 2;
            Value  propertyA         = Values.doubleValue(duplicatedNumberA.doubleValue());
            Value  propertyB         = Values.intValue(duplicatedNumberB.intValue());

            ExpectedException.expect(typeof(IndexEntryConflictException));
            ExpectedException.expectMessage(format("Both node 3 and node 4 share the property value %s", ValueTuple.of(propertyA, propertyB)));

            _checkStrategy.checkForDuplicate(new Value[] { propertyA, propertyB }, 3);
            _checkStrategy.checkForDuplicate(new Value[] { propertyA, propertyB }, 4);
        }
 public IndexEntryConflictException(long existingNodeId, long addedNodeId, params Value[] propertyValue) : this(existingNodeId, addedNodeId, ValueTuple.of(propertyValue))
 {
 }
Example #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void duplicateFoundAmongUniqueStringMultipleProperties() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DuplicateFoundAmongUniqueStringMultipleProperties()
        {
            for (int i = 0; i < RandomNumberOfEntries(); i++)
            {
                string propertyValueA = i.ToString();
                string propertyValueB = (-i).ToString();
                Value  propertyA      = Values.stringValue(propertyValueA);
                Value  propertyB      = Values.stringValue(propertyValueB);
                _checkStrategy.checkForDuplicate(new Value[] { propertyA, propertyB }, i);
            }

            int    duplicateTarget  = BUCKET_STRATEGY_ENTRIES_THRESHOLD - 2;
            string duplicatedValueA = duplicateTarget.ToString();
            string duplicatedValueB = (-duplicateTarget).ToString();
            Value  propertyA        = Values.stringValue(duplicatedValueA);
            Value  propertyB        = Values.stringValue(duplicatedValueB);

            ExpectedException.expect(typeof(IndexEntryConflictException));
            ExpectedException.expectMessage(format("Both node %d and node 3 share the property value %s", duplicateTarget, ValueTuple.of(propertyA, propertyB)));
            _checkStrategy.checkForDuplicate(new Value[] { propertyA, propertyB }, 3);
        }
Example #24
0
 public virtual IList <long> ExpectedIds(SortedSet <ValueAndId> sortedValues, Value booleanValue, Value from, Value to, bool fromInclusive, bool toInclusive)
 {
     return(sortedValues.subSet(new ValueAndId(ValueTuple.of(booleanValue, from), 0), fromInclusive, new ValueAndId(ValueTuple.of(booleanValue, to), 0), toInclusive).Select(v => v.id).OrderBy(long?.compare).ToList());
 }
Example #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void duplicateFoundAmongUniqueNumberMultipleProperties() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DuplicateFoundAmongUniqueNumberMultipleProperties()
        {
            double propertyValue = 0;

            for (int i = 0; i < RandomNumberOfEntries(); i++)
            {
                double propertyValueA = propertyValue;
                double propertyValueB = -propertyValue;
                Value  propertyA      = Values.doubleValue(propertyValueA);
                Value  propertyB      = Values.doubleValue(propertyValueB);
                _checkStrategy.checkForDuplicate(new Value[] { propertyA, propertyB }, i);
                propertyValue += 1;
            }

            int    duplicateTarget = BUCKET_STRATEGY_ENTRIES_THRESHOLD - 8;
            double duplicateValueA = duplicateTarget;
            double duplicateValueB = -duplicateTarget;
            Value  propertyA       = Values.doubleValue(duplicateValueA);
            Value  propertyB       = Values.doubleValue(duplicateValueB);

            ExpectedException.expect(typeof(IndexEntryConflictException));
            ExpectedException.expectMessage(format("Both node %d and node 3 share the property value %s", duplicateTarget, ValueTuple.of(duplicateValueA, duplicateValueB)));
            _checkStrategy.checkForDuplicate(new Value[] { propertyA, propertyB }, 3);
        }
Example #26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSeekWhenThereAreManyEntriesWithTheSameValues()
            internal virtual void ShouldSeekWhenThereAreManyEntriesWithTheSameValues()
            {
                // GIVEN (note that 44 has the same properties as 43)
                ReadableTransactionState state = (new TxStateBuilder()).WithAdded(42L, "42value1", "42value2").withAdded(43L, "43value1", "43value2").withAdded(44L, "43value1", "43value2").build();

                // WHEN
                AddedAndRemoved changes = indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of("43value1", "43value2"));

                // THEN
                outerInstance.AssertContains(changes.Added, 43L, 44L);
            }
Example #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSeekInComplexMix()
            internal virtual void ShouldSeekInComplexMix()
            {
                // GIVEN
                ReadableTransactionState state = (new TxStateBuilder()).WithAdded(10L, "hi", 3).withAdded(11L, 9L, 33L).withAdded(12L, "sneaker", false).withAdded(13L, new int[] { 10, 100 }, "array-buddy").withAdded(14L, 40.1, 40.2).build();

                // THEN
                outerInstance.AssertContains(indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of("hi", 3)).Added, 10L);
                outerInstance.AssertContains(indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of(9L, 33L)).Added, 11L);
                outerInstance.AssertContains(indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of("sneaker", false)).Added, 12L);
                outerInstance.AssertContains(indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of(new int[] { 10, 100 }, "array-buddy")).Added, 13L);
                outerInstance.AssertContains(indexUpdatesForSeek(state, CompositeIndexConflict, ValueTuple.of(40.1, 40.2)).Added, 14L);
            }
Example #28
0
        private void AssertThatItWorksOneWay(IList <NodeWithPropertyValues> listA, IList <NodeWithPropertyValues> listB)
        {
            SortedMergeJoin sortedMergeJoin = new SortedMergeJoin();

            sortedMergeJoin.Initialize(IndexOrder);

            IComparer <NodeWithPropertyValues> comparator = IndexOrder == IndexOrder.ASCENDING ? (a, b) => ValueTuple.COMPARATOR.Compare(ValueTuple.of(a.Values), ValueTuple.of(b.Values)) : (a, b) => ValueTuple.COMPARATOR.Compare(ValueTuple.of(b.Values), ValueTuple.of(a.Values));

            listA.sort(comparator);
            listB.sort(comparator);

            IList <NodeWithPropertyValues> result = Process(sortedMergeJoin, listA.GetEnumerator(), listB.GetEnumerator());

            IList <NodeWithPropertyValues> expected = new List <NodeWithPropertyValues>();

            ((IList <NodeWithPropertyValues>)expected).AddRange(listA);
            ((IList <NodeWithPropertyValues>)expected).AddRange(listB);
            expected.sort(comparator);

            assertThat(result, equalTo(expected));
        }
Example #29
0
 private ValueTuple Values(params object[] values)
 {
     return(ValueTuple.of(values));
 }
Example #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void checkStringSinglePropertyDuplicates() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CheckStringSinglePropertyDuplicates()
        {
            string duplicatedString = "duplicate";

            Value propertyValue = Values.stringValue(duplicatedString);

            ExpectedException.expect(typeof(IndexEntryConflictException));
            ExpectedException.expectMessage(format("Both node 1 and node 2 share the property value %s", ValueTuple.of(propertyValue)));

            _checkStrategy.checkForDuplicate(propertyValue, 1);
            _checkStrategy.checkForDuplicate(propertyValue, 2);
        }