Skip to content

Instantly share code, notes, and snippets.

@ivelin
Last active June 19, 2019 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivelin/6fe67e2251bca5960f7caa54b379d8f0 to your computer and use it in GitHub Desktop.
Save ivelin/6fe67e2251bca5960f7caa54b379d8f0 to your computer and use it in GitHub Desktop.
// read packets from the file up to record_to_read or end of file
while ((*record_read) < record_to_read) {
int64 record_count = 0;
double packet_timestamp;
string packet_data_buffer;
Status status = state.get()->ReadRecord(packet_timestamp, &packet_data_buffer, record_count);
if (!(status.ok() || errors::IsOutOfRange(status))) {
return status;
}
if (record_count > 0) {
Tensor timestamp_tensor = (*out_tensors)[0];
timestamp_tensor.flat<double>()(*record_read) = packet_timestamp;
Tensor data_tensor = (*out_tensors)[1];
data_tensor.flat<string>()(*record_read) = std::move(packet_data_buffer);
(*record_read) += record_count;
} else {
// no more records available to read
// record_count == 0
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment