//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void randomModifications(long[] expected, int count) throws java.io.IOException private void RandomModifications(long[] expected, int count) { BitArray editedNodes = new BitArray(); using (LabelScanWriter writer = _store.newWriter()) { for (int i = 0; i < count; i++) { int nodeId = _random.Next(NODE_COUNT); if (editedNodes.Get(nodeId)) { i--; continue; } int changeSize = _random.Next(3) + 1; long labels = expected[nodeId]; long[] labelsBefore = GetLabels(labels); for (int j = 0; j < changeSize; j++) { labels = FlipRandom(labels, LABEL_COUNT, _random.random()); } long[] labelsAfter = GetLabels(labels); editedNodes.Set(nodeId, true); NodeLabelUpdate labelChanges = labelChanges(nodeId, labelsBefore, labelsAfter); writer.Write(labelChanges); expected[nodeId] = labels; } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUpdateLabelStoreScanOnNodeCommands() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUpdateLabelStoreScanOnNodeCommands() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final IndexBatchTransactionApplier applier = newIndexTransactionApplier(); IndexBatchTransactionApplier applier = NewIndexTransactionApplier(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.store.record.NodeRecord before = new org.neo4j.kernel.impl.store.record.NodeRecord(11); NodeRecord before = new NodeRecord(11); before.SetLabelField(17, _emptyDynamicRecords); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.store.record.NodeRecord after = new org.neo4j.kernel.impl.store.record.NodeRecord(12); NodeRecord after = new NodeRecord(12); after.SetLabelField(18, _emptyDynamicRecords); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Command.NodeCommand command = new Command.NodeCommand(before, after); Command.NodeCommand command = new Command.NodeCommand(before, after); LabelScanWriter labelScanWriter = mock(typeof(LabelScanWriter)); when(_labelScanStore.get()).thenReturn(labelScanWriter); // when bool result; using (TransactionApplier txApplier = applier.StartTx(_transactionToApply)) { result = txApplier.VisitNodeCommand(command); } // then assertFalse(result); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void prepareIndex() throws java.io.IOException private void PrepareIndex() { Start(); using (LabelScanWriter labelScanWriter = _store.newWriter()) { labelScanWriter.Write(NodeLabelUpdate.labelChanges(1, new long[] {}, new long[] { 1 })); } _store.shutdown(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void write(java.util.Iterator<org.neo4j.kernel.api.labelscan.NodeLabelUpdate> iterator) throws java.io.IOException private void Write(IEnumerator <NodeLabelUpdate> iterator) { using (LabelScanWriter writer = _store.newWriter()) { while (iterator.MoveNext()) { writer.Write(iterator.Current); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void checkLabelScanStoreAccessible(org.neo4j.kernel.api.labelscan.LabelScanStore labelScanStore) throws java.io.IOException private static void CheckLabelScanStoreAccessible(LabelScanStore labelScanStore) { int labelId = 1; using (LabelScanWriter labelScanWriter = labelScanStore.NewWriter()) { labelScanWriter.Write(NodeLabelUpdate.labelChanges(1, new long[] {}, new long[] { labelId })); } using (LabelScanReader labelScanReader = labelScanStore.NewReader()) { assertEquals(1, labelScanReader.NodesWithLabel(labelId).next()); } }
/// <summary> /// Starts the store and makes it available for queries and updates. /// Any required recovery must take place before calling this method. /// </summary> /// <exception cref="IOException"> on <seealso cref="PageCache"/> exceptions. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void start() throws java.io.IOException public override void Start() { if (_needsRebuild && !_readOnly) { _monitor.rebuilding(); long numberOfNodes; // Intentionally ignore read-only flag here when rebuilding. using (LabelScanWriter writer = writer()) { numberOfNodes = _fullStoreChangeStream.applyTo(writer); } _index.checkpoint(Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited, _writeClean); _monitor.rebuilt(numberOfNodes); _needsRebuild = false; } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void shouldStartFromGivenId(int sparsity) throws java.io.IOException private void ShouldStartFromGivenId(int sparsity) { // given NativeLabelScanStore store = Life.add(new NativeLabelScanStore(Storage.pageCache(), DatabaseLayout.of(Storage.directory().directory()), Storage.fileSystem(), EMPTY, false, new Monitors(), immediate())); int labelId = 1; int highNodeId = 100_000; BitArray expected = new BitArray(highNodeId); using (LabelScanWriter writer = store.NewWriter()) { int updates = highNodeId / sparsity; for (int i = 0; i < updates; i++) { int nodeId = Random.Next(highNodeId); writer.Write(labelChanges(nodeId, EMPTY_LONG_ARRAY, new long[] { labelId })); expected.Set(nodeId, true); } } // when long fromId = Random.Next(highNodeId); int nextExpectedId = expected.nextSetBit(toIntExact(fromId + 1)); using (LabelScanReader reader = store.NewReader(), PrimitiveLongResourceIterator ids = reader.NodesWithAnyOfLabels(fromId, new int[] { labelId })) { // then while (nextExpectedId != -1) { assertTrue(ids.hasNext()); long nextId = ids.next(); assertEquals(nextExpectedId, toIntExact(nextId)); nextExpectedId = expected.nextSetBit(nextExpectedId + 1); } assertFalse(ids.hasNext()); } }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: private System.Func<org.neo4j.kernel.api.labelscan.LabelScanWriter> singletonProvider(final org.neo4j.kernel.api.labelscan.LabelScanWriter writer) private System.Func <LabelScanWriter> SingletonProvider(LabelScanWriter writer) { return(() => writer); }