Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gamolina committed Nov 8, 2024
1 parent bf37d49 commit 4b10b07
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 300 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ test: build_all
# mkdir -p $(COVERAGE_DIR)
# export TZ=UTC; go test ${GOLIST} -short -v ${LDFLAGS_TEST} -coverprofile ${COV_PROFILE}
# go tool cover -html=${COV_PROFILE} -o ${COV_HTML}
./test/run-go-tests.sh.
./test/run-go-tests.sh
ifeq ($(UNAME), Darwin)
# open ${COV_HTML}
endif
Expand Down
52 changes: 4 additions & 48 deletions core/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ func (s *Session) processPrimaryKey(tbuf *TableBuffer, row interface{}, pqTableP
cval = vals[0]
tbuf.CurrentPKValue[i] = cval

// NEW IMPLEMENTATION STARTS
var strVal string
mval, err := pk.MapValue(cval, nil, false)
if err != nil {
Expand All @@ -708,7 +707,10 @@ func (s *Session) processPrimaryKey(tbuf *TableBuffer, row interface{}, pqTableP
}
switch shared.TypeFromString(pk.Type) {
case shared.String:
strVal = cval.(string)
var ok bool
if strVal, ok = cval.(string); !ok {
strVal = pk.Render(mval)
}
case shared.Date, shared.DateTime:
strVal = pk.Render(mval)
if i == 0 { // First field in PK is TQ (if TQ != "")
Expand All @@ -732,52 +734,6 @@ func (s *Session) processPrimaryKey(tbuf *TableBuffer, row interface{}, pqTableP
strVal = pk.Render(mval)
}

/* REFACTOR THIS
switch reflect.ValueOf(cval).Kind() {
case reflect.String:
// Do nothing already a string
if i == 0 { // First field in PK is TQ (if TQ != "")
if pk.MappingStrategy == "SysMillisBSI" || pk.MappingStrategy == "SysMicroBSI" {
strVal := cval.(string)
tbuf.CurrentTimestamp, _, _ = shared.ToTQTimestamp(tbuf.Table.TimeQuantumType, strVal)
}
}
if pk.ColumnID {
if cID, err := strconv.ParseInt(cval.(string), 10, 64); err == nil {
tbuf.CurrentColumnID = uint64(cID)
directColumnID = true
}
}
case reflect.Int64:
orig := cval.(int64)
cval = fmt.Sprintf("%d", orig)
if i == 0 {
tFormat := shared.YMDTimeFmt
if tbuf.Table.TimeQuantumType == "YMDH" {
tFormat = shared.YMDHTimeFmt
}
if pk.MappingStrategy == "SysMillisBSI" || pk.MappingStrategy == "SysMicroBSI" {
ts := time.Unix(0, orig*1000000)
if pk.MappingStrategy == "SysMicroBSI" {
ts = time.Unix(0, orig*1000)
}
tbuf.CurrentTimestamp, _, _ = shared.ToTQTimestamp(tbuf.Table.TimeQuantumType, ts.Format(tFormat))
}
}
case reflect.Float64:
orig := cval.(float64)
f := fmt.Sprintf("%%10.%df", pk.Scale)
cval = fmt.Sprintf(f, orig)
case reflect.Float32:
orig := cval.(float32)
f := fmt.Sprintf("%%10.%df", pk.Scale)
cval = fmt.Sprintf(f, orig)
default:
return false, fmt.Errorf("PK Lookup value [%v] unknown type, it is [%v]", cval,
reflect.ValueOf(cval).Kind())
}
*/
if pkLookupVal.Len() == 0 {
pkLookupVal.WriteString(strVal)
} else {
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,5 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/RoaringBitmap/roaring/v2 => /home/ec2-user/roaring
241 changes: 0 additions & 241 deletions quanta-kafka-consumer/quanta-kafka-consumer.go

This file was deleted.

22 changes: 12 additions & 10 deletions server/bitmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"io"
"unsafe"

"math"
//"math"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -330,26 +330,28 @@ type BSIBitmap struct {
func (m *BitmapIndex) newBSIBitmap(index, field string) *BSIBitmap {

attr, err := m.getFieldConfig(index, field)
var minValue, maxValue int64
// var minValue, maxValue int64
var timeQuantumType string
if err == nil {
timeQuantumType = attr.TimeQuantumType
minValue = int64(attr.MinValue)
maxValue = int64(attr.MaxValue)
// minValue = int64(attr.MinValue)
// maxValue = int64(attr.MaxValue)
}
var seq *SequencerQueue
if attr.Parent.PrimaryKey != "" || attr.Parent.TimeQuantumField != "" {
pkInfo, _ := attr.Parent.GetPrimaryKeyInfo()
if attr.FieldName == pkInfo[0].FieldName {
// If compound key, sequencer installed on first key attr
seq = NewSequencerQueue()
if maxValue == 0 {
maxValue = math.MaxInt64
}
// if maxValue == 0 {
// maxValue = math.MaxInt64
// }
}
}
ts := time.Now()
return &BSIBitmap{BSI: roaring64.NewBSI(maxValue, minValue),
// return &BSIBitmap{BSI: roaring64.NewBSI(maxValue, minValue),
// TQType: timeQuantumType, ModTime: ts, AccessTime: ts, sequencerQueue: seq}
return &BSIBitmap{BSI: roaring64.NewDefaultBSI(),
TQType: timeQuantumType, ModTime: ts, AccessTime: ts, sequencerQueue: seq}
}

Expand Down Expand Up @@ -1438,9 +1440,9 @@ func (m *BitmapIndex) OfflinePartitions(ctx context.Context, req *pb.PartitionIn
ts := time.Unix(0, req.Time)

if req.Index != "" {
u.Info("Offline partition request for %v, table = %s", ts.Format(timeFmt), req.Index)
u.Infof("Offline partition request for %v, table = %s", ts.Format(timeFmt), req.Index)
} else {
u.Info("Offline partition request for %v, all partitioned tables", ts.Format(timeFmt))
u.Infof("Offline partition request for %v, all partitioned tables", ts.Format(timeFmt))
}

// Iterate over shard cache insert into partition operation queue
Expand Down

0 comments on commit 4b10b07

Please sign in to comment.