public override void AcquireShared(LockTracer tracer, ResourceType resourceType, params long[] resourceIds) { _stateHolder.incrementActiveClients(this); try { MutableLongObjectMap <LockResource> localLocks = LocalShared(resourceType); foreach (long resourceId in resourceIds) { LockResource resource = localLocks.get(resourceId); if (resource != null) { resource.AcquireReference(); } else { resource = new LockResource(resourceType, resourceId); if (_manager.getReadLock(tracer, resource, _lockTransaction)) { localLocks.put(resourceId, resource); } else { throw new LockClientStoppedException(this); } } } } finally { _stateHolder.decrementActiveClients(); } }
public override bool TrySharedLock(ResourceType resourceType, long resourceId) { _stateHolder.incrementActiveClients(this); try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableLongObjectMap<LockResource> localLocks = localShared(resourceType); MutableLongObjectMap <LockResource> localLocks = LocalShared(resourceType); LockResource resource = localLocks.get(resourceId); if (resource != null) { resource.AcquireReference(); return(true); } else { resource = new LockResource(resourceType, resourceId); if (_manager.tryReadLock(resource, _lockTransaction)) { localLocks.put(resourceId, resource); return(true); } else { return(false); } } } finally { _stateHolder.decrementActiveClients(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @VisibleForTesting NodeStateImpl getOrCreateNodeState(long nodeId) internal virtual NodeStateImpl GetOrCreateNodeState(long nodeId) { if (_nodeStatesMap == null) { _nodeStatesMap = new LongObjectHashMap <NodeStateImpl>(); } return(_nodeStatesMap.getIfAbsentPut(nodeId, () => new NodeStateImpl(nodeId, _collectionsFactory))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @VisibleForTesting MutableLongDiffSets getOrCreateLabelStateNodeDiffSets(long labelId) internal virtual MutableLongDiffSets GetOrCreateLabelStateNodeDiffSets(long labelId) { if (_labelStatesMap == null) { _labelStatesMap = new LongObjectHashMap <MutableLongDiffSets>(); } return(_labelStatesMap.getIfAbsentPut(labelId, () => new MutableLongDiffSetsImpl(_collectionsFactory))); }
private RelationshipStateImpl GetOrCreateRelationshipState(long relationshipId) { if (_relationshipStatesMap == null) { _relationshipStatesMap = new LongObjectHashMap <RelationshipStateImpl>(); } return(_relationshipStatesMap.getIfAbsentPut(relationshipId, () => new RelationshipStateImpl(relationshipId, _collectionsFactory))); }
public override void RelationshipTypeDoCreateForName(string labelName, int id) { if (_createdRelationshipTypeTokens == null) { _createdRelationshipTypeTokens = new LongObjectHashMap <string>(); } _createdRelationshipTypeTokens.put(id, labelName); Changed(); }
public override void PropertyKeyDoCreateForName(string propertyKeyName, int id) { if (_createdPropertyKeyTokens == null) { _createdPropertyKeyTokens = new LongObjectHashMap <string>(); } _createdPropertyKeyTokens.put(id, propertyKeyName); Changed(); }
public override void LabelDoCreateForName(string labelName, long id) { if (_createdLabelTokens == null) { _createdLabelTokens = new LongObjectHashMap <string>(); } _createdLabelTokens.put(id, labelName); Changed(); }
public RecordChange(MutableLongObjectMap <RecordAccess_RecordProxy <RECORD, ADDITIONAL> > allChanges, IntCounter changeCounter, long key, RECORD record, RecordAccess_Loader <RECORD, ADDITIONAL> loader, bool created, ADDITIONAL additionalData) { this.AllChanges = allChanges; this.ChangeCounter = changeCounter; this.KeyConflict = key; this.Record = record; this.Loader = loader; this.CreatedConflict = created; this.AdditionalDataConflict = additionalData; }
public override void Close() { if (_recordChanges.size() <= 32) { _recordChanges.clear(); } else { // Let's not allow the internal maps to grow too big over time. _recordChanges = new LongObjectHashMap <RecordAccess_RecordProxy <RECORD, ADDITIONAL> >(); } _changeCounter.clear(); }
private void Put(int count, ValuesMap actualMap, MutableLongObjectMap <Value> expectedMap) { for (int i = 0; i < count * 2; i++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long key = rnd.nextLong(count); long key = _rnd.nextLong(count); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.values.storable.Value value = rnd.randomValues().nextValue(); Value value = _rnd.randomValues().nextValue(); actualMap.Put(key, value); expectedMap.put(key, value); } }
internal virtual void AddProperty(int propertyKeyId, Value value) { if (_removedProperties != null && _removedProperties.remove(propertyKeyId)) { // This indicates the user did remove+add as two discrete steps, which should be translated to // a single change operation. ChangeProperty(propertyKeyId, value); return; } if (_addedProperties == null) { _addedProperties = CollectionsFactory.newValuesMap(); } _addedProperties.put(propertyKeyId, value); }
internal SchemaCacheState(ConstraintSemantics constraintSemantics, IEnumerable <SchemaRule> rules, IndexProviderMap indexProviderMap) { this.ConstraintSemantics = constraintSemantics; this.IndexProviderMap = indexProviderMap; this.ConstraintsConflict = new HashSet <ConstraintDescriptor>(); this.IndexDescriptorById = new LongObjectHashMap <CapableIndexDescriptor>(); this.ConstraintRuleById = new LongObjectHashMap <ConstraintRule>(); this.IndexDescriptorsConflict = new Dictionary <SchemaDescriptor, CapableIndexDescriptor>(); this.IndexDescriptorsByLabel = new IntObjectHashMap <ISet <CapableIndexDescriptor> >(); this.IndexDescriptorsByRelationshipType = new IntObjectHashMap <ISet <CapableIndexDescriptor> >(); this.IndexDescriptorsByName = new Dictionary <string, CapableIndexDescriptor>(); this.DependantState = new ConcurrentDictionary <Type, object>(); this.IndexByProperty = new IntObjectHashMap <IList <CapableIndexDescriptor> >(); Load(rules); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void randomizedWithSharedValuesContainer() internal virtual void RandomizedWithSharedValuesContainer() { const int maps = 13; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int COUNT = 10000 + rnd.nextInt(1000); int count = 10000 + _rnd.Next(1000); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final AppendOnlyValuesContainer valuesContainer = new AppendOnlyValuesContainer(new TestMemoryAllocator()); AppendOnlyValuesContainer valuesContainer = new AppendOnlyValuesContainer(new TestMemoryAllocator()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<ValuesMap> actualMaps = new java.util.ArrayList<>(); IList <ValuesMap> actualMaps = new List <ValuesMap>(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<org.eclipse.collections.api.map.primitive.MutableLongObjectMap<org.neo4j.values.storable.Value>> expectedMaps = new java.util.ArrayList<>(); IList <MutableLongObjectMap <Value> > expectedMaps = new List <MutableLongObjectMap <Value> >(); for (int i = 0; i < maps; i++) { actualMaps.Add(NewMap(valuesContainer)); expectedMaps.Add(new LongObjectHashMap <>()); } for (int i = 0; i < maps; i++) { Put(count, actualMaps[i], expectedMaps[i]); } for (int i = 0; i < maps; i++) { Remove(count, actualMaps[i], expectedMaps[i]); } for (int i = 0; i < maps; i++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableLongObjectMap<org.neo4j.values.storable.Value> expected = expectedMaps.get(i); MutableLongObjectMap <Value> expected = expectedMaps[i]; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final ValuesMap actual = actualMaps.get(i); ValuesMap actual = actualMaps[i]; expected.forEachKeyValue((k, v) => assertEquals(v, actual.Get(k))); } }
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 IndexMap(MutableLongObjectMap <IndexProxy> indexesById, IDictionary <SchemaDescriptor, IndexProxy> indexesByDescriptor, MutableObjectLongMap <SchemaDescriptor> indexIdsByDescriptor, MutableLongObjectMap <IndexBackedConstraintDescriptor> uniquenessConstraintsById) { this._indexesById = indexesById; this._indexesByDescriptor = indexesByDescriptor; this._indexIdsByDescriptor = indexIdsByDescriptor; this._uniquenessConstraintsById = uniquenessConstraintsById; this._descriptorsByLabelThenProperty = new SchemaDescriptorLookupSet <SchemaDescriptor>(); this._descriptorsByReltypeThenProperty = new SchemaDescriptorLookupSet <SchemaDescriptor>(); foreach (SchemaDescriptor schema in indexesByDescriptor.Keys) { AddDescriptorToLookups(schema); } this._constraintsByLabelThenProperty = new SchemaDescriptorLookupSet <IndexBackedConstraintDescriptor>(); this._constraintsByRelTypeThenProperty = new SchemaDescriptorLookupSet <IndexBackedConstraintDescriptor>(); foreach (IndexBackedConstraintDescriptor constraint in uniquenessConstraintsById.values()) { AddConstraintToLookups(constraint); } }
internal virtual void ChangeProperty(int propertyKeyId, Value value) { if (_addedProperties != null && _addedProperties.containsKey(propertyKeyId)) { _addedProperties.put(propertyKeyId, value); return; } if (_changedProperties == null) { _changedProperties = CollectionsFactory.newValuesMap(); } _changedProperties.put(propertyKeyId, value); if (_removedProperties != null) { _removedProperties.remove(propertyKeyId); } }
public override void ReleaseExclusive(ResourceType resourceType, params long[] resourceIds) { _stateHolder.incrementActiveClients(this); try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableLongObjectMap<LockResource> localLocks = localExclusive(resourceType); MutableLongObjectMap <LockResource> localLocks = LocalExclusive(resourceType); foreach (long resourceId in resourceIds) { LockResource resource = localLocks.get(resourceId); if (resource.ReleaseReference() == 0) { localLocks.remove(resourceId); _manager.releaseWriteLock(new LockResource(resourceType, resourceId), _lockTransaction); } } } finally { _stateHolder.decrementActiveClients(); } }