Re: [PATCH 14/18] streaming: make the `odb_read_stream` definition public
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Nov 19, 2025, 16:27 UTC
- Message-ID
- <CAOLa=ZT_VFfbfLVdvHUqK5C6k4zROLQs0Pt5rOWL_hE_BSfGeg@mail.gmail.com>
- In-Reply-To
- <20251119-b4-pks-odb-read-stream-v1-14-adacf03c2ccf@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 5 quoted lines
> Subsequent commits will move the backend-specific logic of setting up an > object read stream into the specific subsystems. As the backends are now > the ones that are responsible for allocating the stream they'll need to > have the stream definition available to them. >
This was a question I had in mind in one of the previous patches, looks like we're going in that direction. Makes sense to me.
Show 63 quoted lines
> Make the stream definition public to prepare for this.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> streaming.c | 11 -----------
> streaming.h | 15 ++++++++++++++-
> 2 files changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/streaming.c b/streaming.c
> index 9e20e9a882..3f94bd2a03 100644
> --- a/streaming.c
> +++ b/streaming.c
> @@ -12,19 +12,8 @@
> #include "replace-object.h"
> #include "packfile.h"
>
> -typedef int (*close_istream_fn)(struct odb_read_stream *);
> -typedef ssize_t (*read_istream_fn)(struct odb_read_stream *, char *, size_t);
> -
> #define FILTER_BUFFER (1024*16)
>
> -struct odb_read_stream {
> - close_istream_fn close;
> - read_istream_fn read;
> -
> - enum object_type type;
> - unsigned long size; /* inflated size of full object */
> -};
> -
> /*****************************************************************
> *
> * Filtered stream
> diff --git a/streaming.h b/streaming.h
> index 95c2a434fa..3a850e3efc 100644
> --- a/streaming.h
> +++ b/streaming.h
> @@ -6,11 +6,24 @@
>
> #include "object.h"
>
> -/* opaque */
> struct object_database;
> struct odb_read_stream;
> struct stream_filter;
>
> +typedef int (*odb_read_stream_close_fn)(struct odb_read_stream *);
> +typedef ssize_t (*odb_read_stream_read_fn)(struct odb_read_stream *, char *, size_t);
> +
> +/*
> + * A stream that can be used to read an object from the object database without
> + * loading all of it into memory.
> + */
> +struct odb_read_stream {
> + odb_read_stream_close_fn close;
> + odb_read_stream_read_fn read;
> + enum object_type type;
> + unsigned long size; /* inflated size of full object */
> +};
> +
> struct odb_read_stream *open_istream(struct repository *, const struct object_id *,
> enum object_type *, unsigned long *,
> struct stream_filter *);
>If we're returning an `struct odb_read_stream` anyways, why take in pointers for object size and object type? They'll be the same as `odb_read_stream.type` and `odb_read_stream.size` no?