//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void scanOverPartitions() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ScanOverPartitions() { PartitionedIndexReader indexReader = CreatePartitionedReaderFromReaders(); IndexQuery.ExistsPredicate query = IndexQuery.exists(1); 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 shouldRejectNodeNotInUse() public virtual void ShouldRejectNodeNotInUse() { // given NodeValueClientFilter filter = InitializeFilter(IndexQuery.exists(12)); // when filter.Next(); assertFalse(filter.AcceptNode(17, null)); filter.Close(); // then AssertEvents(Initialize(), Event.NEXT, Event.CLOSE); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAcceptNodeWithoutMatchingProperty() public virtual void ShouldNotAcceptNodeWithoutMatchingProperty() { // given _node.withNode(17, new long[0], genericMap(7, stringValue("wrong"))); NodeValueClientFilter filter = InitializeFilter(IndexQuery.exists(12)); // when filter.Next(); assertFalse(filter.AcceptNode(17, null)); filter.Close(); // then AssertEvents(Initialize(), Event.NEXT, Event.CLOSE); }
//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: public final void nodeIndexScan(org.neo4j.internal.kernel.api.IndexReference index, org.neo4j.internal.kernel.api.NodeValueIndexCursor cursor, org.neo4j.internal.kernel.api.IndexOrder indexOrder, boolean needsValues) throws org.neo4j.internal.kernel.api.exceptions.KernelException public override void NodeIndexScan(IndexReference index, NodeValueIndexCursor cursor, IndexOrder indexOrder, bool needsValues) { Ktx.assertOpen(); if (HasForbiddenProperties(index)) { cursor.Close(); return; } // for a scan, we simply query for existence of the first property, which covers all entries in an index int firstProperty = index.Properties()[0]; DefaultNodeValueIndexCursor cursorImpl = ( DefaultNodeValueIndexCursor )cursor; cursorImpl.Read = this; IndexReader(index, false).query(cursorImpl, indexOrder, needsValues, IndexQuery.exists(firstProperty)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addUpdates() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AddUpdates() { _populator = NewPopulator(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = java.util.Arrays.asList(add(1, schemaDescriptor, "aaa"), add(2, schemaDescriptor, "bbb"), add(3, schemaDescriptor, "ccc")); IList <IndexEntryUpdate <object> > updates = Arrays.asList(add(1, _schemaDescriptor, "aaa"), add(2, _schemaDescriptor, "bbb"), add(3, _schemaDescriptor, "ccc")); _populator.add(updates); _index.maybeRefreshBlocking(); using (IndexReader reader = _index.IndexReader) { LongIterator allEntities = reader.Query(IndexQuery.exists(1)); assertArrayEquals(new long[] { 1, 2, 3 }, PrimitiveLongCollections.asArray(allEntities)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void indexReaderShouldSupportScan() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void IndexReaderShouldSupportScan() { // GIVEN //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: updateAndCommit(asList(add(nodeId, value), add(nodeId2, value2))); UpdateAndCommit(new IList <IndexEntryUpdate <object> > { Add(_nodeId, _value), Add(_nodeId2, _value2) }); IndexReader reader = _accessor.newReader(); // WHEN LongIterator results = reader.Query(IndexQuery.exists(PROP_ID)); // THEN assertEquals(asSet(_nodeId, _nodeId2), PrimitiveLongCollections.toSet(results)); assertEquals(asSet(_nodeId), PrimitiveLongCollections.toSet(reader.Query(exact(PROP_ID, _value)))); reader.Close(); }
// close iterator //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void closeIteratorMustCloseAll() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CloseIteratorMustCloseAll() { // given PrimitiveLongResourceIterator[] iterators = new PrimitiveLongResourceIterator[_aliveReaders.Length]; for (int i = 0; i < _aliveReaders.Length; i++) { PrimitiveLongResourceIterator iterator = mock(typeof(PrimitiveLongResourceIterator)); when(_aliveReaders[i].query(any(typeof(IndexQuery)))).thenReturn(iterator); iterators[i] = iterator; } // when _fusionIndexReader.query(IndexQuery.exists(PROP_KEY)).close(); // then foreach (PrimitiveLongResourceIterator iterator in iterators) { verify(iterator, times(1)).close(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustCombineResultFromExistsPredicate() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MustCombineResultFromExistsPredicate() { // given IndexQuery.ExistsPredicate exists = IndexQuery.exists(PROP_KEY); long lastId = 0; foreach (IndexReader aliveReader in _aliveReaders) { when(aliveReader.Query(exists)).thenReturn(PrimitiveLongResourceCollections.iterator(null, lastId++, lastId++)); } // when LongIterator result = _fusionIndexReader.query(exists); // then LongSet resultSet = PrimitiveLongCollections.asSet(result); for (long i = 0L; i < lastId; i++) { assertTrue("Expected to contain " + i + ", but was " + resultSet, resultSet.contains(i)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertIndexedNodesMatchesStoreNodes() throws Exception private void AssertIndexedNodesMatchesStoreNodes() { int nodesInStore = 0; Label label = Label.label(PERSON_LABEL); using (Transaction tx = _db.beginTx()) { KernelTransaction ktx = (( GraphDatabaseAPI )_db).DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); IList <string> mismatches = new List <string>(); int labelId = ktx.TokenRead().nodeLabel(PERSON_LABEL); int propertyKeyId = ktx.TokenRead().propertyKey(NAME_PROPERTY); IndexReference index = ktx.SchemaRead().index(labelId, propertyKeyId); using (NodeValueIndexCursor cursor = ktx.Cursors().allocateNodeValueIndexCursor()) { // Node --> Index foreach (Node node in filter(n => n.hasLabel(label) && n.hasProperty(NAME_PROPERTY), _db.AllNodes)) { nodesInStore++; string name = ( string )node.GetProperty(NAME_PROPERTY); ktx.DataRead().nodeIndexSeek(index, cursor, IndexOrder.NONE, false, IndexQuery.exact(propertyKeyId, name)); bool found = false; while (cursor.Next()) { long indexedNode = cursor.NodeReference(); if (indexedNode == node.Id) { if (found) { mismatches.Add("Index has multiple entries for " + name + " and " + indexedNode); } found = true; } } if (!found) { mismatches.Add("Index is missing entry for " + name + " " + node); } } if (mismatches.Count > 0) { fail(join(mismatches.ToArray(), format("%n"))); } // Node count == indexed node count ktx.DataRead().nodeIndexSeek(index, cursor, IndexOrder.NONE, false, IndexQuery.exists(propertyKeyId)); int nodesInIndex = 0; while (cursor.Next()) { nodesInIndex++; } assertEquals(nodesInStore, nodesInIndex); } } }