示例#1
0
 private void GatherPropsToLoad(SchemaDescriptor schema, MutableIntSet target)
 {
     foreach (int propertyId in Schema.PropertyIds)
     {
         if (_knownProperties.get(propertyId) == null)
         {
             target.add(propertyId);
         }
     }
 }
        public virtual int AugmentDegree(RelationshipDirection direction, int degree, int typeId)
        {
            switch (direction)
            {
            case RelationshipDirection.INCOMING:
                if (_incoming != null && _incoming.containsKey(typeId))
                {
                    return(_diffStrategy.augmentDegree(degree, _incoming.get(typeId).size()));
                }
                break;

            case RelationshipDirection.OUTGOING:
                if (_outgoing != null && _outgoing.containsKey(typeId))
                {
                    return(_diffStrategy.augmentDegree(degree, _outgoing.get(typeId).size()));
                }
                break;

            case RelationshipDirection.LOOP:
                if (_loops != null && _loops.containsKey(typeId))
                {
                    return(_diffStrategy.augmentDegree(degree, _loops.get(typeId).size()));
                }
                break;

            default:
                throw new System.ArgumentException("Unknown direction: " + direction);
            }

            return(degree);
        }
 /// <param name="schemaDescriptor"> <seealso cref="SchemaDescriptor"/> to remove. </param>
 /// <param name="propertyKeyIds"> the sorted property key ids for this schema. </param>
 /// <param name="cursor"> which property key among the sorted property keys that this set deals with. </param>
 /// <returns> {@code true} if this <seealso cref="PropertySet"/> ends up empty after this removal. </returns>
 internal virtual bool Remove(T schemaDescriptor, int[] propertyKeyIds, int cursor)
 {
     if (cursor == propertyKeyIds.Length - 1)
     {
         FullDescriptors.remove(schemaDescriptor);
     }
     else
     {
         int         nextPropertyKeyId = propertyKeyIds[++cursor];
         PropertySet propertySet       = Next.get(nextPropertyKeyId);
         if (propertySet != null && propertySet.Remove(schemaDescriptor, propertyKeyIds, cursor))
         {
             Next.remove(nextPropertyKeyId);
         }
     }
     return(FullDescriptors.Count == 0 && Next.Empty);
 }
            /// <summary>
            /// Removes the <seealso cref="SchemaDescriptor"/> from this multi-set. </summary>
            /// <param name="schemaDescriptor"> the <seealso cref="SchemaDescriptor"/> to remove. </param>
            /// <returns> {@code true} if this multi-set ended up empty after removing this descriptor. </returns>
            internal virtual bool Remove(T schemaDescriptor)
            {
                // Remove from the optimized path
                Descriptors.remove(schemaDescriptor);
                int[] propertyKeyIds = SortedPropertyKeyIds(schemaDescriptor.schema());
                [email protected]_PropertySchemaType propertySchemaType = schemaDescriptor.schema().propertySchemaType();
                if (propertySchemaType == COMPLETE_ALL_TOKENS)
                {
                    int         firstPropertyKeyId = propertyKeyIds[0];
                    PropertySet firstPropertySet   = Next.get(firstPropertyKeyId);
                    if (firstPropertySet != null && firstPropertySet.Remove(schemaDescriptor, propertyKeyIds, 0))
                    {
                        Next.remove(firstPropertyKeyId);
                    }
                }
                else if (propertySchemaType == PARTIAL_ANY_TOKEN)
                {
                    foreach (int propertyKeyId in propertyKeyIds)
                    {
                        PropertySet propertySet = Next.get(propertyKeyId);
                        if (propertySet != null && propertySet.Remove(schemaDescriptor, new int[] { propertyKeyId }, 0))
                        {
                            Next.remove(propertyKeyId);
                        }
                    }
                }
                else
                {
                    throw new System.NotSupportedException("Unknown property schema type " + propertySchemaType);
                }

                // Remove from the fall-back path
                foreach (int keyId in propertyKeyIds)
                {
                    ISet <T> byProperty = ByAnyProperty.get(keyId);
                    if (byProperty != null)
                    {
                        byProperty.remove(schemaDescriptor);
                        if (byProperty.Count == 0)
                        {
                            ByAnyProperty.remove(keyId);
                        }
                    }
                }
                return(Descriptors.Count == 0 && Next.Empty);
            }
        /// <summary>
        /// Cheap way of finding out whether or not there are any descriptors matching the set of entity token ids and the property key id.
        /// </summary>
        /// <param name="entityTokenIds"> complete list of entity token ids for the entity to check. </param>
        /// <param name="propertyKey"> a property key id to check. </param>
        /// <returns> {@code true} if there are one or more descriptors matching the given tokens. </returns>
        internal virtual bool Has(long[] entityTokenIds, int propertyKey)
        {
            // Abort right away if there are no descriptors at all
            if (Empty)
            {
                return(false);
            }

            // Check if there are any descriptors that matches any of the first (or only) entity token
            foreach (long entityTokenId in entityTokenIds)
            {
                PropertyMultiSet set = _byEntityToken.get(toIntExact(entityTokenId));
                if (set != null && set.Has(propertyKey))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#6
0
 private static void RecordConstraint(int labelOrRelType, int propertyKey, MutableIntObjectMap <int[]> storage)
 {
     int[] propertyKeys = storage.get(labelOrRelType);
     if (propertyKeys == null)
     {
         propertyKeys = new int[] { propertyKey };
     }
     else
     {
         propertyKeys = Arrays.copyOf(propertyKeys, propertyKeys.Length + 1);
         propertyKeys[propertyKeys.Length - 1] = propertyKey;
     }
     storage.put(labelOrRelType, propertyKeys);
 }
        public virtual bool RemoveRelationship(long relId, int typeId, RelationshipDirection direction)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableIntObjectMap<org.eclipse.collections.api.set.primitive.MutableLongSet> relTypeToRelsMap = getTypeToRelMapForDirection(direction);
            MutableIntObjectMap <MutableLongSet> relTypeToRelsMap = GetTypeToRelMapForDirection(direction);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet rels = relTypeToRelsMap.get(typeId);
            MutableLongSet rels = relTypeToRelsMap.get(typeId);

            if (rels != null && rels.remove(relId))
            {
                if (rels.Empty)
                {
                    relTypeToRelsMap.remove(typeId);
                }
                return(true);
            }
            return(false);
        }
示例#8
0
            internal virtual IEnumerator <CapableIndexDescriptor> IndexDescriptorsForRelationshipType(int relationshipType)
            {
                ISet <CapableIndexDescriptor> forLabel = IndexDescriptorsByRelationshipType.get(relationshipType);

                return(forLabel == null?emptyIterator() : forLabel.GetEnumerator());
            }
示例#9
0
            internal virtual IEnumerator <CapableIndexDescriptor> IndexDescriptorsForLabel(int labelId)
            {
                ISet <CapableIndexDescriptor> forLabel = IndexDescriptorsByLabel.get(labelId);

                return(forLabel == null?emptyIterator() : forLabel.GetEnumerator());
            }
示例#10
0
            internal virtual IEnumerator <CapableIndexDescriptor> IndexesByProperty(int propertyId)
            {
                IList <CapableIndexDescriptor> indexes = IndexByProperty.get(propertyId);

                return((indexes == null) ? emptyIterator() : indexes.GetEnumerator());
            }
示例#11
0
 internal virtual ICollection <Hit> Least()
 {
     return(HitsConflict.get(LowestDepth));
 }
示例#12
0
        private Value[] GetValueTuple(NodeCursor node, PropertyCursor propertyCursor, int changedPropertyKeyId, Value changedValue, int[] indexPropertyIds, MutableIntObjectMap <Value> materializedValues)
        {
            Value[] values  = new Value[indexPropertyIds.Length];
            int     missing = 0;

            // First get whatever values we already have on the stack, like the value change that provoked this update in the first place
            // and already loaded values that we can get from the map of materialized values.
            for (int k = 0; k < indexPropertyIds.Length; k++)
            {
                values[k] = indexPropertyIds[k] == changedPropertyKeyId ? changedValue : materializedValues.get(indexPropertyIds[k]);
                if (values[k] == null)
                {
                    missing++;
                }
            }

            // If we couldn't get all values that we wanted we need to load from the node. While we're loading values
            // we'll place those values in the map so that other index updates from this change can just used them.
            if (missing > 0)
            {
                node.Properties(propertyCursor);
                while (missing > 0 && propertyCursor.Next())
                {
                    int k = ArrayUtils.IndexOf(indexPropertyIds, propertyCursor.PropertyKey());
                    if (k >= 0 && values[k] == null)
                    {
                        int  propertyKeyId            = indexPropertyIds[k];
                        bool thisIsTheChangedProperty = propertyKeyId == changedPropertyKeyId;
                        values[k] = thisIsTheChangedProperty ? changedValue : propertyCursor.PropertyValue();
                        if (!thisIsTheChangedProperty)
                        {
                            materializedValues.put(propertyKeyId, values[k]);
                        }
                        missing--;
                    }
                }
            }

            return(values);
        }