Exemple #1
0
        private void ScanEverythingBelongingToNodes(NodeMappings nodeMappings)
        {
            using (NodeCursor nodeCursor = _cursors.allocateNodeCursor(), PropertyCursor propertyCursor = _cursors.allocatePropertyCursor())
            {
                _dataRead.allNodesScan(nodeCursor);
                while (nodeCursor.Next())
                {
                    // each node
                    SortedLabels labels = SortedLabels.From(nodeCursor.Labels());
                    nodeCursor.Properties(propertyCursor);
                    MutableIntSet propertyIds = IntSets.mutable.empty();

                    while (propertyCursor.Next())
                    {
                        Value currentValue           = propertyCursor.PropertyValue();
                        int   propertyKeyId          = propertyCursor.PropertyKey();
                        Pair <SortedLabels, int> key = Pair.of(labels, propertyKeyId);
                        UpdateValueTypeInMapping(currentValue, key, nodeMappings.LabelSetANDNodePropertyKeyIdToValueType);

                        propertyIds.add(propertyKeyId);
                    }
                    propertyCursor.Close();

                    MutableIntSet oldPropertyKeySet = nodeMappings.LabelSetToPropertyKeys.getOrDefault(labels, _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 nodes with those labels, set all of them nullable
                            nodeMappings.NullableLabelSets.Add(labels);
                        }

                        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 node

                        propertyIds.addAll(oldPropertyKeySet);
                        propertyIds.forEach(id =>
                        {
                            Pair <SortedLabels, int> key = Pair.of(labels, id);
                            nodeMappings.LabelSetANDNodePropertyKeyIdToValueType[key].setNullable();
                        });

                        propertyIds.addAll(currentPropertyIdsHelperSet);
                    }

                    nodeMappings.LabelSetToPropertyKeys[labels] = propertyIds;
                }
                nodeCursor.Close();
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testHashCodeOfLabelSet()
        internal virtual void TestHashCodeOfLabelSet()
        {
            long[]       longsA = new long[] { 1L, 2L, 3L };
            long[]       longsB = new long[] { 3L, 2L, 1L };
            long[]       longsC = new long[] { 1L, 2L, 3L, 4L };
            SortedLabels a      = SortedLabels.From(longsA);
            SortedLabels b      = SortedLabels.From(longsB);
            SortedLabels c      = SortedLabels.From(longsC);

            assertEquals(a.GetHashCode(), b.GetHashCode());
            assertNotEquals(a.GetHashCode(), c.GetHashCode());
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testEquals()
        internal virtual void TestEquals()
        {
            long[]       longsA = new long[] { 1L, 2L, 3L };
            long[]       longsB = new long[] { 3L, 2L, 1L };
            long[]       longsC = new long[] { 1L, 2L, 3L, 4L };
            SortedLabels a      = SortedLabels.From(longsA);
            SortedLabels b      = SortedLabels.From(longsB);
            SortedLabels c      = SortedLabels.From(longsC);

            // self
            //noinspection EqualsWithItself
            assertEquals(a, a);

            // unordered self
            assertEquals(a, b);
            assertEquals(b, a);

            // other
            assertNotEquals(a, c);
            assertNotEquals(c, a);
        }