//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAcceptUnsortedLabels() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotAcceptUnsortedLabels() { // GIVEN ControlledInserter inserter = new ControlledInserter(); bool failed = false; try { using (NativeLabelScanWriter writer = new NativeLabelScanWriter(1, NativeLabelScanWriter.EMPTY)) { writer.Initialize(inserter); // WHEN writer.Write(NodeLabelUpdate.labelChanges(0, EMPTY_LONG_ARRAY, new long[] { 2, 1 })); // we can't do the usual "fail( blabla )" here since the actual write will happen // when closing this writer, i.e. in the curly bracket below. } } catch (System.ArgumentException e) { // THEN assertTrue(e.Message.contains("unsorted")); failed = true; } assertTrue(failed); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailOnUnsortedLabelsFromFullStoreChangeStream() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFailOnUnsortedLabelsFromFullStoreChangeStream() { // given PageCache pageCache = _pageCacheRule.getPageCache(_fileSystemRule.get()); IList <NodeLabelUpdate> existingData = new List <NodeLabelUpdate>(); existingData.Add(NodeLabelUpdate.labelChanges(1, new long[0], new long[] { 2, 1 })); FullStoreChangeStream changeStream = asStream(existingData); NativeLabelScanStore nativeLabelScanStore = null; try { nativeLabelScanStore = new NativeLabelScanStore(pageCache, _testDirectory.databaseLayout(), _fileSystemRule.get(), changeStream, false, new Monitors(), immediate()); nativeLabelScanStore.Init(); // when nativeLabelScanStore.Start(); fail("Expected native label scan store to fail on "); } catch (System.ArgumentException e) { // then assertThat(e.Message, Matchers.containsString("unsorted label")); assertThat(e.Message, Matchers.stringContainsInOrder(Iterables.asIterable("2", "1"))); } finally { if (nativeLabelScanStore != null) { nativeLabelScanStore.Shutdown(); } } }
public override bool VisitNodeCommand(Command.NodeCommand command) { // for label store updates NodeRecord before = command.Before; NodeRecord after = command.After; NodeLabels labelFieldBefore = parseLabelsField(before); NodeLabels labelFieldAfter = parseLabelsField(after); if (!(labelFieldBefore.Inlined && labelFieldAfter.Inlined && before.LabelField == after.LabelField)) { long[] labelsBefore = labelFieldBefore.IfLoaded; long[] labelsAfter = labelFieldAfter.IfLoaded; if (labelsBefore != null && labelsAfter != null) { if (outerInstance.labelUpdates == null) { outerInstance.labelUpdates = new List <NodeLabelUpdate>(); } outerInstance.labelUpdates.Add(NodeLabelUpdate.labelChanges(command.Key, labelsBefore, labelsAfter, outerInstance.txId)); } } // for indexes return(IndexUpdatesExtractor.visitNodeCommand(command)); }
//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 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()); } }
private NodeLabelUpdate RandomUpdate(long[] expected) { int nodeId = Random.Next(expected.Length); long labels = expected[nodeId]; long[] before = getLabels(labels); int changeCount = Random.Next(4) + 1; for (int i = 0; i < changeCount; i++) { labels = flipRandom(labels, LABEL_COUNT, Random.random()); } expected[nodeId] = labels; return(NodeLabelUpdate.labelChanges(nodeId, before, getLabels(labels))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWorkWithAFullRange() public virtual void ShouldWorkWithAFullRange() { // given long labelId = 0; IList <NodeLabelUpdate> updates = new List <NodeLabelUpdate>(); ISet <long> nodes = new HashSet <long>(); for (int i = 0; i < 34; i++) { updates.Add(NodeLabelUpdate.labelChanges(i, new long[] {}, new long[] { labelId })); nodes.Add(( long )i); } Start(updates); // when LabelScanReader reader = _store.newReader(); ISet <long> nodesWithLabel = PrimitiveLongCollections.toSet(reader.NodesWithLabel(( int )labelId)); // then assertEquals(nodes, nodesWithLabel); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSeeEntriesWhenOnlyLowestIsPresent() public virtual void ShouldSeeEntriesWhenOnlyLowestIsPresent() { // given long labelId = 0; IList <NodeLabelUpdate> labelUpdates = new List <NodeLabelUpdate>(); labelUpdates.Add(NodeLabelUpdate.labelChanges(0L, new long[] {}, new long[] { labelId })); Start(labelUpdates); // when MutableInt count = new MutableInt(); AllEntriesLabelScanReader nodeLabelRanges = _store.allNodeLabelRanges(); nodeLabelRanges.forEach(nlr => { foreach (long nodeId in nlr.nodes()) { count.add(nlr.labels(nodeId).length); } }); assertThat(count.intValue(), @is(1)); }