public static KeyValueSet Open(Header h, FNodeSet Fields, AggregateSet CR) { RecordSet rs = BinarySerializer.BufferRecordSet(h.Path); KeyValueSet gbs = new KeyValueSet(Fields, CR); gbs.ImportFromInterim(rs); return gbs; }
public static void Save(Header H, KeyValueSet Data) { RecordSet rs = Data.ToInterim(); rs.Attach(H); BinarySerializer.FlushRecordSet(rs); }
public static Header Save(string Dir, KeyValueSet Data) { RecordSet rs = Data.ToInterim(); Header h = Header.TempHeader(Dir, rs); rs.Attach(h); BinarySerializer.FlushRecordSet(rs); return h; }
// Statics // /// <summary> /// Takes all the records from T2 and merges into T1; if the record exists in T1, then: /// -- T1's record is updated /// -- T2's record is deleted /// Otherwise, if the record does not exist in T1, nothing happens /// </summary> /// <param name="T1"></param> /// <param name="T2"></param> public static void Union(KeyValueSet T1, KeyValueSet T2) { List<Record> Deletes = new List<Record>(); // Merge and tag deletes // foreach (KeyValuePair<Record, CompoundRecord> t in T2._cache) { if (T1._cache.ContainsKey(t.Key)) { T1.Merge(t.Key, t.Value); Deletes.Add(t.Key); } } // Clear deletes // foreach (Record r in Deletes) T2._cache.Remove(r); }
// Methods // public void Insert() { // If the cache is full, then dump to disk if (this._Cache.IsFull) { // Create the interim data cache // Header h = KeyValueSet.Save(this._TempDir, this._Cache); this._Headers.Add(h); // Create new record set // this._Cache = new KeyValueSet(this._Cache.BaseMappers, this._Cache.BaseReducers); } // Add the record to the cache // this._Cache.Add(); }
// Constructor // public AggregateStructure(string TempDir, FNodeSet Fields, AggregateSet Aggregates, List<Header> Headers) { this._TempDir = TempDir; this._Cache = new KeyValueSet(Fields, Aggregates); this._Headers = new List<Header>(); this._keys = Fields; this._aggregates = Aggregates; }