//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitOnlyLabeledNodes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void VisitOnlyLabeledNodes()
        {
            LabelScanReader labelScanReader = mock(typeof(LabelScanReader));

            when(_labelScanStore.newReader()).thenReturn(labelScanReader);
            when(_nodeLabelRanges.maxCount()).thenReturn(1L);

            PrimitiveLongResourceIterator labeledNodesIterator = PrimitiveLongResourceCollections.iterator(null, 1, 2, 3, 4, 5, 6, 7, 8);

            when(_nodeStore.HighestPossibleIdInUse).thenReturn(200L);
            when(_nodeStore.HighId).thenReturn(20L);
            when(labelScanReader.NodesWithAnyOfLabels(new int[] { 2, 6 })).thenReturn(labeledNodesIterator);
            when(_nodeStore.openPageCursorForReading(anyLong())).thenReturn(mock(typeof(PageCursor)));

            MockLabelNodeCount(_countStore, 2);
            MockLabelNodeCount(_countStore, 6);

            DynamicIndexStoreView storeView = DynamicIndexStoreView();

            StoreScan <Exception> storeScan = storeView.VisitNodes(new int[] { 2, 6 }, _propertyKeyIdFilter, _propertyUpdateVisitor, _labelUpdateVisitor, false);

            storeScan.Run();

            Mockito.verify(_nodeStore, times(8)).getRecordByCursor(anyLong(), any(typeof(NodeRecord)), any(typeof(RecordLoad)), any(typeof(PageCursor)));
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void close() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void Close()
        {
            _actual.close();
            try
            {
                using (IndexReader reader = _readerSupplier.get())
                {
                    foreach (ValueTuple tuple in _touchedTuples)
                    {
                        using (PrimitiveLongResourceIterator results = reader.Query(QueryOf(tuple)))
                        {
                            if (results.hasNext())
                            {
                                long firstEntityId = results.next();
                                if (results.hasNext())
                                {
                                    long secondEntityId = results.next();
                                    throw new IndexEntryConflictException(firstEntityId, secondEntityId, tuple);
                                }
                            }
                        }
                    }
                }
            }
            catch (IndexNotApplicableKernelException e)
            {
                throw new System.ArgumentException("Unexpectedly the index reader couldn't handle this query", e);
            }
        }
        private void AssertContent(PrimitiveLongResourceIterator iterator, params long[] expected)
        {
            int i = 0;

            while (iterator.hasNext())
            {
                assertEquals(expected[i++], iterator.next(), "has expected value");
            }
            assertEquals(expected.Length, i, "has all expected values");
        }
示例#4
0
 private void AssertHasEntry(BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator, Value duplicate, int expectedId)
 {
     using (NativeIndexReader <GenericKey, NativeIndexValue> reader = populator.newReader())
     {
         PrimitiveLongResourceIterator query = reader.Query(IndexQuery.exact(_indexDescriptor.properties()[0], duplicate));
         assertTrue(query.hasNext());
         long id = query.next();
         assertEquals(expectedId, id);
     }
 }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void closeResource()
        public virtual void CloseResource()
        {
            Resource resource = Mockito.mock(typeof(Resource));
            PrimitiveLongResourceIterator source = resourceIterator(ImmutableEmptyLongIterator.INSTANCE, resource);

            PrimitiveLongResourceIterator iterator = DiffApplyingPrimitiveLongIterator.Augment(source, LongSets.immutable.empty(), LongSets.immutable.empty());

            iterator.Close();

            Mockito.verify(resource).close();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void iterateOverLabeledNodeIds()
        public virtual void IterateOverLabeledNodeIds()
        {
            PrimitiveLongResourceIterator labeledNodes = PrimitiveLongResourceCollections.iterator(null, 1, 2, 4, 8);

            when(_nodeStore.HighId).thenReturn(15L);
            int[] labelIds = new int[] { 1, 2 };
            when(_labelScanReader.nodesWithAnyOfLabels(labelIds)).thenReturn(labeledNodes);

            LabelScanViewNodeStoreScan <Exception> storeScan  = GetLabelScanViewStoreScan(labelIds);
            PrimitiveLongResourceIterator          idIterator = storeScan.EntityIdIterator;
            IList <long> visitedNodeIds = PrimitiveLongCollections.asList(idIterator);

            assertThat(visitedNodeIds, Matchers.hasSize(4));
            assertThat(visitedNodeIds, Matchers.hasItems(1L, 2L, 4L, 8L));
        }
        // ITERATOR

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void simpleIterator()
        internal virtual void SimpleIterator()
        {
            // Given
            CountingResource resource = new CountingResource();
            PrimitiveLongResourceIterator iterator = PrimitiveLongResourceCollections.Iterator(resource, 1, 2, 3, 4);

            // Then
            AssertContent(iterator, 1, 2, 3, 4);

            // When
            iterator.Close();

            // Then
            assertEquals(1, resource.CloseCount(), "exactly one call to close");
        }
示例#8
0
        // FILTER

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void filterItems()
        internal virtual void FilterItems()
        {
            // Given
            CountingResource resource = new CountingResource();
            PrimitiveLongResourceIterator iterator = PrimitiveLongResourceCollections.Iterator(resource, 1, 2, 3, 4);

            // When
            PrimitiveLongResourceIterator filtered = PrimitiveLongResourceCollections.Filter(iterator, _even);

            // Then
            AssertContent(filtered, 2, 4);

            // When
            filtered.Close();

            // Then
            assertEquals(1, resource.CloseCount(), "exactly one call to close");
        }
        // FILTER

        // CONCAT

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void concatIterators()
        internal virtual void ConcatIterators()
        {
            // Given
            CountingResource resource            = new CountingResource();
            PrimitiveLongResourceIterator first  = PrimitiveLongResourceCollections.Iterator(resource, 1, 2);
            PrimitiveLongResourceIterator second = PrimitiveLongResourceCollections.Iterator(resource, 3, 4);

            // When
            PrimitiveLongResourceIterator concat = PrimitiveLongResourceCollections.Concat(first, second);

            // Then
            AssertContent(concat, 1, 2, 3, 4);

            // When
            concat.Close();

            // Then
            assertEquals(2, resource.CloseCount(), "all concatenated iterators are closed");
        }
示例#10
0
        // 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();
            }
        }
示例#11
0
 public static PrimitiveLongResourceIterator Filter(PrimitiveLongResourceIterator source, System.Func <long, bool> filter)
 {
     return(new PrimitiveLongFilteringResourceIteratorAnonymousInnerClass(source, filter));
 }
示例#12
0
 internal PrimitiveLongFilteringResourceIterator(PrimitiveLongResourceIterator source) : base(source)
 {
     this.Source = source;
 }
 internal static PrimitiveLongResourceIterator Augment(PrimitiveLongResourceIterator source, LongSet addedElements, LongSet removedElements)
 {
     return(new DiffApplyingPrimitiveLongIterator(source, addedElements, removedElements, source));
 }