//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAccessRelationshipLabels() public virtual void ShouldAccessRelationshipLabels() { // given IDictionary <int, int> counts = new Dictionary <int, int>(); using (RelationshipScanCursor relationships = cursors.allocateRelationshipScanCursor()) { // when read.allRelationshipsScan(relationships); while (relationships.Next()) { Counts.compute(relationships.Type(), (k, v) => v == null ? 1 : v + 1); } } // then assertEquals(3, Counts.Count); int[] values = new int[3]; int i = 0; foreach (int value in Counts.Values) { values[i++] = value; } Arrays.sort(values); assertArrayEquals(new int[] { 1, 6, 6 }, values); }
private void ScanEverythingBelongingToRelationships(RelationshipMappings relMappings) { using (RelationshipScanCursor relationshipScanCursor = _cursors.allocateRelationshipScanCursor(), PropertyCursor propertyCursor = _cursors.allocatePropertyCursor()) { _dataRead.allRelationshipsScan(relationshipScanCursor); while (relationshipScanCursor.Next()) { int typeId = relationshipScanCursor.Type(); relationshipScanCursor.Properties(propertyCursor); MutableIntSet propertyIds = IntSets.mutable.empty(); while (propertyCursor.Next()) { int propertyKey = propertyCursor.PropertyKey(); Value currentValue = propertyCursor.PropertyValue(); Pair <int, int> key = Pair.of(typeId, propertyKey); UpdateValueTypeInMapping(currentValue, key, relMappings.RelationshipTypeIdANDPropertyTypeIdToValueType); propertyIds.add(propertyKey); } propertyCursor.Close(); MutableIntSet oldPropertyKeySet = relMappings.RelationshipTypeIdToPropertyKeys.getOrDefault(typeId, _emptyPropertyIdSet); // find out which old properties we did not visited and mark them as nullable if (oldPropertyKeySet == _emptyPropertyIdSet) { if (propertyIds.size() == 0) { // Even if we find property key on other rels with this type, set all of them nullable relMappings.NullableRelationshipTypes.Add(typeId); } propertyIds.addAll(oldPropertyKeySet); } else { MutableIntSet currentPropertyIdsHelperSet = new IntHashSet(propertyIds.size()); currentPropertyIdsHelperSet.addAll(propertyIds); propertyIds.removeAll(oldPropertyKeySet); // only the brand new ones in propIds now oldPropertyKeySet.removeAll(currentPropertyIdsHelperSet); // only the old ones that are not on the new rel propertyIds.addAll(oldPropertyKeySet); propertyIds.forEach(id => { Pair <int, int> key = Pair.of(typeId, id); relMappings.RelationshipTypeIdANDPropertyTypeIdToValueType[key].setNullable(); }); propertyIds.addAll(currentPropertyIdsHelperSet); } relMappings.RelationshipTypeIdToPropertyKeys[typeId] = propertyIds; } relationshipScanCursor.Close(); } }
public virtual bool InitializeData() { // It enough to check only start node, since it's absence will indicate that data was not yet loaded. if (_startNode == AbstractBaseRecord.NO_ID) { KernelTransaction transaction = _spi.kernelTransaction(); using (Statement ignore = transaction.AcquireStatement()) { RelationshipScanCursor relationships = transaction.AmbientRelationshipCursor(); transaction.DataRead().singleRelationship(_id, relationships); // At this point we don't care if it is there or not just load what we got. bool wasPresent = relationships.Next(); this._type = relationships.Type(); this._startNode = relationships.SourceNodeReference(); this._endNode = relationships.TargetNodeReference(); // But others might care, e.g. the Bolt server needs to know for serialisation purposes. return(wasPresent); } } return(true); }