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

Commit

Permalink
update mt-store-cp-experimental to comply with new gocql version
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-milan committed Dec 19, 2019
1 parent 00b21c5 commit cb83a93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 4 additions & 2 deletions cmd/mt-store-cp-experimental/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,10 @@ func worker(id int, jobs <-chan string, wg *sync.WaitGroup, sourceSession, destS
if *verbose {
log.Printf("id=%d processing rownum=%d table=%q key=%q ts=%d query=%q data='%x'\n", id, atomic.LoadUint64(&doneRows)+1, tableIn, key, ts, query, data)
}

batch.Query(insertQuery, data, key, ts, ttl)
// As 'data' is re-used for each scan, we need to make a copy of the []byte slice before assigning it to a new batch.
safeData := make([]byte, len(data))
copy(safeData, data)
batch.Query(insertQuery, safeData, key, ts, ttl)

if batch.Size() >= *maxBatchSize {
if *verbose {
Expand Down
10 changes: 4 additions & 6 deletions store/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,10 @@ func (c *CassandraStore) SearchTable(ctx context.Context, key schema.AMKey, tabl
if len(b) < 2 {
return itgens, errChunkTooSmall
}
// due to changes in gocql we need to manually copy the []byte before
// creating an itergen
// reference: https://github.com/gocql/gocql/pull/1167
copiedBytes := make([]byte, len(b))
copy(copiedBytes, b)
itgen, err := chunk.NewIterGen(uint32(t0), intervalHint, copiedBytes)
// As 'b' is re-used for each scan, we need to make a copy of the []byte slice before assigning it to a new IterGen.
safeBytes := make([]byte, len(b))
copy(safeBytes, b)
itgen, err := chunk.NewIterGen(uint32(t0), intervalHint, safeBytes)
if err != nil {
return itgens, err
}
Expand Down

0 comments on commit cb83a93

Please sign in to comment.