-
Notifications
You must be signed in to change notification settings - Fork 15.1k
MINOR: improve generic type safety for IQv2 in metered-store layer #21683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,8 +103,7 @@ public class MeteredKeyValueStore<K, V> | |
| protected NavigableSet<MeteredIterator> openIterators = new ConcurrentSkipListSet<>(Comparator.comparingLong(MeteredIterator::startTimestamp)); | ||
|
|
||
|
|
||
| @SuppressWarnings("rawtypes") | ||
| private final Map<Class, QueryHandler> queryHandlers = | ||
| private final Map<Class<?>, QueryHandler<?>> queryHandlers = | ||
| mkMap( | ||
| mkEntry( | ||
| RangeQuery.class, | ||
|
|
@@ -230,31 +229,29 @@ record -> { | |
|
|
||
| @SuppressWarnings("unchecked") | ||
| @Override | ||
| public <R> QueryResult<R> query(final Query<R> query, | ||
| final PositionBound positionBound, | ||
| final QueryConfig config) { | ||
|
|
||
| public <R> QueryResult<R> query( | ||
| final Query<R> query, | ||
| final PositionBound positionBound, | ||
| final QueryConfig config | ||
| ) { | ||
| final long start = time.nanoseconds(); | ||
| final QueryResult<R> result; | ||
|
|
||
| final QueryHandler handler = queryHandlers.get(query.getClass()); | ||
| final QueryHandler<?> handler = queryHandlers.get(query.getClass()); | ||
| if (handler == null) { | ||
| result = wrapped().query(query, positionBound, config); | ||
| if (config.isCollectExecutionInfo()) { | ||
| result.addExecutionInfo( | ||
| "Handled in " + getClass() + " in " + (time.nanoseconds() - start) + "ns"); | ||
| result.addExecutionInfo("Handled in " + getClass() + " in " + (time.nanoseconds() - start) + "ns"); | ||
| } | ||
| } else { | ||
| result = (QueryResult<R>) handler.apply( | ||
| result = ((QueryHandler<R>) handler).apply( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That we have improved type check on the the This is still cleaner. The issue is with the (similar elsewhere in this PR) |
||
| query, | ||
| positionBound, | ||
| config, | ||
| this | ||
| ); | ||
| if (config.isCollectExecutionInfo()) { | ||
| result.addExecutionInfo( | ||
| "Handled in " + getClass() + " with serdes " | ||
| + serdes + " in " + (time.nanoseconds() - start) + "ns"); | ||
| result.addExecutionInfo("Handled in " + getClass() + " with serdes " + serdes + " in " + (time.nanoseconds() - start) + "ns"); | ||
| } | ||
| } | ||
| return result; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we cannot have safe types, make it explicit using
<?>(similar elsewhere)