internal NodeSetFirstGroupStep(StageControl control, Configuration config, NodeStore nodeStore, ByteArray cache) : base(control, "FIRST", config, 1) { this._cache = cache; this._batchSize = config.BatchSize(); this._nodeStore = nodeStore; this._nodeCursor = nodeStore.OpenPageCursorForReading(0); NewBatch(); }
public override void Change(long nodeId, ByteArray array) { Batch[Cursor++] = nodeId; if (Cursor == outerInstance.BatchSize) { Send(); Batch = new long[outerInstance.BatchSize]; Cursor = 0; } }
public virtual long Get(ByteArray array, long index) { // Basically two modes: boolean or 5B field, right? if (BitCount == 1) { int field = array.GetByte(index, ByteOffset) & 0xFF; bool bitIsSet = (field & FbMask) != 0; return(bitIsSet ? -1 : 0); // the -1 here is a bit weird, but for the time being this is what the rest of the code expects } else // we know that this larger field starts at the beginning of a byte { long field = array.Get5ByteLong(index, ByteOffset); long raw = field & Mask; return(raw == Mask ? -1 : raw); } }
public virtual void Set(ByteArray array, long index, long value) { if (value < -1 || value > Mask) { throw new System.InvalidOperationException("Invalid value " + value + ", max is " + Mask); } if (BitCount == 1) { int field = array.GetByte(index, ByteOffset) & 0xFF; int otherBits = field & ~FbMask; array.SetByte(index, ByteOffset, ( sbyte )(otherBits | (value << BitOffset))); } else { long field = array.Get5ByteLong(index, ByteOffset); long otherBits = field & ~Mask; array.Set5ByteLong(index, ByteOffset, value | otherBits); } }
public virtual void Run(long memoryWeCanHoldForCertain, BatchingNeoStores neoStore, long highNodeId) { using (RelationshipGroupCache groupCache = new RelationshipGroupCache(_numberArrayFactory, memoryWeCanHoldForCertain, highNodeId)) { // Read from the temporary relationship group store... RecordStore <RelationshipGroupRecord> fromStore = neoStore.TemporaryRelationshipGroupStore; // and write into the main relationship group store RecordStore <RelationshipGroupRecord> toStore = neoStore.RelationshipGroupStore; // Count all nodes, how many groups each node has each Configuration groupConfig = withBatchSize(_config, neoStore.RelationshipGroupStore.RecordsPerPage); StatsProvider memoryUsage = new MemoryUsageStatsProvider(neoStore, groupCache); ExecuteStage(new CountGroupsStage(groupConfig, fromStore, groupCache, memoryUsage)); long fromNodeId = 0; long toNodeId = 0; while (fromNodeId < highNodeId) { // See how many nodes' groups we can fit into the cache this iteration of the loop. // Groups that doesn't fit in this round will be included in consecutive rounds. toNodeId = groupCache.Prepare(fromNodeId); _monitor.defragmentingNodeRange(fromNodeId, toNodeId); // Cache those groups ExecuteStage(new ScanAndCacheGroupsStage(groupConfig, fromStore, groupCache, memoryUsage)); // And write them in sequential order in the store ExecuteStage(new WriteGroupsStage(groupConfig, groupCache, toStore)); // Make adjustments for the next iteration fromNodeId = toNodeId; } // Now update nodes to point to the new groups ByteArray groupCountCache = groupCache.GroupCountCache; groupCountCache.clear(); Configuration nodeConfig = withBatchSize(_config, neoStore.NodeStore.RecordsPerPage); ExecuteStage(new NodeFirstGroupStage(nodeConfig, toStore, neoStore.NodeStore, groupCountCache)); } }
public PackedMultiFieldCache(ByteArray array, params int[] slotSizes) { this._array = array; SlotSizes = slotSizes; }
public NodeFirstGroupStage(Configuration config, RecordStore <RelationshipGroupRecord> groupStore, NodeStore nodeStore, ByteArray cache) : base(NAME, null, config, 0) { Add(new BatchFeedStep(Control(), config, allIn(groupStore, config), groupStore.RecordSize)); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: add(new org.neo4j.unsafe.impl.batchimport.staging.ReadRecordsStep<>(control(), config, true, groupStore)); Add(new ReadRecordsStep <object>(Control(), config, true, groupStore)); Add(new NodeSetFirstGroupStep(Control(), config, nodeStore, cache)); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: add(new UpdateRecordsStep<>(control(), config, nodeStore, new org.neo4j.unsafe.impl.batchimport.store.StorePrepareIdSequence())); Add(new UpdateRecordsStep <object>(Control(), config, nodeStore, new StorePrepareIdSequence())); }
public virtual long Get(ByteArray array, long index, int slotIndex) { return(Slot(slotIndex).get(array, index)); }
public virtual void Set(ByteArray array, long index, int slotIndex, long value) { Slot(slotIndex).set(array, index, value); }
public override void Change(long nodeId, ByteArray array) { outerInstance.cache.GetFirstRel(nodeId, this); }