Skip to content

Commit

Permalink
txn: Using %q to format key and value
Browse files Browse the repository at this point in the history
since key and value could be binary
  • Loading branch information
ngaut committed Sep 10, 2015
1 parent 89455ad commit b540a5a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (s *session) GetTxn(forceNew bool) (kv.Transaction, error) {
return nil, err
}

log.Warnf("New txn:%s in session:%d", s.txn, s.sid)
log.Infof("New txn:%s in session:%d", s.txn, s.sid)
return s.txn, nil
}
if forceNew {
Expand Down
12 changes: 6 additions & 6 deletions store/localstore/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ func (txn *dbTxn) markOrigin(k []byte) error {
return err
}

//log.Debugf("markOrigin, key:%s, value:%s", keystr, val)
//log.Debugf("markOrigin, key:%q, value:%q", keystr, val)
txn.snapshotVals[keystr] = val
return nil
}

// Implement transaction interface

func (txn *dbTxn) Inc(k []byte, step int64) (int64, error) {
log.Debugf("Inc %s, step %d txn:%d", k, step, txn.tID)
log.Debugf("Inc %q, step %d txn:%d", k, step, txn.tID)
k = kv.EncodeKey(k)

if err := txn.markOrigin(k); err != nil {
Expand Down Expand Up @@ -105,7 +105,7 @@ func (txn *dbTxn) String() string {
}

func (txn *dbTxn) Get(k []byte) ([]byte, error) {
log.Debugf("get key:%s, txn:%d", k, txn.tID)
log.Debugf("get key:%q, txn:%d", k, txn.tID)
k = kv.EncodeKey(k)
val, err := txn.UnionStore.Get(k)
if kv.IsErrNotFound(err) {
Expand All @@ -129,13 +129,13 @@ func (txn *dbTxn) Set(k []byte, data []byte) error {
return ErrCannotSetNilValue
}

log.Debugf("set key:%s, txn:%d", k, txn.tID)
log.Debugf("set key:%q, txn:%d", k, txn.tID)
k = kv.EncodeKey(k)
return txn.UnionStore.Set(k, data)
}

func (txn *dbTxn) Seek(k []byte, fnKeyCmp func([]byte) bool) (kv.Iterator, error) {
log.Debugf("seek %s txn:%d", k, txn.tID)
log.Debugf("seek %q txn:%d", k, txn.tID)
k = kv.EncodeKey(k)

iter, err := txn.UnionStore.Seek(k, txn)
Expand All @@ -157,7 +157,7 @@ func (txn *dbTxn) Seek(k []byte, fnKeyCmp func([]byte) bool) (kv.Iterator, error
}

func (txn *dbTxn) Delete(k []byte) error {
log.Debugf("delete %s txn:%d", k, txn.tID)
log.Debugf("delete %q txn:%d", k, txn.tID)
k = kv.EncodeKey(k)
return txn.UnionStore.Delete(k)
}
Expand Down
2 changes: 1 addition & 1 deletion table/tables/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func (t *Table) IterRecords(ctx context.Context, startKey string, cols []*column
}
defer it.Close()

log.Debugf("startKey %s, key:%s,value:%s", startKey, it.Key(), it.Value())
log.Debugf("startKey %q, key:%q,value:%q", startKey, it.Key(), it.Value())

prefix := t.KeyPrefix()
for it.Valid() && strings.HasPrefix(it.Key(), prefix) {
Expand Down

0 comments on commit b540a5a

Please sign in to comment.