Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldProcessRecordsParallelAndUpdateProgress() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldProcessRecordsParallelAndUpdateProgress()
        {
            // given
            ProgressMonitorFactory.MultiPartBuilder progressBuilder = mock(typeof(ProgressMonitorFactory.MultiPartBuilder));
            ProgressListener progressListener = mock(typeof(ProgressListener));

            when(progressBuilder.ProgressForPart(anyString(), anyLong())).thenReturn(progressListener);

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") org.neo4j.helpers.collection.BoundedIterable<int> store = mock(org.neo4j.helpers.collection.BoundedIterable.class);
            BoundedIterable <int> store = mock(typeof(BoundedIterable));

            when(store.GetEnumerator()).thenReturn(asList(42, 75, 192).GetEnumerator());

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") RecordProcessor<int> recordProcessor = mock(RecordProcessor.class);
            RecordProcessor <int> recordProcessor = mock(typeof(RecordProcessor));

            RecordScanner <int> scanner = new ParallelRecordScanner <int>("our test task", Statistics.NONE, 1, store, progressBuilder, recordProcessor, CacheAccess.EMPTY, QueueDistribution.ROUND_ROBIN);

            // when
            scanner.Run();

            // then
            VerifyProcessCloseAndDone(recordProcessor, store, progressListener);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldScanMultipleRanges()
        public virtual void ShouldScanMultipleRanges()
        {
            // GIVEN
            int  labelId1 = 1;
            int  labelId2 = 2;
            long nodeId1  = 10;
            long nodeId2  = 1280;

            Start(new IList <NodeLabelUpdate> {
                labelChanges(nodeId1, _noLabels, new long[] { labelId1 }), labelChanges(nodeId2, _noLabels, new long[] { labelId1, labelId2 })
            });

            // WHEN
            BoundedIterable <NodeLabelRange> reader   = _store.allNodeLabelRanges();
            IEnumerator <NodeLabelRange>     iterator = reader.GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            NodeLabelRange range1 = iterator.next();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            NodeLabelRange range2 = iterator.next();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(iterator.hasNext());

            // THEN
            assertArrayEquals(new long[] { nodeId1 }, ReducedNodes(range1));
            assertArrayEquals(new long[] { nodeId2 }, ReducedNodes(range2));

            assertArrayEquals(new long[] { labelId1 }, Sorted(range1.Labels(nodeId1)));

            assertArrayEquals(new long[] { labelId1, labelId2 }, Sorted(range2.Labels(nodeId2)));
        }
Ejemplo n.º 3
0
        private static BoundedIterable <long> MockSingleAllEntriesReader(IndexAccessor targetAccessor, IList <long> entries)
        {
            BoundedIterable <long> allEntriesReader = MockedAllEntriesReader(entries);

            when(targetAccessor.NewAllEntriesReader()).thenReturn(allEntriesReader);
            return(allEntriesReader);
        }
Ejemplo n.º 4
0
        private static BoundedIterable <long> MockedAllEntriesReader(bool knownMaxCount, IList <long> entries)
        {
            BoundedIterable <long> mockedAllEntriesReader = mock(typeof(BoundedIterable));

            when(mockedAllEntriesReader.MaxCount()).thenReturn(knownMaxCount ? entries.Count : Org.Neo4j.Helpers.Collection.BoundedIterable_Fields.UNKNOWN_MAX_COUNT);
            when(mockedAllEntriesReader.GetEnumerator()).thenReturn(entries.GetEnumerator());
            return(mockedAllEntriesReader);
        }
Ejemplo n.º 5
0
        internal RecordScanner(string name, Statistics statistics, int threads, BoundedIterable <RECORD> store, ProgressMonitorFactory.MultiPartBuilder builder, RecordProcessor <RECORD> processor, params IterableStore[] warmUpStores) : base(name, statistics, threads)
        {
            this.Store     = store;
            this.Processor = processor;
            long maxCount = store.MaxCount();

            this.Progress      = maxCount == -1 ? builder.ProgressForUnknownPart(name) : builder.ProgressForPart(name, maxCount);
            this._warmUpStores = warmUpStores;
        }
Ejemplo n.º 6
0
        public override IEnumerator <long> Iterator()
        {
            if (_indexReader == null)
            {
                _indexReader = _indexAccessor.newAllEntriesReader();
            }

            return(_indexReader.GetEnumerator());
        }
Ejemplo n.º 7
0
 public override long MaxCount()
 {
     try
     {
         using (BoundedIterable <long> reader = _indexAccessor.newAllEntriesReader())
         {
             return(reader.MaxCount());
         }
     }
     catch (Exception e)
     {
         throw new Exception(e);
     }
 }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void allEntriesReaderMustReportFusionMaxCountOfAll()
        public virtual void AllEntriesReaderMustReportFusionMaxCountOfAll()
        {
            long lastId = 0;

            foreach (IndexAccessor accessor in _aliveAccessors)
            {
                MockSingleAllEntriesReader(accessor, Arrays.asList(lastId++, lastId++));
            }

            // then
            BoundedIterable <long> fusionAllEntriesReader = _fusionIndexAccessor.newAllEntriesReader();

            assertThat(fusionAllEntriesReader.MaxCount(), @is(lastId));
        }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void allEntriesReaderMustCloseOthersIfOneThrow() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AllEntriesReaderMustCloseOthersIfOneThrow()
        {
            for (int i = 0; i < _aliveAccessors.Length; i++)
            {
                // given
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                BoundedIterable <long>[] allEntriesReaders = java.util.aliveAccessors.Select(accessor => MockSingleAllEntriesReader(accessor, Arrays.asList())).ToArray(BoundedIterable[] ::new);

                // then
                BoundedIterable <long> fusionAllEntriesReader = _fusionIndexAccessor.newAllEntriesReader();
                verifyOtherIsClosedOnSingleThrow(allEntriesReaders[i], fusionAllEntriesReader, without(allEntriesReaders, allEntriesReaders[i]));

                ResetMocks();
            }
        }
Ejemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void allEntriesReaderMustThrowIfOneThrow() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AllEntriesReaderMustThrowIfOneThrow()
        {
            foreach (IndexAccessor failingAccessor in _aliveAccessors)
            {
                BoundedIterable <long> failingReader = null;
                foreach (IndexAccessor aliveAccessor in _aliveAccessors)
                {
                    BoundedIterable <long> reader = MockSingleAllEntriesReader(aliveAccessor, Collections.emptyList());
                    if (aliveAccessor == failingAccessor)
                    {
                        failingReader = reader;
                    }
                }

                // then
                BoundedIterable <long> fusionAllEntriesReader = _fusionIndexAccessor.newAllEntriesReader();
                FusionIndexTestHelp.VerifyFusionCloseThrowOnSingleCloseThrow(failingReader, fusionAllEntriesReader);
            }
        }
Ejemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldScanSingleRange()
        public virtual void ShouldScanSingleRange()
        {
            // GIVEN
            int  labelId1 = 1;
            int  labelId2 = 2;
            long nodeId1  = 10;
            long nodeId2  = 11;

            Start(new IList <NodeLabelUpdate> {
                labelChanges(nodeId1, _noLabels, new long[] { labelId1 }), labelChanges(nodeId2, _noLabels, new long[] { labelId1, labelId2 })
            });

            // WHEN
            BoundedIterable <NodeLabelRange> reader = _store.allNodeLabelRanges();
            NodeLabelRange range = single(reader.GetEnumerator());

            // THEN
            assertArrayEquals(new long[] { nodeId1, nodeId2 }, ReducedNodes(range));

            assertArrayEquals(new long[] { labelId1 }, Sorted(range.Labels(nodeId1)));
            assertArrayEquals(new long[] { labelId1, labelId2 }, Sorted(range.Labels(nodeId2)));
        }
Ejemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void allEntriesReaderMustReportUnknownMaxCountIfAnyReportUnknownMaxCount()
        public virtual void AllEntriesReaderMustReportUnknownMaxCountIfAnyReportUnknownMaxCount()
        {
            for (int i = 0; i < _aliveAccessors.Length; i++)
            {
                for (int j = 0; j < _aliveAccessors.Length; j++)
                {
                    // given
                    if (j == i)
                    {
                        MockSingleAllEntriesReaderWithUnknownMaxCount(_aliveAccessors[j], Collections.emptyList());
                    }
                    else
                    {
                        MockSingleAllEntriesReader(_aliveAccessors[j], Collections.emptyList());
                    }
                }

                // then
                BoundedIterable <long> fusionAllEntriesReader = _fusionIndexAccessor.newAllEntriesReader();
                assertThat(fusionAllEntriesReader.MaxCount(), @is(Org.Neo4j.Helpers.Collection.BoundedIterable_Fields.UNKNOWN_MAX_COUNT));
            }
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void verifyProcessCloseAndDone(RecordProcessor<int> recordProcessor, org.neo4j.helpers.collection.BoundedIterable<int> store, org.neo4j.helpers.progress.ProgressListener progressListener) throws Exception
        private static void VerifyProcessCloseAndDone(RecordProcessor <int> recordProcessor, BoundedIterable <int> store, ProgressListener progressListener)
        {
            verify(recordProcessor).process(42);
            verify(recordProcessor).process(75);
            verify(recordProcessor).process(192);
            verify(recordProcessor).close();

            verify(store).close();

            verify(progressListener, times(3)).add(1);
            verify(progressListener).done();
        }
Ejemplo n.º 14
0
        private static void MockSingleAllEntriesReaderWithUnknownMaxCount(IndexAccessor targetAccessor, IList <long> entries)
        {
            BoundedIterable <long> allEntriesReader = MockedAllEntriesReaderUnknownMaxCount(entries);

            when(targetAccessor.NewAllEntriesReader()).thenReturn(allEntriesReader);
        }
Ejemplo n.º 15
0
 public SequentialRecordScanner(string name, Statistics statistics, int threads, BoundedIterable <RECORD> store, MultiPartBuilder builder, RecordProcessor <RECORD> processor, params IterableStore[] warmUpStores) : base(name, statistics, threads, store, builder, processor, warmUpStores)
 {
 }
Ejemplo n.º 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: private <RECORD> RecordScanner<RECORD> recordScanner(String name, org.neo4j.helpers.collection.BoundedIterable<RECORD> store, RecordProcessor<RECORD> processor, Stage stage, QueueDistribution distribution, @SuppressWarnings("rawtypes") IterableStore... warmupStores)
        private RecordScanner <RECORD> RecordScanner <RECORD>(string name, BoundedIterable <RECORD> store, RecordProcessor <RECORD> processor, Stage stage, QueueDistribution distribution, params IterableStore[] warmupStores)
        {
            return(stage.Parallel ? new ParallelRecordScanner <RECORD>(name, _statistics, _numberOfThreads, store, _multiPartBuilder, processor, _cacheAccess, distribution, warmupStores) : new SequentialRecordScanner <RECORD>(name, _statistics, _numberOfThreads, store, _multiPartBuilder, processor, warmupStores));
        }
Ejemplo n.º 17
0
 public ParallelRecordScanner(string name, Statistics statistics, int threads, BoundedIterable <RECORD> store, MultiPartBuilder builder, RecordProcessor <RECORD> processor, CacheAccess cacheAccess, QueueDistribution distribution, params IterableStore[] warmUpStores) : base(name, statistics, threads, store, builder, processor, warmUpStores)
 {
     this._cacheAccess  = cacheAccess;
     this._distribution = distribution;
 }
Ejemplo n.º 18
0
 public LuceneAllEntriesIndexAccessorReader(BoundedIterable <Document> documents, System.Func <Document, long> entityIdReader)
 {
     this._documents      = documents;
     this._entityIdReader = entityIdReader;
 }