Skip to content

Commit

Permalink
Automated Code Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 659901936
  • Loading branch information
tensorflower-gardener authored and copybara-github committed Aug 6, 2024
1 parent 1fe3e81 commit 4de1c44
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion tsl/lib/io/snappy/snappy_inputbuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ absl::Status SnappyInputBuffer::ReadFromFile() {
bytes_to_read -= avail_in_;
read_location += avail_in_;
}
StringPiece data;
absl::string_view data;
// Try to read enough data to fill up input_buffer_.
absl::Status s = file_->Read(file_pos_, bytes_to_read, &data, read_location);
if (data.data() != read_location) {
Expand Down
10 changes: 5 additions & 5 deletions tsl/lib/io/snappy/snappy_outputbuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SnappyOutputBuffer::~SnappyOutputBuffer() {
}
}

absl::Status SnappyOutputBuffer::Append(StringPiece data) {
absl::Status SnappyOutputBuffer::Append(absl::string_view data) {
return Write(data);
}

Expand All @@ -58,7 +58,7 @@ absl::Status SnappyOutputBuffer::Close() {
return Flush();
}

absl::Status SnappyOutputBuffer::Name(StringPiece* result) const {
absl::Status SnappyOutputBuffer::Name(absl::string_view* result) const {
return file_->Name(result);
}

Expand All @@ -71,7 +71,7 @@ absl::Status SnappyOutputBuffer::Tell(int64_t* position) {
return file_->Tell(position);
}

absl::Status SnappyOutputBuffer::Write(StringPiece data) {
absl::Status SnappyOutputBuffer::Write(absl::string_view data) {
//
// The deflated output is accumulated in output_buffer_ and gets written to
// file as and when needed.
Expand Down Expand Up @@ -121,7 +121,7 @@ int32 SnappyOutputBuffer::AvailableInputSpace() const {
return input_buffer_capacity_ - avail_in_;
}

void SnappyOutputBuffer::AddToInputBuffer(StringPiece data) {
void SnappyOutputBuffer::AddToInputBuffer(absl::string_view data) {
size_t bytes_to_write = data.size();
DCHECK_LE(bytes_to_write, AvailableInputSpace());

Expand Down Expand Up @@ -182,7 +182,7 @@ absl::Status SnappyOutputBuffer::DeflateBuffered() {
absl::Status SnappyOutputBuffer::FlushOutputBufferToFile() {
size_t bytes_to_write = output_buffer_capacity_ - avail_out_;
if (bytes_to_write > 0) {
absl::Status s = file_->Append(StringPiece(
absl::Status s = file_->Append(absl::string_view(
reinterpret_cast<char*>(output_buffer_.get()), bytes_to_write));
if (s.ok()) {
next_out_ = output_buffer_.get();
Expand Down
8 changes: 4 additions & 4 deletions tsl/lib/io/snappy/snappy_outputbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SnappyOutputBuffer : public WritableFile {
//
// The input data is buffered internally and will be written to disk at a
// later time. To immediately write contents to file call `Flush()`.
absl::Status Append(StringPiece data) override;
absl::Status Append(absl::string_view data) override;

#if defined(TF_CORD_SUPPORT)
absl::Status Append(const absl::Cord& cord) override;
Expand All @@ -81,7 +81,7 @@ class SnappyOutputBuffer : public WritableFile {
absl::Status Close() override;

// Returns the name of the underlying file.
absl::Status Name(StringPiece* result) const override;
absl::Status Name(absl::string_view* result) const override;

// Deflates any cached input, writes all output to file and syncs it.
absl::Status Sync() override;
Expand All @@ -98,7 +98,7 @@ class SnappyOutputBuffer : public WritableFile {
// to file when the buffer is full.
//
// To immediately write contents to file call `Flush()`.
absl::Status Write(StringPiece data);
absl::Status Write(absl::string_view data);

// Compresses any cached input and writes all output to file. This must be
// called before the destructor to avoid any data loss.
Expand All @@ -107,7 +107,7 @@ class SnappyOutputBuffer : public WritableFile {
private:
// Appends `data` to `input_buffer_`.
// Throws if `data.size()` > AvailableInputSpace().
void AddToInputBuffer(StringPiece data);
void AddToInputBuffer(absl::string_view data);

// Appends `data` to `output_buffer_`. Flushes buffer contents to file when
// buffer gets full.
Expand Down
14 changes: 7 additions & 7 deletions tsl/lib/io/snappy/snappy_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ absl::Status TestMultipleWritesWriteFile(size_t compress_input_buf_size,
compress_output_buf_size);

for (int i = 0; i < num_writes; i++) {
TF_RETURN_IF_ERROR(out.Write(StringPiece(data)));
TF_RETURN_IF_ERROR(out.Write(absl::string_view(data)));
if (with_flush) {
TF_RETURN_IF_ERROR(out.Flush());
}
Expand All @@ -96,7 +96,7 @@ absl::Status TestMultipleWritesWriteFile(size_t compress_input_buf_size,
std::unique_ptr<RandomAccessFile> file_reader;
TF_RETURN_IF_ERROR(env->NewRandomAccessFile(fname, &file_reader));

StringPiece data;
absl::string_view data;
size_t file_pos = 0;
size_t bytes_to_read = 256;
char* scratch = new char[bytes_to_read];
Expand All @@ -106,14 +106,14 @@ absl::Status TestMultipleWritesWriteFile(size_t compress_input_buf_size,
while ((file_reader->Read(file_pos, bytes_to_read, &data, scratch)).ok()) {
file_pos += data.size();
TF_CHECK_OK(
corrupt_file_writer->Append(StringPiece(buffer, buffer_size)));
corrupt_file_writer->Append(absl::string_view(buffer, buffer_size)));
memcpy(buffer, data.data(), data.size());
buffer_size = data.size();
}

// Drop the last byte. File is now corrupt.
TF_CHECK_OK(
corrupt_file_writer->Append(StringPiece(buffer, buffer_size - 1)));
TF_CHECK_OK(corrupt_file_writer->Append(
absl::string_view(buffer, buffer_size - 1)));
TF_CHECK_OK(corrupt_file_writer->Flush());
TF_CHECK_OK(corrupt_file_writer->Close());
delete[] scratch;
Expand Down Expand Up @@ -216,7 +216,7 @@ void TestTellWriteFile(size_t compress_input_buf_size,
TF_CHECK_OK(env->NewWritableFile(fname, &file_writer));
io::SnappyOutputBuffer out(file_writer.get(), compress_input_buf_size,
compress_output_buf_size);
TF_CHECK_OK(out.Write(StringPiece(data)));
TF_CHECK_OK(out.Write(absl::string_view(data)));
TF_CHECK_OK(out.Flush());
TF_CHECK_OK(file_writer->Flush());
TF_CHECK_OK(file_writer->Close());
Expand Down Expand Up @@ -296,7 +296,7 @@ void TestTellInputStream(size_t compress_input_buf_size,

static bool SnappyCompressionSupported() {
string out;
StringPiece in = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
absl::string_view in = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
return port::Snappy_Compress(in.data(), in.size(), &out);
}

Expand Down

0 comments on commit 4de1c44

Please sign in to comment.