-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add table indexes API #11576
Add table indexes API #11576
Conversation
Codecov Report
@@ Coverage Diff @@
## master #11576 +/- ##
============================================
+ Coverage 14.51% 14.54% +0.02%
Complexity 201 201
============================================
Files 2323 2324 +1
Lines 124465 124534 +69
Branches 18989 18994 +5
============================================
+ Hits 18071 18109 +38
- Misses 104877 104906 +29
- Partials 1517 1519 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 5 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@Produces(MediaType.APPLICATION_JSON) | ||
@ApiOperation(value = "Get the aggregate index details of all segments for a table", notes = "Get the aggregate " | ||
+ "index details of all segments for a table") | ||
public String getTableIndexes( |
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.
Since this is a new API, shouldn't we have tests to validate its behavior?
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.
Ack. added tests
response = ErrorInfo.class), @ApiResponse(code = 404, message = "Table or segment not found", response = | ||
ErrorInfo.class) | ||
}) | ||
public String getTableIndexes( |
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.
Likewise, shouldn't we have some unit tests and integration tests to validate this new API?
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.
Ack. added tests
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.
Had one question about tests.
public void getTableIndexes() | ||
throws Exception { | ||
String tableIndexesPath = | ||
"/tables/" + TableNameBuilder.forType(TableType.OFFLINE).tableNameWithType(TABLE_NAME) + "/indexes"; |
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.
Do we also need to test this for RT tables?
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.
LGTM
long totalSegmentCount = 0; | ||
Map<String, Map<String, Long>> columnToIndexesCount = new HashMap<>(); | ||
for (SegmentDataManager segmentDataManager : allSegments) { | ||
if (segmentDataManager instanceof RealtimeSegmentDataManager) { |
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.
In the documentation, let's mention that consuming segment is not counted to avoid confusion
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.
Ack
TableDataManager tableDataManager = ServerResourceUtils.checkGetTableDataManager(_serverInstance, tableName); | ||
List<SegmentDataManager> allSegments = tableDataManager.acquireAllSegments(); | ||
try { | ||
long totalSegmentCount = 0; |
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.
(minor) long
seems not necessary, same for the index count
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.
Ack
columnToIndexCountMap.putIfAbsent(col, new HashMap<>()); | ||
|
||
indexToCount.forEach((indexName, count) -> { | ||
columnToIndexCountMap.get(col) | ||
.put(indexName, columnToIndexCountMap.get(col).getOrDefault(indexName, 0L) + count); | ||
}); |
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.
Reduce map lookup
columnToIndexCountMap.putIfAbsent(col, new HashMap<>()); | |
indexToCount.forEach((indexName, count) -> { | |
columnToIndexCountMap.get(col) | |
.put(indexName, columnToIndexCountMap.get(col).getOrDefault(indexName, 0L) + count); | |
}); | |
Map<String, Integer> indexCountMap = columnToIndexCountMap.computeIfAbsent(col, new HashMap<>()); | |
indexToCount.forEach((indexName, count) -> { | |
indexCountMap.compute(col, (k, v) -> v != null ? v + count : count); | |
}); |
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.
Ack
def1e04
to
0b9a468
Compare
0b9a468
to
a4e1370
Compare
This API is primarily for the controller UI -> tables ->
-> reload status -> STATUS ui element. Right now it uses the/segments/{tableName}/metadata?type={type}&columns=*
API to display the column level index details. This has a few problemsThis new API's reponse looks like this
The
totalSegments
is the total count ofONLINE
segments (replication included). Since mutable version of all indexes don't exist,CONSUMING
segments will not be used when building the response.I'll followup with @jayeshchoudhary to move the UI API call to this new one, and how best to display the UI element once this PR is merged.