private void Put(int propertyKeyId, PropertyValue propertyValue) { PropertyValue existing = _knownProperties.put(propertyKeyId, propertyValue); if (existing == null) { if (_propertyKeyIdsCursor >= _propertyKeyIds.Length) { _propertyKeyIds = Arrays.copyOf(_propertyKeyIds, _propertyKeyIdsCursor * 2); } _propertyKeyIds[_propertyKeyIdsCursor++] = propertyKeyId; } }
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); }
internal SchemaCacheState(SchemaCacheState schemaCacheState) { this.ConstraintSemantics = schemaCacheState.ConstraintSemantics; this.IndexDescriptorById = LongObjectHashMap.newMap(schemaCacheState.IndexDescriptorById); this.ConstraintRuleById = LongObjectHashMap.newMap(schemaCacheState.ConstraintRuleById); this.ConstraintsConflict = new HashSet <ConstraintDescriptor>(schemaCacheState.ConstraintsConflict); this.IndexDescriptorsConflict = new Dictionary <SchemaDescriptor, CapableIndexDescriptor>(schemaCacheState.IndexDescriptorsConflict); this.IndexDescriptorsByLabel = new IntObjectHashMap <ISet <CapableIndexDescriptor> >(schemaCacheState.IndexDescriptorsByLabel.size()); schemaCacheState.IndexDescriptorsByLabel.forEachKeyValue((k, v) => IndexDescriptorsByLabel.put(k, new HashSet <>(v))); this.IndexDescriptorsByRelationshipType = new IntObjectHashMap <ISet <CapableIndexDescriptor> >(schemaCacheState.IndexDescriptorsByRelationshipType.size()); schemaCacheState.IndexDescriptorsByRelationshipType.forEachKeyValue((k, v) => IndexDescriptorsByRelationshipType.put(k, new HashSet <>(v))); this.IndexDescriptorsByName = new Dictionary <string, CapableIndexDescriptor>(schemaCacheState.IndexDescriptorsByName); this.DependantState = new ConcurrentDictionary <Type, object>(); this.IndexByProperty = new IntObjectHashMap <IList <CapableIndexDescriptor> >(schemaCacheState.IndexByProperty.size()); schemaCacheState.IndexByProperty.forEachKeyValue((k, v) => IndexByProperty.put(k, new List <>(v))); this.IndexProviderMap = schemaCacheState.IndexProviderMap; }
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); }
private int GetOrAssignId(MutableObjectIntMap <string> stringToId, MutableIntObjectMap <string> idToString, AtomicInteger nextId, string @string) { if (string.ReferenceEquals(@string, null)) { return(-1); } if (stringToId.containsKey(@string)) { return(stringToId.get(@string)); } int id = nextId.incrementAndGet(); if (id > HighestPossibleId || stringToId.size() >= HighestPossibleId) { throw new System.InvalidOperationException(format("Modifying more than %d indexes or keys in a single transaction is not supported", HighestPossibleId + 1)); } stringToId.put(@string, id); idToString.put(id, @string); return(id); }