Re: [PATCH v2 06/11] reftable/writer: refactorings for `writer_add_record()`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Apr 4, 2024, 07:32 UTC
- Message-ID
- <Zg5XhYq802lG4AgU@tanuki>
- In-Reply-To
- <CAOw_e7YeqEK4O=KWowMYGtRVMLwL3y6bWw2LRfC9TqJz06Esyg@mail.gmail.com>
On Thu, Apr 04, 2024 at 08:58:08AM +0200, Han-Wen Nienhuys wrote:
Show 16 quoted lines
> On Thu, Apr 4, 2024 at 7:48 AM Patrick Steinhardt <ps@pks.im> wrote: > > + /* > > + * Try to add the record to the writer again. If this still fails then > > + * the record does not fit into the block size. > > + * > > + * TODO: it would be great to have `block_writer_add()` return proper > > + * error codes so that we don't have to second-guess the failure > > + * mode here. > > + */ > > The Go code returns a (size, boolean) tuple for the write routines > here, but that does not really work in the Git C style. > > If you make the routines return error codes it suggests that the > in-memory write can fail for other reasons beyond "does not fit". Not > sure if that is really an improvement.
In reality, `block_writer_add()` already can fail because of different reasons: it returns `REFTABLE_API_ERROR` if the passed-in record has an empty key. This shouldn't ever happen, but it demonstrates that this is certainly an area which needs some further cleanups.
Patrick