public BigIndexSet(string SinkDir, RecordReader Stream, Key K) : base(SinkDir, TableHeader.TempName(), BuildSchema(K, Stream.SourceSchema)) { // Open readers/writers // RecordWriter rw = this.OpenWriter(); // Main loop // while (!Stream.EndOfData) { // Need to pull the id and position here because read next will advance the stream int pos = Stream.Position; long id = Stream.SetID; Record q = Stream.ReadNext(); Record r = Record.Stitch(new Cell(id), new Cell(pos), new Cell(q.GetHashCode(K))); r = Record.Join(r, Record.Split(q, K)); rw.Insert(r); } rw.Close(); // Sort table // Key sort = new Key(2); for (int i = 0; i < K.Count; i++) sort.Add(3 + i); this.Sort(sort); }
public static long Update(DataSet Data, Key K, FNodeSet Fields, Predicate BaseDataFilter) { // Check that the field indicies and the maps have the same length // if (K.Count != Fields.Count) throw new Exception(string.Format("Field collection passed [{0}] has fewer elements than the map collection passed [{0}]", K.Count, Fields.Count)); // Create the total append count // long CountOf = 0; // Loop through each extent // foreach (RecordSet rs in Data.Extents) { // Open a stream // RecordReader rr = new RecordReader(rs, BaseDataFilter); // Create a register // Register mem = new StreamRegister(rr); // Assign the register to the fields // Fields.AssignRegister(mem); // Update the data // while (!rr.EndOfData) { Update(rr.Read(), K, Fields); CountOf++; rr.Advance(); } // if (rs.IsAttached) BinarySerializer.Flush(rs); } // No need to flush the data set // return CountOf; }
// Text IO // public static void FlushText(string FullPath, RecordReader R, char Delim, bool Headers) { // Build a stream // using (StreamWriter sw = new StreamWriter(FullPath)) { // Write the name string // if (Headers) sw.WriteLine(R.SourceSchema.ToNameString(Delim)); // Write all records // while (!R.EndOfData) { string value = R.ReadNext().ToString(Delim); if (!R.EndOfData) sw.WriteLine(value); else sw.Write(value); } } }
public StreamRegister(RecordReader Stream) : base() { this._stream = Stream; }