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)); }
public List <string> ValidationErrors() { var validationErrors = new List <string>(); if (!NodeLabels.Any()) { validationErrors.Add("At least one NodeLabel must be provided."); } return(validationErrors); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldInlineOneLabelWithHighId() public virtual void ShouldInlineOneLabelWithHighId() { // GIVEN long labelId = 10000; NodeRecord node = NodeRecordWithInlinedLabels(); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN nodeLabels.Add(labelId, null, null); // THEN assertEquals(InlinedLabelsLongRepresentation(labelId), node.LabelField); }
public List <string> ValidationErrors() { var validationErrors = new List <string>(); if (!NodeLabels.Any()) { validationErrors.Add("At least one NodeLabel must be provided."); } //todo: needs to validate id property name and value too return(validationErrors); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldInlineTwoSmallLabels() public virtual void ShouldInlineTwoSmallLabels() { // GIVEN long labelId1 = 10; long labelId2 = 30; NodeRecord node = NodeRecordWithInlinedLabels(labelId1); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN nodeLabels.Add(labelId2, null, null); // THEN assertEquals(InlinedLabelsLongRepresentation(labelId1, labelId2), node.LabelField); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void maximumOfSevenInlinedLabels() public virtual void MaximumOfSevenInlinedLabels() { // GIVEN long[] labels = new long[] { 0, 1, 2, 3, 4, 5, 6 }; NodeRecord node = NodeRecordWithInlinedLabels(labels); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN IEnumerable <DynamicRecord> changedDynamicRecords = nodeLabels.Add(23, _nodeStore, _nodeStore.DynamicLabelStore); // THEN assertEquals(DynamicLabelsLongRepresentation(changedDynamicRecords), node.LabelField); assertEquals(1, Iterables.count(changedDynamicRecords)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void oneDynamicRecordShouldShrinkIntoInlinedWhenRemoving() public virtual void OneDynamicRecordShouldShrinkIntoInlinedWhenRemoving() { // GIVEN NodeRecord node = nodeRecordWithDynamicLabels(_nodeStore, OneByteLongs(5)); ICollection <DynamicRecord> initialRecords = node.DynamicLabelRecords; NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN ICollection <DynamicRecord> changedDynamicRecords = Iterables.asCollection(nodeLabels.Remove(255, _nodeStore)); // THEN assertEquals(initialRecords, changedDynamicRecords); assertFalse(Iterables.single(changedDynamicRecords).inUse()); assertEquals(InlinedLabelsLongRepresentation(251, 252, 253, 254), node.LabelField); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReallocateAllOfPreviousDynamicRecordsAndThenSome() public virtual void ShouldReallocateAllOfPreviousDynamicRecordsAndThenSome() { // GIVEN NodeRecord node = nodeRecordWithDynamicLabels(_nodeStore, FourByteLongs(100)); ISet <DynamicRecord> initialRecords = Iterables.asSet(Cloned(node.DynamicLabelRecords, typeof(DynamicRecord))); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN ISet <DynamicRecord> reallocatedRecords = Iterables.asUniqueSet(nodeLabels.Put(FourByteLongs(5), _nodeStore, _nodeStore.DynamicLabelStore)); // THEN //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method: assertTrue("initial:" + initialRecords + ", reallocated:" + reallocatedRecords, initialRecords.containsAll(Used(reallocatedRecords))); assertTrue(Used(reallocatedRecords).Count < initialRecords.Count); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSerializeInlineLabels() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSerializeInlineLabels() { // Given NodeRecord before = new NodeRecord(12, false, 1, 2); before.InUse = true; NodeRecord after = new NodeRecord(12, false, 2, 1); after.InUse = true; NodeLabels nodeLabels = parseLabelsField(after); nodeLabels.Add(1337, _nodeStore, _nodeStore.DynamicLabelStore); // When AssertSerializationWorksFor(new Command.NodeCommand(before, after)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReallocateSomeOfPreviousDynamicRecords() public virtual void ShouldReallocateSomeOfPreviousDynamicRecords() { // GIVEN NodeRecord node = nodeRecordWithDynamicLabels(_nodeStore, OneByteLongs(5)); ISet <DynamicRecord> initialRecords = Iterables.asUniqueSet(node.DynamicLabelRecords); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN ISet <DynamicRecord> reallocatedRecords = Iterables.asUniqueSet(nodeLabels.Put(FourByteLongs(100), _nodeStore, _nodeStore.DynamicLabelStore)); // THEN //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method: assertTrue(reallocatedRecords.containsAll(initialRecords)); assertTrue(reallocatedRecords.Count > initialRecords.Count); }
public virtual List <string> ValidationErrors() { List <string> validationErrors = new List <string>(); if (!NodeLabels.Any()) { validationErrors.Add($"Missing {nameof(NodeLabels)}."); } if (IdPropertyName == null) { validationErrors.Add($"{nameof(IdPropertyName)} is null."); } return(validationErrors); }
public List <string> ValidationErrors() { var validationErrors = new List <string>(); if (!NodeLabels.Any()) { validationErrors.Add("At least one NodeLabel must be provided."); } if (MaxPathLength < 0) { validationErrors.Add("MaxPathLength must not be negative."); } return(validationErrors); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void twoDynamicRecordsShouldShrinkToOneWhenRemovingWithoutChangingItsOwner() public virtual void TwoDynamicRecordsShouldShrinkToOneWhenRemovingWithoutChangingItsOwner() { // GIVEN // will occupy 61B of data, i.e. just two dynamic records long? nodeId = 42L; NodeRecord node = nodeRecordWithDynamicLabels(nodeId, _nodeStore, OneByteLongs(57)); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); IList <DynamicRecord> changedDynamicRecords = Iterables.addToCollection(nodeLabels.Remove(255, _nodeStore), new List <DynamicRecord>()); // WHEN Pair <long, long[]> changedPair = DynamicNodeLabels.getDynamicLabelsArrayAndOwner(changedDynamicRecords, _nodeStore.DynamicLabelStore); // THEN assertEquals(nodeId, changedPair.First()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void twoDynamicRecordsShouldShrinkToOneWhenRemoving() public virtual void TwoDynamicRecordsShouldShrinkToOneWhenRemoving() { // GIVEN // will occupy 61B of data, i.e. just two dynamic records NodeRecord node = nodeRecordWithDynamicLabels(_nodeStore, OneByteLongs(57)); ICollection <DynamicRecord> initialRecords = node.DynamicLabelRecords; NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN IList <DynamicRecord> changedDynamicRecords = Iterables.addToCollection(nodeLabels.Remove(255, _nodeStore), new List <DynamicRecord>()); // THEN assertEquals(initialRecords, changedDynamicRecords); assertTrue(changedDynamicRecords[0].InUse()); assertFalse(changedDynamicRecords[1].InUse()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void oneDynamicRecordShouldExtendIntoAnAdditionalIfTooManyLabels() public virtual void OneDynamicRecordShouldExtendIntoAnAdditionalIfTooManyLabels() { // GIVEN // will occupy 60B of data, i.e. one dynamic record NodeRecord node = nodeRecordWithDynamicLabels(_nodeStore, OneByteLongs(56)); ICollection <DynamicRecord> initialRecords = node.DynamicLabelRecords; NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN ISet <DynamicRecord> changedDynamicRecords = Iterables.asSet(nodeLabels.Add(1, _nodeStore, _nodeStore.DynamicLabelStore)); // THEN //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method: assertTrue(changedDynamicRecords.containsAll(initialRecords)); assertEquals(initialRecords.Count + 1, changedDynamicRecords.Count); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSpillOverToDynamicRecordIfExceedsInlinedSpace() public virtual void ShouldSpillOverToDynamicRecordIfExceedsInlinedSpace() { // GIVEN -- the upper limit for a label ID for 3 labels would be 36b/3 - 1 = 12b - 1 = 4095 long labelId1 = 10; long labelId2 = 30; long labelId3 = 4096; NodeRecord node = NodeRecordWithInlinedLabels(labelId1, labelId2); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN ICollection <DynamicRecord> changedDynamicRecords = nodeLabels.Add(labelId3, _nodeStore, _nodeStore.DynamicLabelStore); // THEN assertEquals(1, Iterables.count(changedDynamicRecords)); assertEquals(DynamicLabelsLongRepresentation(changedDynamicRecords), node.LabelField); assertTrue(Arrays.Equals(new long[] { labelId1, labelId2, labelId3 }, DynamicNodeLabels.getDynamicLabelsArray(changedDynamicRecords, _nodeStore.DynamicLabelStore))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void removingNonExistentLabelInDynamicRecordsShouldFail() public virtual void RemovingNonExistentLabelInDynamicRecordsShouldFail() { // GIVEN long[] labels = OneByteLongs(20); NodeRecord node = nodeRecordWithDynamicLabels(_nodeStore, labels); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN try { nodeLabels.Remove(123456, _nodeStore); fail("Should have thrown exception"); } catch (System.InvalidOperationException) { // THEN } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addingAnAlreadyAddedLabelWhenLabelsAreInDynamicRecordsShouldFail() public virtual void AddingAnAlreadyAddedLabelWhenLabelsAreInDynamicRecordsShouldFail() { // GIVEN long[] labels = OneByteLongs(20); NodeRecord node = nodeRecordWithDynamicLabels(_nodeStore, labels); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN try { nodeLabels.Add(safeCastLongToInt(labels[0]), _nodeStore, _nodeStore.DynamicLabelStore); fail("Should have thrown exception"); } catch (System.InvalidOperationException) { // THEN } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addingAnAlreadyAddedLabelWhenLabelsAreInlinedShouldFail() public virtual void AddingAnAlreadyAddedLabelWhenLabelsAreInlinedShouldFail() { // GIVEN int labelId = 1; NodeRecord node = NodeRecordWithInlinedLabels(labelId); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN try { nodeLabels.Add(labelId, _nodeStore, _nodeStore.DynamicLabelStore); fail("Should have thrown exception"); } catch (System.InvalidOperationException) { // THEN } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void removingNonExistentInlinedLabelShouldFail() public virtual void RemovingNonExistentInlinedLabelShouldFail() { // GIVEN int labelId1 = 1; int labelId2 = 2; NodeRecord node = NodeRecordWithInlinedLabels(labelId1); NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node); // WHEN try { nodeLabels.Remove(labelId2, _nodeStore); fail("Should have thrown exception"); } catch (System.InvalidOperationException) { // THEN } }
public List <string> ValidationErrors() { var validationErrors = new List <string>(); if (IdPropertyName == null) { validationErrors.Add($"{nameof(IdPropertyName)} is null."); } if (IdPropertyValue == null) { validationErrors.Add($"{nameof(IdPropertyValue)} is null."); } if (!NodeLabels.Any()) { validationErrors.Add("At least one NodeLabel must be provided."); } return(validationErrors); }
/* * There was this issue that DynamicNodeLabels#add would consider even unused dynamic records when * reading existing label ids before making the change. Previously this would create a duplicate * last label id (the one formerly being in the second record). * * This randomized test found this issue every time when it existed and it will potentially find other * unforeseen issues as well. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleRandomAddsAndRemoves() public virtual void ShouldHandleRandomAddsAndRemoves() { // GIVEN ISet <int> key = new HashSet <int>(); NodeRecord node = new NodeRecord(0); node.InUse = true; // WHEN for (int i = 0; i < 100_000; i++) { NodeLabels labels = NodeLabelsField.parseLabelsField(node); int labelId = Random.Next(200); if (Random.nextBoolean()) { if (!key.Contains(labelId)) { labels.Add(labelId, _nodeStore, _nodeStore.DynamicLabelStore); key.Add(labelId); } } else { if (key.remove(labelId)) { labels.Remove(labelId, _nodeStore); } } } // THEN NodeLabels labels = NodeLabelsField.parseLabelsField(node); long[] readLabelIds = labels.Get(_nodeStore); foreach (long labelId in readLabelIds) { assertTrue("Found an unexpected label " + labelId, key.remove(( int )labelId)); } assertTrue(key.Count == 0); }