diff --git a/CMakeLists.txt b/CMakeLists.txt index 47d7c4c2..4c7fabaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,7 @@ set(SOURCES gemma/weights.cc gemma/weights.h io/blob_store.cc - io/blob_store.h + io/blob_finder.h io/fields.cc io/fields.h io/io_win.cc diff --git a/io/blob_store.cc b/io/blob_store.cc index 8346e4ba..990d0d7a 100644 --- a/io/blob_store.cc +++ b/io/blob_store.cc @@ -412,8 +412,8 @@ class BlobStore { std::vector directory_; // two per blob, see `SetRange`. }; // BlobStore -BlobReader::BlobReader(const Path& blob_path) : blob_path_(blob_path) { - PROFILER_ZONE("Startup.BlobReader"); +BlobFinder::BlobFinder(const Path& blob_path) : blob_path_(blob_path) { + PROFILER_ZONE("Startup.BlobFinder"); file_ = OpenFileOrAbort(blob_path, "r"); file_bytes_ = file_->FileSize(); diff --git a/io/blob_store.h b/io/blob_store.h index 82c2357b..0acb0ecc 100644 --- a/io/blob_store.h +++ b/io/blob_store.h @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_GEMMA_CPP_IO_BLOB_STORE_H_ -#define THIRD_PARTY_GEMMA_CPP_IO_BLOB_STORE_H_ +#ifndef THIRD_PARTY_GEMMA_CPP_IO_BLOB_FINDER_H_ +#define THIRD_PARTY_GEMMA_CPP_IO_BLOB_FINDER_H_ // Reads/writes arrays of bytes from/to file. @@ -48,11 +48,11 @@ struct BlobRange { // faster lookups. // TODO(janwas): rename to BlobFinder or similar. // Thread-safe: it is safe to concurrently call all methods except `CloseFile`. -class BlobReader { +class BlobFinder { public: // Acquires ownership of `file` (which must be non-null) and reads its header. // Aborts on error. - explicit BlobReader(const Path& blob_path); + explicit BlobFinder(const Path& blob_path); const Path& blob_path() const { return blob_path_; } @@ -136,4 +136,4 @@ class BlobWriter { } // namespace gcpp -#endif // THIRD_PARTY_GEMMA_CPP_IO_BLOB_STORE_H_ +#endif // THIRD_PARTY_GEMMA_CPP_IO_BLOB_FINDER_H_ diff --git a/io/blob_store_test.cc b/io/blob_store_test.cc index cf966849..9a6c047b 100644 --- a/io/blob_store_test.cc +++ b/io/blob_store_test.cc @@ -32,10 +32,10 @@ namespace gcpp { namespace { #if !HWY_TEST_STANDALONE -class BlobStoreTest : public testing::Test {}; +class BlobFinderTest : public testing::Test {}; #endif -TEST(BlobStoreTest, TestReadWrite) { +TEST(BlobFinderTest, TestReadWrite) { ThreadingArgs threading_args; ThreadingContext ctx(threading_args); @@ -59,7 +59,7 @@ TEST(BlobStoreTest, TestReadWrite) { std::fill(buffer.begin(), buffer.end(), 0); - const BlobReader reader(path); + const BlobFinder reader(path); HWY_ASSERT_EQ(reader.Keys().size(), 2); HWY_ASSERT_STRING_EQ(reader.Keys()[0].c_str(), keyA.c_str()); @@ -92,7 +92,7 @@ TEST(BlobStoreTest, TestReadWrite) { } // Ensures padding works for any number of random-sized blobs. -TEST(BlobStoreTest, TestNumBlobs) { +TEST(BlobFinderTest, TestNumBlobs) { ThreadingArgs threading_args; ThreadingContext ctx(threading_args); hwy::RandomState rng; @@ -126,7 +126,7 @@ TEST(BlobStoreTest, TestNumBlobs) { HWY_ASSERT(blobs.size() == num_blobs); writer.Finalize(); - BlobReader reader(path); + BlobFinder reader(path); HWY_ASSERT_EQ(reader.Keys().size(), num_blobs); ParallelFor(