public DeleteDuplicateNodesStep(StageControl control, Configuration config, LongIterator nodeIds, NodeStore nodeStore, PropertyStore propertyStore, DataImporter.Monitor storeMonitor) : base(control, "DEDUP", config) { this._nodeStore = nodeStore; this._propertyStore = propertyStore; this._nodeIds = nodeIds; this._storeMonitor = storeMonitor; }
private Ids CreateNode(DataImporter.Monitor monitor, NeoStores neoStores, int propertyCount, int labelCount) { PropertyStore propertyStore = neoStores.PropertyStore; RecordAccess <PropertyRecord, PrimitiveRecord> propertyRecordAccess = new DirectRecordAccess <PropertyRecord, PrimitiveRecord>(propertyStore, (new Loaders(neoStores)).propertyLoader()); NodeStore nodeStore = neoStores.NodeStore; NodeRecord nodeRecord = nodeStore.NewRecord(); nodeRecord.Id = nodeStore.NextId(); nodeRecord.InUse = true; NodeLabelsField.parseLabelsField(nodeRecord).put(LabelIds(labelCount), nodeStore, nodeStore.DynamicLabelStore); long nextProp = (new PropertyCreator(propertyStore, new PropertyTraverser())).createPropertyChain(nodeRecord, Properties(propertyStore, propertyCount), propertyRecordAccess); nodeRecord.NextProp = nextProp; nodeStore.UpdateRecord(nodeRecord); PropertyRecord[] propertyRecords = ExtractPropertyRecords(propertyRecordAccess, nextProp); propertyRecordAccess.Close(); monitor.NodesImported(1); monitor.PropertiesImported(propertyCount); return(new Ids(nodeRecord, propertyRecords)); }
public DataStatistics(DataImporter.Monitor entityCounts, RelationshipTypeCount[] sortedTypes) { this._entityCounts = entityCounts; this._typeCounts = sortedTypes; }
public DeleteDuplicateNodesStage(Configuration config, LongIterator duplicateNodeIds, BatchingNeoStores neoStore, DataImporter.Monitor storeMonitor) : base("DEDUP", null, config, 0) { Add(new DeleteDuplicateNodesStep(Control(), config, duplicateNodeIds, neoStore.NodeStore, neoStore.PropertyStore, storeMonitor)); }
public virtual void ShouldDeleteEverythingAboutTheDuplicatedNodes() { // given NeoStores neoStores = _neoStoresRule.builder().build(); Ids[] ids = new Ids[9]; DataImporter.Monitor monitor = new DataImporter.Monitor(); ids[0] = CreateNode(monitor, neoStores, 10, 10); // node with many properties and many labels ids[1] = CreateNode(monitor, neoStores, 10, 1); // node with many properties and few labels ids[2] = CreateNode(monitor, neoStores, 10, 0); // node with many properties and no labels ids[3] = CreateNode(monitor, neoStores, 1, 10); // node with few properties and many labels ids[4] = CreateNode(monitor, neoStores, 1, 1); // node with few properties and few labels ids[5] = CreateNode(monitor, neoStores, 1, 0); // node with few properties and no labels ids[6] = CreateNode(monitor, neoStores, 0, 10); // node with no properties and many labels ids[7] = CreateNode(monitor, neoStores, 0, 1); // node with no properties and few labels ids[8] = CreateNode(monitor, neoStores, 0, 0); // node with no properties and no labels // when long[] duplicateNodeIds = RandomNodes(ids); SimpleStageControl control = new SimpleStageControl(); using (DeleteDuplicateNodesStep step = new DeleteDuplicateNodesStep(control, Configuration.DEFAULT, PrimitiveLongCollections.iterator(duplicateNodeIds), neoStores.NodeStore, neoStores.PropertyStore, monitor)) { control.Steps(step); StartAndAwaitCompletionOf(step); } control.AssertHealthy(); // then int expectedNodes = 0; int expectedProperties = 0; foreach (Ids entity in ids) { bool expectedToBeInUse = !ArrayUtils.contains(duplicateNodeIds, entity.Node.Id); int stride = expectedToBeInUse ? 1 : 0; expectedNodes += stride; // Verify node record assertEquals(expectedToBeInUse, neoStores.NodeStore.isInUse(entity.Node.Id)); // Verify label records foreach (DynamicRecord labelRecord in entity.Node.DynamicLabelRecords) { assertEquals(expectedToBeInUse, neoStores.NodeStore.DynamicLabelStore.isInUse(labelRecord.Id)); } // Verify property records foreach (PropertyRecord propertyRecord in entity.Properties) { assertEquals(expectedToBeInUse, neoStores.PropertyStore.isInUse(propertyRecord.Id)); foreach (PropertyBlock property in propertyRecord) { // Verify property dynamic value records foreach (DynamicRecord valueRecord in property.ValueRecords) { AbstractDynamicStore valueStore; switch (property.Type) { case STRING: valueStore = neoStores.PropertyStore.StringStore; break; case ARRAY: valueStore = neoStores.PropertyStore.ArrayStore; break; default: throw new System.ArgumentException(propertyRecord + " " + property); } assertEquals(expectedToBeInUse, valueStore.IsInUse(valueRecord.Id)); } expectedProperties += stride; } } } assertEquals(expectedNodes, monitor.NodesImported()); assertEquals(expectedProperties, monitor.PropertiesImported()); }