aliehsaeedii commented on PR #21830:
URL: https://github.com/apache/kafka/pull/21830#issuecomment-4934288764
One more thing I noticed now: the same duplication you just removed still
lives in the two *window-store* iterator adapters:
- `PlainToHeadersWindowStoreIteratorAdapter` (top-level class)
- `TimestampedWindowToHeadersWindowStoreIteratorAdapter` (private nested
class in `TimestampedToHeadersWindowStoreAdapter`)
Both have no body beyond `extends MappingKeyValueIteratorAdapter<Long>
implements WindowStoreIterator<byte[]>` and differ only by the mapper
(`convertFromPlainToHeaderFormat` vs `convertToHeaderFormat`) — the only reason
they exist as subclasses is to carry the `WindowStoreIterator` marker on the
return type. Since this is exactly the pattern this PR set out to eliminate,
I'd suggest finishing the job here for consistency: add window-flavored
factories to `MappingKeyValueIteratorAdapter` backed by a single private inner
subclass, e.g.
```java
private static final class WindowStoreIteratorAdapter
extends MappingKeyValueIteratorAdapter<Long>
implements WindowStoreIterator<byte[]> {
WindowStoreIteratorAdapter(final KeyValueIterator<Long, byte[]> inner,
final Function<byte[], byte[]> mapper) {
super(inner, mapper);
}
}
static WindowStoreIterator<byte[]> plainToHeadersWindow(final
KeyValueIterator<Long, byte[]> inner) {
return new WindowStoreIteratorAdapter(inner,
HeadersBytesStore::convertFromPlainToHeaderFormat);
}
static WindowStoreIterator<byte[]> timestampedToHeadersWindow(final
KeyValueIterator<Long, byte[]> inner) {
return new WindowStoreIteratorAdapter(inner,
HeadersBytesStore::convertToHeaderFormat);
}
```
Then both window iterator classes can be deleted and their call sites
updated. No behavior change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]