Skip to content

Commit

Permalink
Use aliases ReadChunkReceiver & WriteChunkReceiver
Browse files Browse the repository at this point in the history
Qualify span<T> in some places.

PiperOrigin-RevId: 657319989
Change-Id: I97614161b598437b033ab799c28727ea1930518f
  • Loading branch information
laramiel authored and tkiela1 committed Jul 29, 2024
1 parent 07bbe1a commit 2f65bf2
Show file tree
Hide file tree
Showing 21 changed files with 155 additions and 200 deletions.
9 changes: 1 addition & 8 deletions tensorstore/driver/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ tensorstore_cc_library(
name = "chunk",
hdrs = ["chunk.h"],
deps = [
"//tensorstore:index",
"//tensorstore:read_write_options",
"//tensorstore/index_space:index_transform",
"//tensorstore/index_space:transformed_array",
Expand All @@ -68,7 +67,7 @@ tensorstore_cc_library(
"//tensorstore/internal/poly",
"//tensorstore/util:future",
"//tensorstore/util:result",
"//tensorstore/util:span",
"//tensorstore/util/execution:any_receiver",
"@com_google_absl//absl/functional:function_ref",
"@com_google_absl//absl/status",
],
Expand All @@ -83,14 +82,10 @@ tensorstore_cc_library(
"//tensorstore:data_type",
"//tensorstore:index",
"//tensorstore:staleness_bound",
"//tensorstore:transaction",
"//tensorstore/index_space:index_transform",
"//tensorstore/internal:chunk_grid_specification",
"//tensorstore/internal/cache",
"//tensorstore/internal/cache:chunk_cache",
"//tensorstore/util:executor",
"//tensorstore/util/execution:any_receiver",
"@com_google_absl//absl/status",
],
)

Expand Down Expand Up @@ -169,7 +164,6 @@ tensorstore_cc_library(
"//tensorstore/util:status",
"//tensorstore/util:str_cat",
"//tensorstore/util/execution",
"//tensorstore/util/execution:any_receiver",
"//tensorstore/util/execution:sender",
"//tensorstore/util/execution:sender_util",
"//tensorstore/util/garbage_collection",
Expand All @@ -185,7 +179,6 @@ tensorstore_cc_test(
size = "small",
srcs = ["driver_test.cc"],
deps = [
":chunk",
":driver",
"//tensorstore:array",
"//tensorstore:data_type",
Expand Down
1 change: 0 additions & 1 deletion tensorstore/driver/array/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ tensorstore_cc_library(
"//tensorstore/util:status",
"//tensorstore/util:str_cat",
"//tensorstore/util/execution",
"//tensorstore/util/execution:any_receiver",
"//tensorstore/util/garbage_collection",
"@com_google_absl//absl/status",
"@com_google_absl//absl/synchronization",
Expand Down
17 changes: 4 additions & 13 deletions tensorstore/driver/array/array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
#include "tensorstore/strided_layout.h"
#include "tensorstore/transaction.h"
#include "tensorstore/util/constant_vector.h"
#include "tensorstore/util/execution/any_receiver.h"
#include "tensorstore/util/execution/execution.h"
#include "tensorstore/util/executor.h"
#include "tensorstore/util/future.h"
Expand Down Expand Up @@ -215,13 +214,9 @@ class ArrayDriver

Future<IndexTransform<>> ResolveBounds(ResolveBoundsRequest request) override;

void Read(ReadRequest request,
AnyFlowReceiver<absl::Status, ReadChunk, IndexTransform<>> receiver)
override;
void Read(ReadRequest request, ReadChunkReceiver receiver) override;

void Write(WriteRequest request,
AnyFlowReceiver<absl::Status, WriteChunk, IndexTransform<>>
receiver) override;
void Write(WriteRequest request, WriteChunkReceiver receiver) override;

DataType dtype() override { return data_.dtype(); }

Expand Down Expand Up @@ -266,9 +261,7 @@ Future<IndexTransform<>> ArrayDriver::ResolveBounds(
std::move(request.transform));
}

void ArrayDriver::Read(
ReadRequest request,
AnyFlowReceiver<absl::Status, ReadChunk, IndexTransform<>> receiver) {
void ArrayDriver::Read(ReadRequest request, ReadChunkReceiver receiver) {
// Implementation of `tensorstore::ReadChunk::Impl` Poly interface.
struct ChunkImpl {
IntrusivePtr<ArrayDriver> self;
Expand Down Expand Up @@ -300,9 +293,7 @@ void ArrayDriver::Read(
execution::set_stopping(receiver);
}

void ArrayDriver::Write(
WriteRequest request,
AnyFlowReceiver<absl::Status, WriteChunk, IndexTransform<>> receiver) {
void ArrayDriver::Write(WriteRequest request, WriteChunkReceiver receiver) {
// Implementation of `tensorstore::internal::WriteChunk::Impl` Poly interface.
struct ChunkImpl {
IntrusivePtr<ArrayDriver> self;
Expand Down
2 changes: 0 additions & 2 deletions tensorstore/driver/cast/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ tensorstore_cc_library(
"//tensorstore:open_mode",
"//tensorstore:open_options",
"//tensorstore:rank",
"//tensorstore:resize_options",
"//tensorstore:schema",
"//tensorstore:spec",
"//tensorstore:transaction",
Expand All @@ -57,7 +56,6 @@ tensorstore_cc_library(
"//tensorstore/util:future",
"//tensorstore/util:iterate",
"//tensorstore/util:result",
"//tensorstore/util:span",
"//tensorstore/util:status",
"//tensorstore/util:str_cat",
"//tensorstore/util/execution",
Expand Down
18 changes: 4 additions & 14 deletions tensorstore/driver/cast/cast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include "tensorstore/open_mode.h"
#include "tensorstore/open_options.h"
#include "tensorstore/rank.h"
#include "tensorstore/resize_options.h"
#include "tensorstore/schema.h"
#include "tensorstore/spec.h"
#include "tensorstore/transaction.h"
Expand All @@ -56,7 +55,6 @@
#include "tensorstore/util/future.h"
#include "tensorstore/util/iterate.h"
#include "tensorstore/util/result.h"
#include "tensorstore/util/span.h"
#include "tensorstore/util/status.h"
#include "tensorstore/util/str_cat.h"

Expand Down Expand Up @@ -269,13 +267,9 @@ class CastDriver
return base_driver_->data_copy_executor();
}

void Read(ReadRequest request,
AnyFlowReceiver<absl::Status, ReadChunk, IndexTransform<>> receiver)
override;
void Read(ReadRequest request, ReadChunkReceiver receiver) override;

void Write(WriteRequest request,
AnyFlowReceiver<absl::Status, WriteChunk, IndexTransform<>>
receiver) override;
void Write(WriteRequest request, WriteChunkReceiver receiver) override;

Future<IndexTransform<>> ResolveBounds(
ResolveBoundsRequest request) override {
Expand Down Expand Up @@ -382,17 +376,13 @@ struct ChunkReceiverAdapter {
void set_stopping() { tensorstore::execution::set_stopping(base); }
};

void CastDriver::Read(
ReadRequest request,
AnyFlowReceiver<absl::Status, ReadChunk, IndexTransform<>> receiver) {
void CastDriver::Read(ReadRequest request, ReadChunkReceiver receiver) {
base_driver_->Read(std::move(request),
ChunkReceiverAdapter<ReadChunk, ReadChunkImpl>{
IntrusivePtr<CastDriver>(this), std::move(receiver)});
}

void CastDriver::Write(
WriteRequest request,
AnyFlowReceiver<absl::Status, WriteChunk, IndexTransform<>> receiver) {
void CastDriver::Write(WriteRequest request, WriteChunkReceiver receiver) {
base_driver_->Write(std::move(request),
ChunkReceiverAdapter<WriteChunk, WriteChunkImpl>{
IntrusivePtr<CastDriver>(this), std::move(receiver)});
Expand Down
9 changes: 7 additions & 2 deletions tensorstore/driver/chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@

#include "absl/functional/function_ref.h"
#include "absl/status/status.h"
#include "tensorstore/index.h"
#include "tensorstore/index_space/index_transform.h"
#include "tensorstore/index_space/transformed_array.h"
#include "tensorstore/internal/arena.h"
#include "tensorstore/internal/lock_collection.h"
#include "tensorstore/internal/nditerable.h"
#include "tensorstore/internal/poly/poly.h"
#include "tensorstore/read_write_options.h"
#include "tensorstore/util/execution/any_receiver.h"
#include "tensorstore/util/future.h"
#include "tensorstore/util/result.h"
#include "tensorstore/util/span.h"

namespace tensorstore {
namespace internal {
Expand Down Expand Up @@ -82,6 +81,9 @@ struct ReadChunk {
IndexTransform<> transform;
};

using ReadChunkReceiver =
AnyFlowReceiver<absl::Status, ReadChunk, IndexTransform<>>;

struct WriteChunk {
struct BeginWrite {};
struct EndWrite {};
Expand Down Expand Up @@ -193,6 +195,9 @@ struct WriteChunk {
IndexTransform<> transform;
};

using WriteChunkReceiver =
AnyFlowReceiver<absl::Status, WriteChunk, IndexTransform<>>;

/// Attempts to lock one or more `ReadChunk`/`WriteChunk` objects.
///
/// If registering a chunk with the lock collection fails, the error propagates
Expand Down
11 changes: 2 additions & 9 deletions tensorstore/driver/chunk_cache_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@
#include <cassert>
#include <utility>

#include "absl/status/status.h"
#include "tensorstore/data_type.h"
#include "tensorstore/driver/chunk.h"
#include "tensorstore/driver/driver.h"
#include "tensorstore/index.h"
#include "tensorstore/index_space/index_transform.h"
#include "tensorstore/internal/cache/cache.h"
#include "tensorstore/internal/cache/chunk_cache.h"
#include "tensorstore/internal/chunk_grid_specification.h"
#include "tensorstore/staleness_bound.h"
#include "tensorstore/transaction.h"
#include "tensorstore/util/execution/any_receiver.h"
#include "tensorstore/util/executor.h"

namespace tensorstore {
Expand All @@ -48,9 +44,7 @@ template <typename Derived, typename Parent>
class ChunkCacheReadWriteDriverMixin : public Parent {
public:
/// Simply forwards to `ChunkCache::Read`.
void Read(Driver::ReadRequest request,
AnyFlowReceiver<absl::Status, ReadChunk, IndexTransform<>> receiver)
override {
void Read(Driver::ReadRequest request, ReadChunkReceiver receiver) override {
static_cast<Derived*>(this)->cache()->Read(
{std::move(request), static_cast<Derived*>(this)->component_index(),
static_cast<Derived*>(this)->data_staleness_bound().time},
Expand All @@ -59,8 +53,7 @@ class ChunkCacheReadWriteDriverMixin : public Parent {

/// Simply forwards to `ChunkCache::Write`.
void Write(Driver::WriteRequest request,
AnyFlowReceiver<absl::Status, WriteChunk, IndexTransform<>>
receiver) override {
WriteChunkReceiver receiver) override {
static_cast<Derived*>(this)->cache()->Write(
{std::move(request), static_cast<Derived*>(this)->component_index()},
std::move(receiver));
Expand Down
1 change: 0 additions & 1 deletion tensorstore/driver/downsample/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ tensorstore_cc_library(
"//tensorstore/util:status",
"//tensorstore/util:str_cat",
"//tensorstore/util/execution",
"//tensorstore/util/execution:any_receiver",
"//tensorstore/util/execution:sender_util",
"//tensorstore/util/garbage_collection",
"@com_google_absl//absl/base:core_headers",
Expand Down
30 changes: 14 additions & 16 deletions tensorstore/driver/downsample/downsample.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
#include "tensorstore/serialization/std_vector.h" // IWYU pragma: keep
#include "tensorstore/spec.h"
#include "tensorstore/transaction.h"
#include "tensorstore/util/execution/any_receiver.h"
#include "tensorstore/util/execution/execution.h"
#include "tensorstore/util/execution/sender_util.h"
#include "tensorstore/util/executor.h"
Expand Down Expand Up @@ -111,7 +110,8 @@ namespace jb = tensorstore::internal_json_binding;
/// \dchecks `downsampled_domain.valid()`
/// \dchecks `downsampled_domain.rank() == downsample_factors.size()`
Result<IndexDomain<>> GetBaseDomainConstraintFromDownsampledDomain(
IndexDomain<> downsampled_domain, span<const Index> downsample_factors) {
IndexDomain<> downsampled_domain,
tensorstore::span<const Index> downsample_factors) {
assert(downsampled_domain.valid());
const DimensionIndex rank = downsampled_domain.rank();
assert(rank == downsample_factors.size());
Expand Down Expand Up @@ -140,7 +140,8 @@ Result<IndexDomain<>> GetBaseDomainConstraintFromDownsampledDomain(
Result<IndexTransform<>> GetBaseTransformForDownsampledTransform(
IndexTransformView<> base_transform,
IndexTransformView<> downsampled_transform,
span<const Index> downsample_factors, DownsampleMethod downsample_method) {
tensorstore::span<const Index> downsample_factors,
DownsampleMethod downsample_method) {
if (downsample_method == DownsampleMethod::kStride) {
return base_transform | tensorstore::AllDims().Stride(downsample_factors) |
downsampled_transform;
Expand Down Expand Up @@ -281,7 +282,8 @@ class DownsampleDriverSpec
TENSORSTORE_ASSIGN_OR_RETURN(auto dimension_units,
internal::GetEffectiveDimensionUnits(base));
if (!dimension_units.empty()) {
span<const Index> downsample_factors = this->downsample_factors;
tensorstore::span<const Index> downsample_factors =
this->downsample_factors;
TENSORSTORE_ASSIGN_OR_RETURN(
auto transform,
tensorstore::IdentityTransform(downsample_factors.size()) |
Expand Down Expand Up @@ -431,7 +433,7 @@ class DownsampleDriver
GetStorageStatisticsRequest request) override;

explicit DownsampleDriver(DriverPtr base, IndexTransform<> base_transform,
span<const Index> downsample_factors,
tensorstore::span<const Index> downsample_factors,
DownsampleMethod downsample_method)
: base_driver_(std::move(base)),
base_transform_(std::move(base_transform)),
Expand All @@ -446,9 +448,7 @@ class DownsampleDriver
return base_driver_->data_copy_executor();
}

void Read(ReadRequest request,
AnyFlowReceiver<absl::Status, ReadChunk, IndexTransform<>> receiver)
override;
void Read(ReadRequest request, ReadChunkReceiver receiver) override;

Result<IndexTransform<>> GetStridedBaseTransform() {
return base_transform_ | tensorstore::AllDims().Stride(downsample_factors_);
Expand Down Expand Up @@ -543,7 +543,7 @@ struct ReadState : public internal::AtomicReferenceCount<ReadState> {
IntrusivePtr<DownsampleDriver> self_;

/// Receiver of downsampled chunks.
AnyFlowReceiver<absl::Status, ReadChunk, IndexTransform<>> receiver_;
internal::ReadChunkReceiver receiver_;

/// Protects access to most other members.
absl::Mutex mutex_;
Expand Down Expand Up @@ -706,7 +706,7 @@ struct BufferedReadChunkImpl {
/// assumed to be singleton dimensions and are not used by any output index
/// maps.
IndexTransform<> GetDownsampledRequestIdentityTransform(
BoxView<> base_domain, span<const Index> downsample_factors,
BoxView<> base_domain, tensorstore::span<const Index> downsample_factors,
DownsampleMethod downsample_method, DimensionIndex request_rank) {
// Construct the `request_transform` to send to the receiver, which is simply
// an identity transform over the first `request_rank` dimensions. The
Expand Down Expand Up @@ -748,7 +748,7 @@ void ReadState::EmitBufferedChunks() {
// Iterate over grid cells that haven't been independently emitted.
const DimensionIndex rank = emitted_chunk_map.rank();
Index grid_cell[kMaxRank];
span<Index> grid_cell_span(&grid_cell[0], rank);
tensorstore::span<Index> grid_cell_span(&grid_cell[0], rank);
Box<dynamic_rank(internal::kNumInlinedDims)> grid_cell_domain;
grid_cell_domain.set_rank(rank);
emitted_chunk_map.InitializeCellIterator(grid_cell_span);
Expand Down Expand Up @@ -962,9 +962,7 @@ struct ReadReceiverImpl {
}
};

void DownsampleDriver::Read(
ReadRequest request,
AnyFlowReceiver<absl::Status, ReadChunk, IndexTransform<>> receiver) {
void DownsampleDriver::Read(ReadRequest request, ReadChunkReceiver receiver) {
if (downsample_method_ == DownsampleMethod::kStride) {
// Stride-based downsampling just relies on the normal `IndexTransform`
// machinery.
Expand Down Expand Up @@ -1064,7 +1062,7 @@ const internal::DriverRegistration<DownsampleDriverSpec> driver_registration;
namespace internal {

Result<Driver::Handle> MakeDownsampleDriver(
Driver::Handle base, span<const Index> downsample_factors,
Driver::Handle base, tensorstore::span<const Index> downsample_factors,
DownsampleMethod downsample_method) {
if (downsample_factors.size() != base.transform.input_rank()) {
return absl::InvalidArgumentError(tensorstore::StrCat(
Expand Down Expand Up @@ -1097,7 +1095,7 @@ Result<Driver::Handle> MakeDownsampleDriver(
} // namespace internal

Result<Spec> Downsample(const Spec& base_spec,
span<const Index> downsample_factors,
tensorstore::span<const Index> downsample_factors,
DownsampleMethod downsample_method) {
using internal_spec::SpecAccess;
Spec downsampled_spec;
Expand Down
Loading

0 comments on commit 2f65bf2

Please sign in to comment.