Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit af9b8d0

Browse files
committed
optimize allocations and loop in SearchTable
1 parent da15b99 commit af9b8d0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

store/cassandra/cassandra.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,13 @@ func (c *CassandraStore) SearchTable(ctx context.Context, key schema.AMKey, tabl
470470

471471
results := make(chan readResult, 1)
472472

473-
var rowKeys []string
474-
for month := start_month; month <= end_month; month += Month_sec {
475-
rowKeys = append(rowKeys, fmt.Sprintf("%s_%d", key, month/Month_sec))
473+
startMonthNum := start_month / Month_sec
474+
endMonthNum := end_month / Month_sec
475+
rowKeys := make([]string, endMonthNum-startMonthNum+1)
476+
i := 0
477+
for num := startMonthNum; num <= endMonthNum; num += 1 {
478+
rowKeys[i] = fmt.Sprintf("%s_%d", key, num)
479+
i++
476480
}
477481
crr := ChunkReadRequest{
478482
q: table.QueryRead,

0 commit comments

Comments
 (0)