Skip to content

[WIP: DO NOT MERGE] KAFKA-3522: Allow storing timestamps in RocksDB#6044

Closed
mjsax wants to merge 2 commits intoapache:trunkfrom
mjsax:kafka-3522-rocksdb-format-column-family
Closed

[WIP: DO NOT MERGE] KAFKA-3522: Allow storing timestamps in RocksDB#6044
mjsax wants to merge 2 commits intoapache:trunkfrom
mjsax:kafka-3522-rocksdb-format-column-family

Conversation

@mjsax
Copy link
Copy Markdown
Member

@mjsax mjsax commented Dec 17, 2018

No description provided.

@mjsax mjsax mentioned this pull request Dec 20, 2018
* @param aggregate the aggregated value for the session, it can be {@code null};
* if the serialized bytes are also {@code null} it is interpreted as deletes
* @param timestamp the timestamp for the session; ignored if {@code aggregate} is {@code null}
* @throws NullPointerException If null is used for sessionKey.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to document runtime exceptions like this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It common practice in Kafka (at least for Streams API) to document those. Some API accept null and others don't. It would be bad user experience to find out via trial-and-error IMHO.

* @param <K> Type of keys
* @param <V> Type of values
*/
public interface WindowWithTimestampStore<K, V> extends WindowStore<K, ValueAndTimestamp<V>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to parse this class name -- sounds like "trait Window with TimestampStore" instead of WindowStore<... ValueAndTimestamp...>

Maybe TimestampWindowStore or TimestampedWindowStore? shrug.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Please follow up on the DISCUSS thread on the dev mailing list with this. All public API changes should be discussed there.

*/
class Segments {
private static final Logger log = LoggerFactory.getLogger(Segments.class);
abstract class AbstractSegments<S extends Segment> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommend sticking with T, U, V (or A, B, C for higher-kinded) type parameters

import org.apache.kafka.streams.processor.internals.ProcessorRecordContext;
import org.apache.kafka.streams.state.KeyValueStore;

class CachingKeyValueWithTimestampStore<K, V> extends CachingKeyValueStore<K, V> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here -- sounds like CachingKeyValue with TimestampStore

super(underlying, keySerde, valueSerde);
}

void putAndMaybeForward(final ThreadCache.DirtyEntry entry, final InternalProcessorContext context) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

large and deeply nested method here -- recommend splitting into multiple smaller private methods where possible

* Simple wrapper around a {@link SegmentedBytesStore} to support writing
* updates to a changelog
*/
class ChangeLoggingWindowWithTimestampBytesStore extends ChangeLoggingWindowBytesStore {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid these very long class names, consider adding a factory method like ChangeLoggingWindowByteStore.newWithTimestamp() or something

*/
class ChangeLoggingWindowWithTimestampBytesStore extends ChangeLoggingWindowBytesStore {

ChangeLoggingWindowWithTimestampBytesStore(final WindowStore<Bytes, byte[]> bytesStore,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this wrapper just exposes a new constructor, consider making it a factory method instead

* @param <K> The key type
* @param <V> The value type
*/
public interface KeyValueWithTimestampStore<K, V> extends KeyValueStore<K, ValueAndTimestamp<V>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possible alternative: implement KeyValueStore<K, V>, and then expose an additional putWithTimestamp, getWithTimestamp etc for callers that want ValueAndTimestamp<V> instead of V. This would probably require fewer code changes elsewhere.

},
restoreTime);
} else {
inner.init(context, root);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pattern of if (shouldRecord) measureLatency(X) else X is not very DRY. You have this same condition (shouldRecord) in several places, and the code for measureLatency(X) vs X is essentially copy-pasted.

Instead, add maybeMeasureLatency(f, sensor) with if (sensor.shouldRecord()) ... .

}
}

private interface Action<V> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this just be Producer<ValueAndTimestamp<V>> ?

@mjsax mjsax added the streams label Jan 3, 2019
@mjsax mjsax closed this Mar 7, 2019
@mjsax mjsax deleted the kafka-3522-rocksdb-format-column-family branch March 9, 2019 20:35
@mjsax mjsax added the kip Requires or implements a KIP label Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kip Requires or implements a KIP streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants