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); }
// 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); } } }