Skip to content

Commit

Permalink
updates for tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
tildeleb committed Sep 27, 2017
1 parent 48d7a15 commit f22957a
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions hashtable/hashtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type HashTable struct {
Stats
tbs []TBS
Seed uint64
Tcnt int // trace counter
extra int
pd bool
oa bool
Expand Down Expand Up @@ -140,11 +141,17 @@ func (ht *HashTable) Insert(ka []byte) {
ht.Buckets[idx] = append(ht.Buckets[idx], Bucket{Key: k})
//fmt.Printf("Insert: ins idx=%d, len=%d, hash=0x%08x, key=%q\n", idx, len(ht.Buckets[idx]), h, ht.Buckets[idx][0].Key)
if Trace {
fmt.Printf("{%q: %q, %q: %d, %q: %d, %q: %d, %q: %v},\n", "op", "I", "t", 0, "b", idx, "s", 0, "v", btoi(k))
fmt.Printf("{%q: %d, %q: %d, %q: %q, %q: %d, %q: %d, %q: %d, %q: %v, %q: %v},\n",
"i", ht.Tcnt, "l", cnt, "op", "I", "t", 0, "b", idx, "s", 0, "k", btoi(k), "v", btoi(k))
ht.Tcnt++
//fmt.Printf("len(ht.tbs)=%d\n", ht.tbs)
for _, tbs := range ht.tbs {
fmt.Printf("{%q: %q, %q: %d, %q: %d, %q: %d, %q: %v},\n", "op", "U", "t", tbs.t, "b", tbs.b, "s", tbs.s, "v", btoi(k))
}
/*
for _, _ := range ht.tbs {
fmt.Printf("{%q: %d, %q: %d, %q: %q, %q: %d, %q: %d, %q: %d, %q: %v, %q: %v},\n",
"i", ht.Tcnt, "l", cnt, "op", "U", "t", tbs.t, "b", tbs.b, "s", tbs.s, "k", btoi(k), "v", btoi(k))
ht.Tcnt++
}
*/
ht.tbs = nil
}
ht.Probes++
Expand All @@ -153,16 +160,19 @@ func (ht *HashTable) Insert(ka []byte) {
}
if ht.oa {
//fmt.Printf("Insert: col idx=%d, len=%d, hash=0x%08x, key=%q\n", idx, len(ht.Buckets[idx]), h, ht.Buckets[idx][0].Key)
if Trace {
fmt.Printf("{%q: %q, %q: %d, %q: %d, %q: %d, %q: %v},\n", "op", "H", "t", 0, "b", idx, "s", 0, "v", btoi(k))
ht.tbs = append(ht.tbs, TBS{0, int(idx), 0})
}
if cnt == 0 {
ht.Cols++
} else {
ht.Probes++
} else {
ht.Cols++
}
if Trace {
/*
ht.tbs = append(ht.tbs, TBS{0, int(idx), 0})
*/
fmt.Printf("{%q: %d, %q: %d, %q: %q, %q: %d, %q: %d, %q: %d, %q: %v, %q: %v},\n",
"i", ht.Tcnt, "l", cnt, "op", "P", "t", 0, "b", idx, "s", 0, "k", btoi(k), "v", btoi(k))
ht.Tcnt++
}

// check for a duplicate key
bh := hashf.Hashf(ht.Buckets[idx][0].Key, ht.Seed)
if bh == h {
Expand Down

0 comments on commit f22957a

Please sign in to comment.