Skip to content

Commit

Permalink
[tools] Use streaming reads in read_data_files (#3474)
Browse files Browse the repository at this point in the history
  • Loading branch information
linasm authored May 6, 2021
1 parent 824d4a9 commit c4bd395
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/cmd/tools/read_data_files/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ func main() {
BlockStart: time.Unix(0, *optBlockstart),
VolumeIndex: int(*volume),
},
FileSetType: fileSetType,
FileSetType: fileSetType,
StreamingEnabled: true,
}

err = reader.Open(openOpts)
Expand All @@ -145,22 +146,25 @@ func main() {
}

for {
id, _, data, _, err := reader.Read()
entry, err := reader.StreamingRead()
if err == io.EOF {
break
}
if err != nil {
log.Fatalf("err reading metadata: %v", err)
}

var (
id = entry.ID
data = entry.Data
)

if *idFilter != "" && !strings.Contains(id.String(), *idFilter) {
continue
}

if benchMode != benchmarkSeries {
data.IncRef()

iter := m3tsz.NewReaderIterator(xio.NewBytesReader64(data.Bytes()), true, encodingOpts)
iter := m3tsz.NewReaderIterator(xio.NewBytesReader64(data), true, encodingOpts)
for iter.Next() {
dp, _, annotation := iter.Current()
if benchMode == benchmarkNone {
Expand All @@ -179,11 +183,8 @@ func main() {
log.Fatalf("unable to iterate original data: %v", err)
}
iter.Close()

data.DecRef()
}

data.Finalize()
seriesCount++
}

Expand Down

0 comments on commit c4bd395

Please sign in to comment.