Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updatesShouldEqualRegardlessOfCreationMethod()
        public virtual void UpdatesShouldEqualRegardlessOfCreationMethod()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> singleAdd = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> singleAdd = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);

            Value[] singleAsArray = new Value[] { _singleValue };
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multiAdd = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
            IndexEntryUpdate <object> multiAdd = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> singleRemove = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> singleRemove = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multiRemove = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
            IndexEntryUpdate <object> multiRemove = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> singleChange = IndexEntryUpdate.change(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue, singleValue);
            IndexEntryUpdate <object> singleChange = IndexEntryUpdate.Change(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue, _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multiChange = IndexEntryUpdate.change(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleAsArray, singleAsArray);
            IndexEntryUpdate <object> multiChange = IndexEntryUpdate.Change(0, SchemaDescriptorFactory.forLabel(3, 4), singleAsArray, singleAsArray);

            assertThat(singleAdd, equalTo(multiAdd));
            assertThat(singleRemove, equalTo(multiRemove));
            assertThat(singleChange, equalTo(multiChange));
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void removeShouldThrowIfAskedForChanged()
        public virtual void RemoveShouldThrowIfAskedForChanged()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> single = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> single = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);

            Thrown.expect(typeof(System.NotSupportedException));
            single.BeforeValues();
        }
Пример #3
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);
                }
            }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void removeShouldRetainValues()
        public virtual void RemoveShouldRetainValues()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> single = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> single = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multi = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4, 5), multiValue);
            IndexEntryUpdate <object> multi = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4, 5), _multiValue);

            assertThat(single, not(equalTo(multi)));
            assertThat(single.Values(), equalTo(new object[] { _singleValue }));
            assertThat(multi.Values(), equalTo(_multiValue));
        }
        /// <summary>
        /// This test target a bug around minimal splitter in gbpTree and unique index populator. It goes like this:
        /// Given a set of updates (value,entityId):
        /// - ("A01",1), ("A90",3), ("A9",2)
        /// If ("A01",1) and ("A90",3) would cause a split to occur they would produce a minimal splitter ("A9",3).
        /// Note that the value in this minimal splitter is equal to our last update ("A9",2).
        /// When making insertions with the unique populator we don't compare entityId which would means ("A9",2)
        /// ends up to the right of ("A9",3), even though it belongs to the left because of entityId being smaller.
        /// At this point the tree is in an inconsistent (key on wrong side of splitter).
        ///
        /// To work around this problem the entityId is only kept in minimal splitter if strictly necessary to divide
        /// left from right. This means the minimal splitter between ("A01",1) and ("A90",3) is ("A9",-1) and ("A9",2)
        /// will correctly be placed on the right side of this splitter.
        ///
        /// To trigger this scenario this test first insert a bunch of values that are all unique and that will cause a
        /// split to happen. This is the firstBatch.
        /// The second batch are constructed so that at least one of them will have a value equal to the splitter key
        /// constructed during the firstBatch.
        /// It's important that the secondBatch has ids that are lower than the first batch to align with example described above.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPopulateAndRemoveEntriesWithSimilarMinimalSplitter() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPopulateAndRemoveEntriesWithSimilarMinimalSplitter()
        {
            string prefix     = "Work out your own salvation. Do not depend on others. ";
            int    nbrOfNodes = 200;
            long   nodeId     = 0;

            // Second batch has lower ids
            IList <NodeAndValue> secondBatch = new List <NodeAndValue>();

            for (int i = 0; i < nbrOfNodes; i++)
            {
                secondBatch.Add(new NodeAndValue(nodeId++, stringValue(prefix + i)));
            }

            // First batch has higher ids and minimal splitter among values in first batch will be found among second batch
            IList <NodeAndValue> firstBatch = new List <NodeAndValue>();

            for (int i = 0; i < nbrOfNodes; i++)
            {
                firstBatch.Add(new NodeAndValue(nodeId++, stringValue(prefix + i + " " + i)));
            }

            WithPopulator(IndexProvider.getPopulator(Descriptor, IndexSamplingConfig, heapBufferFactory(1024)), p =>
            {
                p.add(Updates(firstBatch));
                p.add(Updates(secondBatch));

                // Index should be consistent
            });

            IList <NodeAndValue> toRemove = new List <NodeAndValue>();

            ((IList <NodeAndValue>)toRemove).AddRange(firstBatch);
            ((IList <NodeAndValue>)toRemove).AddRange(secondBatch);
            Collections.shuffle(toRemove);

            // And we should be able to remove the entries in any order
            using (IndexAccessor accessor = IndexProvider.getOnlineAccessor(Descriptor, IndexSamplingConfig))
            {
                // WHEN
                using (IndexUpdater updater = accessor.NewUpdater(IndexUpdateMode.ONLINE))
                {
                    foreach (NodeAndValue nodeAndValue in toRemove)
                    {
                        updater.Process(IndexEntryUpdate.Remove(nodeAndValue.NodeId, Descriptor, nodeAndValue.Value));
                    }
                }

                // THEN
                using (IndexReader reader = new QueryResultComparingIndexReader(accessor.NewReader()))
                {
                    int propertyKeyId = Descriptor.schema().PropertyId;
                    foreach (NodeAndValue nodeAndValue in toRemove)
                    {
                        NodeValueIterator nodes = new NodeValueIterator();
                        reader.Query(nodes, IndexOrder.NONE, false, IndexQuery.exact(propertyKeyId, nodeAndValue.Value));
                        bool anyHits = false;

                        StringJoiner nodesStillLeft = new StringJoiner(", ", "[", "]");
                        while (nodes.HasNext())
                        {
                            anyHits = true;
                            nodesStillLeft.add(Convert.ToString(nodes.Next()));
                        }
                        assertFalse("Expected this query to have zero hits but found " + nodesStillLeft.ToString(), anyHits);
                    }
                }
            }
        }
Пример #6
0
 public static IndexEntryUpdate <SchemaDescriptor> Remove(long nodeId, SchemaDescriptor schema, params object[] objects)
 {
     return(IndexEntryUpdate.Remove(nodeId, schema, ToValues(objects)));
 }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateWhenRemovingLastTokenForNonSchemaIndex()
        public virtual void ShouldGenerateUpdateWhenRemovingLastTokenForNonSchemaIndex()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_empty).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Remove(NODE_ID, _nonSchemaIndex, _values123)));
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateWhenRemovingLastPropForNonSchemaIndex()
        public virtual void ShouldGenerateUpdateWhenRemovingLastPropForNonSchemaIndex()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_label).removed(_property2.propertyKeyId(), _property2.value()).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(_property2), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Remove(NODE_ID, _nonSchemaIndex, null, _property2.value(), null)));
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdatesForLabelRemovalWithExistingProperties()
        public virtual void ShouldGenerateUpdatesForLabelRemovalWithExistingProperties()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_empty).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Remove(NODE_ID, _index1, _property1.value()), IndexEntryUpdate.Remove(NODE_ID, _index2, _property2.value()), IndexEntryUpdate.Remove(NODE_ID, _index3, _property3.value()), IndexEntryUpdate.Remove(NODE_ID, _index123, _values123)));
        }