Skip to content

Commit

Permalink
[perf] use correct key exchange table in row store
Browse files Browse the repository at this point in the history
this is not on by default, but will be turned on down the line. this
took a bit of hunting down.
  • Loading branch information
okay committed Mar 24, 2021
1 parent f16381b commit 064a40b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GOBIN=$(shell which go)
ARCH?=
BUILD_CMD = GOARCH=${ARCH} ${GOBIN} install
BUILD_CMD = GOARCH=${ARCH} ${GOBIN} build
INSTALL_CMD = GOARCH=${ARCH} ${GOBIN} install
BINDIR = ./bin
GOBINDIR = `readlink -f ./bin`
PROFILE = -tags profile
Expand All @@ -19,6 +20,7 @@ deps:

sybil: bindir
GOBIN=$(GOBINDIR) $(BUILD_CMD) $(GO_FLAGS) $(BUILD_FLAGS) ./
GOBIN=$(GOBINDIR) $(INSTALL_CMD) $(GO_FLAGS) $(BUILD_FLAGS) ./

fake-data: fake-uptime

Expand Down
22 changes: 11 additions & 11 deletions src/lib/row_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,11 @@ func get_short_key_id(t *Table, key_exchange map[int16]int16, key_id int16) int1
if t.ShortKeyInfo == nil || t.ShortKeyInfo.KeyExchange == nil {
return key_id
}

key_id, ok := key_exchange[key_id]
if !ok {
return -1
}

vv, ok := t.ShortKeyInfo.KeyExchange[int16(key_id)]
if ok {
key_id = int16(vv)
} else {
return -1
}

return key_id

}
Expand Down Expand Up @@ -102,7 +94,7 @@ func (srb *SavedRecordBlock) toRecord(t *Table, s *SavedRecord) *Record {
b.table = t
r.block = &b

max_key_id := srb.max_key_id
max_key_id := int16(srb.max_key_id)
key_exchange := srb.key_exchange
r.ResizeFields(int16(max_key_id))

Expand All @@ -121,6 +113,7 @@ func (srb *SavedRecordBlock) toRecord(t *Table, s *SavedRecord) *Record {
if key_id == -1 {
continue
}

r.AddStrField(t.get_string_for_key(key_id), v.Value)
}

Expand Down Expand Up @@ -182,7 +175,7 @@ func (t *Table) LoadRecordsFromLog(filename string) RecordList {
// If the KeyTable doesn't exist, it means we are loading old records that
// were ingested without a keytable
if srb.KeyTable == nil {
srb.KeyTable = &t.KeyTable
srb.KeyTable = get_key_table(t)
}

srb.init_data_structures(t)
Expand All @@ -194,6 +187,13 @@ func (t *Table) LoadRecordsFromLog(filename string) RecordList {

}

func get_key_table(t *Table) *map[string]int16 {
if t.AllKeyInfo != nil {
return &t.AllKeyInfo.KeyTable
}
return &t.KeyTable
}

func (t *Table) AppendRecordsToLog(records RecordList, blockname string) {
if len(records) == 0 {
return
Expand Down Expand Up @@ -224,7 +224,7 @@ func (t *Table) AppendRecordsToLog(records RecordList, blockname string) {
Debug("SAVING INTO SRB")
srb := SavedRecordBlock{}
srb.RecordList = marshalled_records
srb.KeyTable = &t.KeyTable
srb.KeyTable = get_key_table(t)
err = enc.Encode(srb)
} else {
err = enc.Encode(marshalled_records)
Expand Down

0 comments on commit 064a40b

Please sign in to comment.