func (ts *Ts) rollbackDbDel(db *db.DB, key []byte) { obj := ts.getMagicDb(key) if obj != nil { db.SetDbObj(key, obj) } ts.delMagicDb(key) }
func (ts *Ts) commitDbAdd(db *db.DB, key []byte) { obj := ts.getMagicDb(key) log.Println("Obj", obj) if obj != nil { ts.datalog.PutKeyValue(db, key, store.None, obj) db.SetDbObj(key, obj) } }
func (ts *Ts) DeleteDBKey(db *db.DB, key []byte) { var err error tsr := NewTsRecord(DeleteDbKey) tsr.Key = key tsr.Dbptr = db if origObj := db.GetDbObj(key); origObj != nil { tsr.Position = ts.tsLog.Put(db, origObj.GetObjectType(), key, origObj.GetBuffer()) if tsr.Position == nil { log.Panicln(err) } } ts.AddTsRecord(tsr) obj := ts.getMagicDb(key) if obj != nil { ts.delMagicDb(key) } else { obj = db.GetDbObj(key) if obj != nil { ts.setMagicDb(key, obj) db.DeleteDbObj(key) } } }
func (ts *Ts) SetDBKey(db *db.DB, t uint8, key []byte, value []byte) { var err error tsr := NewTsRecord(AddDbKey) if origObj := db.GetDbObj(key); origObj != nil { log.Println("SetDBKey() origObj:", origObj) tsr.Position = ts.tsLog.Put(db, origObj.GetObjectType(), key, origObj.GetBuffer()) if tsr.Position == nil { log.Panicln(err) } } tsr.Key = key tsr.Dbptr = db ts.AddTsRecord(tsr) ts.setMagicDb(key, ds.CreateObject(value, t, ts.TsId)) }
func (ts *Ts) GetDBKey(db *db.DB, key []byte) *ds.Object { if obj := ts.getMagicDb(key); obj != nil { return obj } return db.GetDbObj(key) }