lucene icon indicating copy to clipboard operation
lucene copied to clipboard

Introduce annotation to indicate when a DocIdStream implementation can be replayed

Open javasoze opened this issue 1 month ago • 2 comments

Description

Sometimes a DocIdStream can be replayed, e.g. RangeDocIdStream, there is not iterator state kept with the instance.

Proposal:

Introduce an annotation

@Retention(RetentionPolicy.RUNTIME)
public @interface Replayable {
}

To indicate a DocIdStream can be replayed.

javasoze avatar Dec 05 '25 13:12 javasoze

Wouldn't an empty marker interface be easier to work with? Anyway, such changes should probably be motivated by something else, otherwise they lack the necessary context for saying if it's right or wrong.

dweiss avatar Dec 05 '25 18:12 dweiss

Yup, empty marker interface does exactly the samething, annotation is just prettier and allows for future parameters support. But in this context, no difference.

DocIdStreams are like iterators, it can be only scanned through once. But nothing in the api that prohibits it to be reused.

If we were to pass the same DocIdStream to multiple aggregators, without knowing it can be replayed, it needs to be reconstructed.

javasoze avatar Dec 05 '25 18:12 javasoze