//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDefragmentRelationshipGroupsWhenSomeDense() public virtual void ShouldDefragmentRelationshipGroupsWhenSomeDense() { // GIVEN some nodes which has their groups scattered int nodeCount = 100; int relationshipTypeCount = 50; RecordStore <RelationshipGroupRecord> groupStore = _stores.TemporaryRelationshipGroupStore; RelationshipGroupRecord groupRecord = groupStore.NewRecord(); RecordStore <NodeRecord> nodeStore = _stores.NodeStore; NodeRecord nodeRecord = nodeStore.NewRecord(); long cursor = 0; BitArray initializedNodes = new BitArray(); for (int typeId = relationshipTypeCount - 1; typeId >= 0; typeId--) { for (int nodeId = 0; nodeId < nodeCount; nodeId++, cursor++) { // Reasoning behind this thing is that we want to have roughly 10% of the nodes dense // right from the beginning and then some stray dense nodes coming into this in the // middle of the type range somewhere double comparison = typeId == 0 || initializedNodes.Get(nodeId) ? 0.1 : 0.001; if (_random.NextDouble() < comparison) { // next doesn't matter at all, as we're rewriting it anyway // firstOut/In/Loop we could use in verification phase later groupRecord.Initialize(true, typeId, cursor, cursor + 1, cursor + 2, nodeId, 4); groupRecord.Id = groupStore.nextId(); groupStore.UpdateRecord(groupRecord); if (!initializedNodes.Get(nodeId)) { nodeRecord.Initialize(true, -1, true, groupRecord.Id, 0); nodeRecord.Id = nodeId; nodeStore.UpdateRecord(nodeRecord); nodeStore.HighestPossibleIdInUse = nodeId; initializedNodes.Set(nodeId, true); } } } } // WHEN Defrag(nodeCount, groupStore); // THEN all groups should sit sequentially in the store VerifyGroupsAreSequentiallyOrderedByNode(); }
private void RandomModifications(IList <Pair <long, Label[]> > existingNodes, int numberOfModifications) { for (int i = 0; i < numberOfModifications; i++) { double selectModification = Random.NextDouble(); if (existingNodes.Count < NODE_COUNT_BASELINE || selectModification >= DELETE_RATIO + UPDATE_RATIO) { CreateNewNode(existingNodes); } else if (selectModification < DELETE_RATIO) { DeleteExistingNode(existingNodes); } else { ModifyLabelsOnExistingNode(existingNodes); } } }
/// <summary> /// This test verify that we correctly handle unique points that all belong to the same tile on the space filling curve. /// All points share at least one dimension coordinate with another point to exercise minimal splitter. /// We verify this by asserting that we always get exactly one hit on an exact match and that the value is what we expect. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustHandlePointsWithinSameTile() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException, org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MustHandlePointsWithinSameTile() { // given // Many random points that all are close enough to each other to belong to the same tile on the space filling curve. int nbrOfValues = 10000; PointValue origin = Values.pointValue(WGS84, 0.0, 0.0); long? derivedValueForCenterPoint = _curve.derivedValueFor(origin.Coordinate()); double[] centerPoint = _curve.centerPointFor(derivedValueForCenterPoint.Value); double xWidthMultiplier = _curve.getTileWidth(0, _curve.MaxLevel) / 2; double yWidthMultiplier = _curve.getTileWidth(1, _curve.MaxLevel) / 2; IList <Value> pointValues = new List <Value>(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = new java.util.ArrayList<>(); IList <IndexEntryUpdate <object> > updates = new List <IndexEntryUpdate <object> >(); long nodeId = 1; for (int i = 0; i < nbrOfValues / 4; i++) { double x1 = (_random.NextDouble() * 2 - 1) * xWidthMultiplier; double x2 = (_random.NextDouble() * 2 - 1) * xWidthMultiplier; double y1 = (_random.NextDouble() * 2 - 1) * yWidthMultiplier; double y2 = (_random.NextDouble() * 2 - 1) * yWidthMultiplier; PointValue value11 = Values.pointValue(WGS84, centerPoint[0] + x1, centerPoint[1] + y1); PointValue value12 = Values.pointValue(WGS84, centerPoint[0] + x1, centerPoint[1] + y2); PointValue value21 = Values.pointValue(WGS84, centerPoint[0] + x2, centerPoint[1] + y1); PointValue value22 = Values.pointValue(WGS84, centerPoint[0] + x2, centerPoint[1] + y2); AssertDerivedValue(derivedValueForCenterPoint, value11, value12, value21, value22); nodeId = AddPointsToLists(pointValues, updates, nodeId, value11, value12, value21, value22); } ProcessAll(updates); // then ExactMatchOnAllValues(pointValues); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { _ratioToKeepInLeftOnSplit = Random.nextBoolean() ? InternalTreeLogic.DEFAULT_SPLIT_RATIO : Random.NextDouble(); }