From 733bbddb7a3f5bda2f9734bad07476b0e6abbd7e Mon Sep 17 00:00:00 2001 From: Olamiposi Otesile Date: Fri, 26 Dec 2025 13:48:49 +0100 Subject: [PATCH 1/2] Refactor: Rename BlobReader to BlobFinder Renamed BlobReader and BlobWriter to BlobFinder as suggested by @janwas in TODO. Also Updated associated files, tests, and CMakeLists.txt. --- CMakeLists.txt | 6 +++--- io/{blob_store.cc => blob_finder.cc} | 2 +- io/{blob_store.h => blob_finder.h} | 10 +++++----- io/{blob_store_test.cc => blob_finder_test.cc} | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) rename io/{blob_store.cc => blob_finder.cc} (99%) rename io/{blob_store.h => blob_finder.h} (95%) rename io/{blob_store_test.cc => blob_finder_test.cc} (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7070781..d52aedac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,8 +98,8 @@ set(SOURCES gemma/vit.h gemma/weights.cc gemma/weights.h - io/blob_store.cc - io/blob_store.h + io/blob_finder.cc + io/blob_finder.h io/fields.cc io/fields.h io/io_win.cc @@ -223,7 +223,7 @@ set(GEMMA_TEST_FILES evals/gemma_test.cc gemma/flash_attention_test.cc gemma/tensor_info_test.cc - io/blob_store_test.cc + io/blob_finder_test.cc io/fields_test.cc ops/bench_matmul.cc ops/dot_test.cc diff --git a/io/blob_store.cc b/io/blob_finder.cc similarity index 99% rename from io/blob_store.cc rename to io/blob_finder.cc index af9f81d6..30d9815d 100644 --- a/io/blob_store.cc +++ b/io/blob_finder.cc @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "io/blob_store.h" +#include "io/blob_finder.h" #include #include diff --git a/io/blob_store.h b/io/blob_finder.h similarity index 95% rename from io/blob_store.h rename to io/blob_finder.h index e5f2221f..1173753b 100644 --- a/io/blob_store.h +++ b/io/blob_finder.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_finder_test.cc similarity index 96% rename from io/blob_store_test.cc rename to io/blob_finder_test.cc index bb41c7e8..9b85f40d 100644 --- a/io/blob_store_test.cc +++ b/io/blob_finder_test.cc @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "io/blob_store.h" +#include "io/blob_finder.h" #include @@ -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( From 765c37e5ee59772c74a5cfc1bde99f99a4700676 Mon Sep 17 00:00:00 2001 From: Olamiposi Otesile Date: Tue, 6 Jan 2026 22:04:30 +0100 Subject: [PATCH 2/2] Restored original filenames. kept BlobReader to BlobFinder class rename --- CMakeLists.txt | 4 ++-- io/{blob_finder.cc => blob_store.cc} | 6 +++--- io/{blob_finder.h => blob_store.h} | 0 io/{blob_finder_test.cc => blob_store_test.cc} | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename io/{blob_finder.cc => blob_store.cc} (99%) rename io/{blob_finder.h => blob_store.h} (100%) rename io/{blob_finder_test.cc => blob_store_test.cc} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc54a237..4c7fabaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,7 +99,7 @@ set(SOURCES gemma/vit.h gemma/weights.cc gemma/weights.h - io/blob_finder.cc + io/blob_store.cc io/blob_finder.h io/fields.cc io/fields.h @@ -225,7 +225,7 @@ set(GEMMA_TEST_FILES gemma/gemma_args_test.cc gemma/flash_attention_test.cc gemma/tensor_info_test.cc - io/blob_finder_test.cc + io/blob_store_test.cc io/fields_test.cc ops/bench_matmul.cc ops/dot_test.cc diff --git a/io/blob_finder.cc b/io/blob_store.cc similarity index 99% rename from io/blob_finder.cc rename to io/blob_store.cc index c0866b3f..990d0d7a 100644 --- a/io/blob_finder.cc +++ b/io/blob_store.cc @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "io/blob_finder.h" +#include "io/blob_store.h" #include #include @@ -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_finder.h b/io/blob_store.h similarity index 100% rename from io/blob_finder.h rename to io/blob_store.h diff --git a/io/blob_finder_test.cc b/io/blob_store_test.cc similarity index 99% rename from io/blob_finder_test.cc rename to io/blob_store_test.cc index dd27d38f..9a6c047b 100644 --- a/io/blob_finder_test.cc +++ b/io/blob_store_test.cc @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "io/blob_finder.h" +#include "io/blob_store.h" #include