Skip to content

Commit 416b15a

Browse files
authored
chore: better naming for SendableLayoutFuture (#3843)
It's not really a writer, if anything the LayoutStrategy is the LayoutWriter, the thing it returns should be a `SendableLayoutFuture` Signed-off-by: Andrew Duffy <andrew@a10y.dev>
1 parent d8d67f2 commit 416b15a

File tree

10 files changed

+20
-27
lines changed

10 files changed

+20
-27
lines changed

vortex-layout/src/layouts/buffered.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use vortex_array::ArrayContext;
1010

1111
use crate::segments::SequenceWriter;
1212
use crate::{
13-
LayoutStrategy, SendableLayoutWriter, SendableSequentialStream, SequentialStreamAdapter,
13+
LayoutStrategy, SendableLayoutFuture, SendableSequentialStream, SequentialStreamAdapter,
1414
SequentialStreamExt as _,
1515
};
1616

@@ -31,7 +31,7 @@ impl LayoutStrategy for BufferedStrategy {
3131
ctx: &ArrayContext,
3232
sequence_writer: SequenceWriter,
3333
stream: SendableSequentialStream,
34-
) -> SendableLayoutWriter {
34+
) -> SendableLayoutFuture {
3535
let dtype = stream.dtype().clone();
3636
let buffer_size = self.buffer_size;
3737
let buffered_stream = try_stream! {

vortex-layout/src/layouts/chunked/writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::layouts::chunked::ChunkedLayout;
1414
use crate::layouts::flat::writer::FlatLayoutStrategy;
1515
use crate::segments::SequenceWriter;
1616
use crate::{
17-
IntoLayout, LayoutStrategy, SendableLayoutWriter, SendableSequentialStream,
17+
IntoLayout, LayoutStrategy, SendableLayoutFuture, SendableSequentialStream,
1818
SequentialStreamAdapter, SequentialStreamExt as _,
1919
};
2020

@@ -37,7 +37,7 @@ impl LayoutStrategy for ChunkedLayoutStrategy {
3737
ctx: &ArrayContext,
3838
sequence_writer: SequenceWriter,
3939
mut stream: SendableSequentialStream,
40-
) -> SendableLayoutWriter {
40+
) -> SendableLayoutFuture {
4141
let chunk_strategy = self.chunk_strategy.clone();
4242
let ctx = ctx.clone();
4343
Box::pin(async move {

vortex-layout/src/layouts/compressed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use vortex_btrblocks::BtrBlocksCompressor;
1212
use crate::scan::{TaskExecutor, TaskExecutorExt as _};
1313
use crate::segments::SequenceWriter;
1414
use crate::{
15-
LayoutStrategy, SendableLayoutWriter, SendableSequentialStream, SequentialStreamAdapter,
15+
LayoutStrategy, SendableLayoutFuture, SendableSequentialStream, SequentialStreamAdapter,
1616
SequentialStreamExt as _,
1717
};
1818

@@ -43,7 +43,7 @@ impl LayoutStrategy for BtrBlocksCompressedStrategy {
4343
ctx: &ArrayContext,
4444
sequence_writer: SequenceWriter,
4545
stream: SendableSequentialStream,
46-
) -> SendableLayoutWriter {
46+
) -> SendableLayoutFuture {
4747
let executor = self.executor.clone();
4848

4949
let dtype = stream.dtype().clone();

vortex-layout/src/layouts/dict/writer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::scan::{TaskExecutor, TaskExecutorExt as _};
2323
use crate::segments::SequenceWriter;
2424
use crate::sequence::{SequenceId, SequencePointer};
2525
use crate::{
26-
IntoLayout, LayoutStrategy, OwnedLayoutChildren, SendableLayoutWriter,
26+
IntoLayout, LayoutStrategy, OwnedLayoutChildren, SendableLayoutFuture,
2727
SendableSequentialStream, SequentialStreamAdapter, SequentialStreamExt,
2828
};
2929

@@ -83,7 +83,7 @@ impl LayoutStrategy for DictStrategy {
8383
ctx: &ArrayContext,
8484
sequence_writer: SequenceWriter,
8585
stream: SendableSequentialStream,
86-
) -> SendableLayoutWriter {
86+
) -> SendableLayoutFuture {
8787
if !dict_layout_supported(stream.dtype()) {
8888
return self.fallback.write_stream(ctx, sequence_writer, stream);
8989
}

vortex-layout/src/layouts/flat/writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use vortex_scalar::{BinaryScalar, Utf8Scalar};
1212
use crate::layouts::flat::FlatLayout;
1313
use crate::layouts::zoned::{lower_bound, upper_bound};
1414
use crate::segments::SequenceWriter;
15-
use crate::{IntoLayout, LayoutStrategy, SendableLayoutWriter, SendableSequentialStream};
15+
use crate::{IntoLayout, LayoutStrategy, SendableLayoutFuture, SendableSequentialStream};
1616

1717
#[derive(Clone)]
1818
pub struct FlatLayoutStrategy {
@@ -37,7 +37,7 @@ impl LayoutStrategy for FlatLayoutStrategy {
3737
ctx: &ArrayContext,
3838
sequence_writer: SequenceWriter,
3939
mut stream: SendableSequentialStream,
40-
) -> SendableLayoutWriter {
40+
) -> SendableLayoutFuture {
4141
let ctx = ctx.clone();
4242
let options = self.clone();
4343
Box::pin(async move {

vortex-layout/src/layouts/repartition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use vortex_error::{VortexExpect, VortexResult};
1212

1313
use crate::segments::SequenceWriter;
1414
use crate::{
15-
LayoutStrategy, SendableLayoutWriter, SendableSequentialStream, SequentialStreamAdapter,
15+
LayoutStrategy, SendableLayoutFuture, SendableSequentialStream, SequentialStreamAdapter,
1616
SequentialStreamExt,
1717
};
1818

@@ -45,7 +45,7 @@ impl LayoutStrategy for RepartitionStrategy {
4545
ctx: &ArrayContext,
4646
sequence_writer: SequenceWriter,
4747
stream: SendableSequentialStream,
48-
) -> SendableLayoutWriter {
48+
) -> SendableLayoutFuture {
4949
// TODO(os): spawn stream below like:
5050
// canon_stream = stream.map(async {to_canonical}).map(spawn).buffered(parallelism)
5151
let dtype = stream.dtype().clone();

vortex-layout/src/layouts/struct_/writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use vortex_utils::aliases::hash_set::HashSet;
1919
use crate::layouts::struct_::StructLayout;
2020
use crate::segments::SequenceWriter;
2121
use crate::{
22-
IntoLayout as _, LayoutStrategy, SendableLayoutWriter, SendableSequentialStream,
22+
IntoLayout as _, LayoutStrategy, SendableLayoutFuture, SendableSequentialStream,
2323
SequentialStreamAdapter, SequentialStreamExt,
2424
};
2525

@@ -40,7 +40,7 @@ impl LayoutStrategy for StructStrategy {
4040
ctx: &ArrayContext,
4141
sequence_writer: SequenceWriter,
4242
stream: SendableSequentialStream,
43-
) -> SendableLayoutWriter {
43+
) -> SendableLayoutFuture {
4444
let dtype = stream.dtype().clone();
4545
let Some(struct_dtype) = stream.dtype().as_struct().cloned() else {
4646
// nothing we can do if dtype is not struct

vortex-layout/src/layouts/zoned/writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::scan::{TaskExecutor, TaskExecutorExt};
1919
use crate::segments::SequenceWriter;
2020
use crate::sequence::SequenceId;
2121
use crate::{
22-
IntoLayout, LayoutStrategy, SendableLayoutWriter, SendableSequentialStream,
22+
IntoLayout, LayoutStrategy, SendableLayoutFuture, SendableSequentialStream,
2323
SequentialStreamAdapter, SequentialStreamExt,
2424
};
2525

@@ -74,7 +74,7 @@ impl LayoutStrategy for ZonedStrategy {
7474
ctx: &ArrayContext,
7575
sequence_writer: SequenceWriter,
7676
stream: SendableSequentialStream,
77-
) -> SendableLayoutWriter {
77+
) -> SendableLayoutFuture {
7878
let executor = self.executor.clone();
7979
let stats = self.options.stats.clone();
8080
let precomputed_stream = SequentialStreamAdapter::new(

vortex-layout/src/strategy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use vortex_array::{ArrayContext, ArrayRef};
1515
use vortex_dtype::DType;
1616
use vortex_error::VortexResult;
1717

18-
use crate::SendableLayoutWriter;
18+
use crate::SendableLayoutFuture;
1919
use crate::segments::SequenceWriter;
2020
use crate::sequence::SequenceId;
2121

@@ -37,7 +37,7 @@ pub trait LayoutStrategy: 'static + Send + Sync {
3737
ctx: &ArrayContext,
3838
sequence_writer: SequenceWriter,
3939
stream: SendableSequentialStream,
40-
) -> SendableLayoutWriter;
40+
) -> SendableLayoutFuture;
4141
}
4242

4343
pub trait SequentialStreamExt: SequentialStream {

vortex-layout/src/writer.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4-
use std::pin::Pin;
5-
4+
use futures::future::BoxFuture;
65
use vortex_error::VortexResult;
76

87
use crate::LayoutRef;
@@ -11,11 +10,5 @@ use crate::LayoutRef;
1110
/// trait to be potentially extended with new methods.
1211
// Tag for Python docs:
1312
// [layout writer]
14-
pub trait LayoutWriter: Future<Output = VortexResult<LayoutRef>> {}
13+
pub type SendableLayoutFuture = BoxFuture<'static, VortexResult<LayoutRef>>;
1514
// [layout writer]
16-
17-
// Allow async blocks to impl LayoutWriter, this would change if more methods
18-
// are added to LayoutWriter.
19-
impl<F: Future<Output = VortexResult<LayoutRef>> + ?Sized + Send> LayoutWriter for F {}
20-
21-
pub type SendableLayoutWriter = Pin<Box<dyn LayoutWriter + Send>>;

0 commit comments

Comments
 (0)