public override void LoadProperties(long entityId, EntityType type, MutableIntSet propertyIds, PropertyLoadSink sink) { PrimitiveRecord entity; if (type == EntityType.NODE) { entity = NodeStore.getRecord(entityId, NodeStore.newRecord(), FORCE); } else { entity = RelationshipStore.getRecord(entityId, RelationshipStore.newRecord(), FORCE); } if (!entity.InUse()) { return; } long firstPropertyId = entity.NextProp; if (firstPropertyId == Record.NO_NEXT_PROPERTY.intValue()) { return; } foreach (PropertyRecord propertyRecord in PropertyStore.getPropertyRecordChain(firstPropertyId)) { foreach (PropertyBlock block in propertyRecord) { int currentPropertyId = block.KeyIndexId; if (propertyIds.remove(currentPropertyId)) { Value currentValue = block.Type.value(block, PropertyStore); sink.onProperty(currentPropertyId, currentValue); } } } }
public void when_set_is_empty_popany_is_not_applicable(IntSet set) { Assume.That(set.IsEmpty); MutableIntSet editedSet = set.EditCopy(); int value = editedSet.PopAny(); }
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(); } }
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(); } }
public void AddFirst(DotItem item, MutableIntSet output) { bool isNullable = tables.AddFirst(item.GetPattern(), item.Position, output); if (isNullable) { output.AddAll(item.LA); } }
internal RealCheck(RECORD record, Type reportClass, ConsistencyReporter reporter, RecordType recordType, MutableIntSet mandatoryKeys) { reportClass = typeof(REPORT); this.Record = record; this.ReportClass = reportClass; this.Reporter = reporter; this.RecordType = recordType; this.MandatoryKeys = mandatoryKeys; }
private void GatherPropsToLoad(SchemaDescriptor schema, MutableIntSet target) { foreach (int propertyId in Schema.PropertyIds) { if (_knownProperties.get(propertyId) == null) { target.add(propertyId); } } }
public void set_has_correct_content_after_removing_value(IntSet set, int value) { MutableIntSet editedSet = set.EditCopy(); int initialCount = editedSet.Count; editedSet.Remove(value); int finalCount = editedSet.Count; Assert.IsFalse(editedSet.Contains(value)); Assert.IsTrue(finalCount == initialCount || finalCount + 1 == initialCount); }
public void set_has_correct_content_after_adding_set(IntSet set, IntSet other) { MutableIntSet editedSet = set.EditCopy(); editedSet.AddAll(other); Assert.IsTrue(editedSet.IsSupersetOf(other)); Assert.IsTrue(set.Union(other).SetEquals(editedSet)); IntSet result = editedSet.CompleteAndDestroy(); Assert.IsTrue(result.IsSupersetOf(other)); Assert.IsTrue(set.Union(other).SetEquals(result)); }
public void set_has_correct_content_after_popany_value(IntSet set) { Assume.That(!set.IsEmpty); MutableIntSet editedSet = set.EditCopy(); int initialCount = editedSet.Count; int value = editedSet.PopAny(); int finalCount = editedSet.Count; Assert.IsFalse(editedSet.Contains(value)); Assert.AreEqual(initialCount, finalCount + 1); }
private void LoadProperties(PropertyLoader propertyLoader, MutableIntSet additionalPropertiesToLoad, EntityType type) { _hasLoadedAdditionalProperties = true; propertyLoader.LoadProperties(_entityId, type, additionalPropertiesToLoad, this); // loadProperties removes loaded properties from the input set, so the remaining ones were not on the node //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.iterator.IntIterator propertiesWithNoValue = additionalPropertiesToLoad.intIterator(); IntIterator propertiesWithNoValue = additionalPropertiesToLoad.intIterator(); while (propertiesWithNoValue.hasNext()) { Put(propertiesWithNoValue.next(), _noValue); } }
public void addall_with_set_of_different_size(IntSet set) { var otherSetType = new BitSetType(10); var other = otherSetType.Of(2, 5, 9); MutableIntSet editedSet = set.EditCopy(); editedSet.AddAll(other); Assert.IsTrue(editedSet.IsSupersetOf(other)); Assert.IsTrue(set.Union(other).SetEquals(editedSet)); IntSet result = editedSet.CompleteAndDestroy(); Assert.IsTrue(result.IsSupersetOf(other)); Assert.IsTrue(set.Union(other).SetEquals(result)); }
public void set_has_correct_content_after_adding_value(IntSet set, int value) { MutableIntSet editedSet = set.EditCopy(); Assert.AreEqual(set.Contains(value), editedSet.Contains(value)); editedSet.Add(value); Assert.IsTrue(editedSet.Contains(value)); Assert.IsTrue(editedSet.Contains(value)); Assert.IsTrue(set.Union(IntSet.Of(value)).SetEquals(editedSet)); IntSet result = editedSet.CompleteAndDestroy(); Assert.IsTrue(result.Contains(value)); Assert.IsTrue(set.IsSubsetOf(result)); Assert.IsTrue(set.Union(IntSet.Of(value)).SetEquals(result)); }
private int[] RandomUniqueUnsortedIntArray(int maxValue, int length) { int[] array = new int[length]; MutableIntSet seen = IntSets.mutable.empty(); for (int i = 0; i < length; i++) { int candidate; do { candidate = _random.Next(maxValue); } while (!seen.add(candidate)); array[i] = candidate; } return(array); }
private IList <NodePropertySchemaInfoResult> ProduceResultsForNodes(NodeMappings nodeMappings) { IList <NodePropertySchemaInfoResult> results = new List <NodePropertySchemaInfoResult>(); foreach (SortedLabels labelSet in nodeMappings.LabelSetToPropertyKeys.Keys) { // lookup label names and produce list of names and produce String out of them IList <string> labelNames = new List <string>(); for (int i = 0; i < labelSet.NumberOfLabels(); i++) { string name = nodeMappings.LabelIdToLabelName[labelSet.Label(i)]; labelNames.Add(name); } labelNames.Sort(); // this is optional but waaaaay nicer StringBuilder labelsConcatenator = new StringBuilder(); foreach (string item in labelNames) { labelsConcatenator.Append(":`").Append(item).Append("`"); } string labels = labelsConcatenator.ToString(); // lookup property value types MutableIntSet propertyIds = nodeMappings.LabelSetToPropertyKeys[labelSet]; if (propertyIds.size() == 0) { results.Add(new NodePropertySchemaInfoResult(labels, labelNames, null, null, false)); } else { propertyIds.forEach(propId => { string propName = _propertyIdToPropertyNameMapping[propId]; ValueTypeListHelper valueTypeListHelper = nodeMappings.LabelSetANDNodePropertyKeyIdToValueType[Pair.of(labelSet, propId)]; if (nodeMappings.NullableLabelSets.Contains(labelSet)) { results.Add(new NodePropertySchemaInfoResult(labels, labelNames, propName, valueTypeListHelper.CypherTypesList, false)); } else { results.Add(new NodePropertySchemaInfoResult(labels, labelNames, propName, valueTypeListHelper.CypherTypesList, valueTypeListHelper.Mandatory)); } }); } } return(results); }
/// <summary> /// Firsts set of the token chain /// </summary> /// <param name="tokenChain"></param> /// <param name="output"></param> /// <returns><c>true</c> if chain is nullable, <c>false</c> otherwise</returns> public bool AddFirst(int[] tokenChain, int startIndex, MutableIntSet output) { bool result = true; while (startIndex != tokenChain.Length) { int token = tokenChain[startIndex]; output.AddAll(firsts[token]); if (!isNullable[token]) { result = false; break; } ++startIndex; } return(result); }
// Fill FIRST set for the chain of tokens. // Returns true if anything was added, false otherwise. private bool InternalAddFirsts(IEnumerable <int> chain, MutableIntSet result) { bool changed = false; bool nullable = true; foreach (int item in chain) { bool itemNullable = false; foreach (var f in firsts[item].ToArray()) { if (f == PredefinedTokens.Epsilon) { itemNullable = true; // current part is nullable continue; } if (!result.Contains(f)) { result.Add(f); changed = true; } } if (!itemNullable) { nullable = false; break; } } if (nullable && !result.Contains(PredefinedTokens.Epsilon)) { result.Add(PredefinedTokens.Epsilon); changed = true; } return(changed); }
private IList <RelationshipPropertySchemaInfoResult> ProduceResultsForRelationships(RelationshipMappings relMappings) { IList <RelationshipPropertySchemaInfoResult> results = new List <RelationshipPropertySchemaInfoResult>(); foreach (int?typeId in relMappings.RelationshipTypeIdToPropertyKeys.Keys) { // lookup typ name string name = relMappings.RelationshipTypIdToRelationshipName[typeId]; name = ":`" + name + "`"; // escaping // lookup property value types MutableIntSet propertyIds = relMappings.RelationshipTypeIdToPropertyKeys[typeId]; if (propertyIds.size() == 0) { results.Add(new RelationshipPropertySchemaInfoResult(name, null, null, false)); } else { string finalName = name; propertyIds.forEach(propId => { string propName = _propertyIdToPropertyNameMapping[propId]; ValueTypeListHelper valueTypeListHelper = relMappings.RelationshipTypeIdANDPropertyTypeIdToValueType[Pair.of(typeId, propId)]; if (relMappings.NullableRelationshipTypes.Contains(typeId)) { results.Add(new RelationshipPropertySchemaInfoResult(finalName, propName, valueTypeListHelper.CypherTypesList, false)); } else { results.Add(new RelationshipPropertySchemaInfoResult(finalName, propName, valueTypeListHelper.CypherTypesList, valueTypeListHelper.Mandatory)); } }); } } return(results); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public System.Func<org.neo4j.kernel.impl.store.record.NodeRecord,Check<org.neo4j.kernel.impl.store.record.NodeRecord,org.neo4j.consistency.report.ConsistencyReport_NodeConsistencyReport>> forNodes(final org.neo4j.consistency.report.ConsistencyReporter reporter) public virtual System.Func <NodeRecord, Check <NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> > ForNodes(ConsistencyReporter reporter) { return(node => { MutableIntSet keys = null; foreach (long labelId in NodeLabelReader.GetListOfLabels(node, _storeAccess.NodeDynamicLabelStore)) { // labelId _is_ actually an int. A technical detail in the store format has these come in a long[] int[] propertyKeys = _nodes.get(safeCastLongToInt(labelId)); if (propertyKeys != null) { if (keys == null) { keys = new IntHashSet(16); } foreach (int key in propertyKeys) { keys.add(key); } } } return keys != null ? new RealCheck <Org.Neo4j.Kernel.impl.store.record.NodeRecord, Check <Org.Neo4j.Kernel.impl.store.record.NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> >(node, typeof(ConsistencyReport.NodeConsistencyReport), reporter, RecordType.Node, keys) : MandatoryProperties.NoCheck(); }); }
private void CheckChainItem(PropertyRecord property, CheckerEngine <RECORD, REPORT> engine, MutableIntSet keys, MandatoryProperties.Check <RECORD, REPORT> mandatory) { if (!property.InUse()) { engine.Report().propertyNotInUse(property); } else { int[] keysInRecord = ChainCheck.Keys(property); if (mandatory != null) { mandatory.Receive(keysInRecord); } foreach (int key in keysInRecord) { if (!keys.add(key)) { engine.Report().propertyKeyNotUniqueInChain(); } } } }
public TdfaTransition(int from, MutableIntSet symbols, int to) { From = from; Symbols = symbols; To = to; }
public override void LoadProperties(long entityId, EntityType type, MutableIntSet propertyIds, PropertyLoadSink sink) { _neoStoreIndexStoreView.loadProperties(entityId, type, propertyIds, sink); }
public override void LoadProperties(long nodeId, EntityType type, MutableIntSet propertyIds, PropertyLoader_PropertyLoadSink sink) { }
public DotTransition(MutableIntSet tokens, DotState to) { this.Tokens = tokens; this.To = to; }