示例#1
0
 private void AssertMatch(BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator, Value value, long id)
 {
     using (NativeIndexReader <GenericKey, NativeIndexValue> reader = populator.newReader())
     {
         SimpleNodeValueClient cursor = new SimpleNodeValueClient();
         reader.Query(cursor, IndexOrder.NONE, true, IndexQuery.exact(_indexDescriptor.properties()[0], value));
         assertTrue(cursor.Next());
         assertEquals(id, cursor.Reference);
         assertEquals(value, cursor.Values[0]);
         assertFalse(cursor.Next());
     }
 }
        internal virtual IList <long> AssertClientReturnValuesInOrder(SimpleNodeValueClient client, IndexOrder order)
        {
            IList <long> seenIds = new List <long>();

            Value[] prevValues = null;
            Value[] values;
            int     count = 0;

            while (client.Next())
            {
                count++;
                seenIds.Add(client.Reference);
                values = client.Values;
                if (order == IndexOrder.ASCENDING)
                {
                    AssertLessThanOrEqualTo(prevValues, values);
                }
                else if (order == IndexOrder.DESCENDING)
                {
                    AssertLessThanOrEqualTo(values, prevValues);
                }
                else
                {
                    Assert.fail("Unexpected order " + order);
                }
                prevValues = values;
            }
            return(seenIds);
        }
示例#3
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());
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void exactMatchOnAllValues(java.util.List<org.neo4j.values.storable.Value> values) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException
        private void ExactMatchOnAllValues(IList <Value> values)
        {
            using (IndexReader indexReader = _accessor.newReader())
            {
                SimpleNodeValueClient client = new SimpleNodeValueClient();
                foreach (Value value in values)
                {
                    IndexQuery.ExactPredicate exact = IndexQuery.exact(_descriptor.schema().PropertyId, value);
                    indexReader.Query(client, IndexOrder.NONE, true, exact);

                    // then
                    assertTrue(client.Next());
                    assertEquals(value, client.Values[0]);
                    assertFalse(client.Next());
                }
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected java.util.List<long> query(org.neo4j.internal.kernel.api.IndexQuery... predicates) throws Exception
        protected internal virtual IList <long> Query(params IndexQuery[] predicates)
        {
            using (IndexReader reader = Accessor.newReader(), )
            {
                SimpleNodeValueClient nodeValueClient = new SimpleNodeValueClient();
                reader.Query(nodeValueClient, IndexOrder.NONE, false, predicates);
                IList <long> list = new LinkedList <long>();
                while (nodeValueClient.Next())
                {
                    long entityId = nodeValueClient.Reference;
                    if (PassesFilter(entityId, predicates))
                    {
                        list.Add(entityId);
                    }
                }
                list.Sort();
                return(list);
            }
        }