-
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
show table metadata info in aggregate index size form #9733
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import java.util.List; | ||
import javax.ws.rs.core.Response; | ||
import org.apache.commons.io.FileUtils; | ||
import org.apache.pinot.common.restlet.resources.TableMetadataInfo; | ||
import org.apache.pinot.common.restlet.resources.TableSegments; | ||
import org.apache.pinot.common.restlet.resources.TablesList; | ||
import org.apache.pinot.common.utils.TarGzCompressionUtils; | ||
|
@@ -32,6 +33,7 @@ | |
import org.apache.pinot.segment.spi.SegmentMetadata; | ||
import org.apache.pinot.segment.spi.V1Constants; | ||
import org.apache.pinot.segment.spi.index.metadata.SegmentMetadataImpl; | ||
import org.apache.pinot.segment.spi.store.ColumnIndexType; | ||
import org.apache.pinot.spi.utils.JsonUtils; | ||
import org.apache.pinot.spi.utils.builder.TableNameBuilder; | ||
import org.testng.Assert; | ||
|
@@ -99,6 +101,38 @@ public void getSegments() | |
Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); | ||
} | ||
|
||
@Test | ||
public void getTableMetadata() | ||
throws Exception { | ||
String tableMetadataPath = "/tables/" + TableNameBuilder.REALTIME.tableNameWithType(TABLE_NAME) + "/metadata"; | ||
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. Can we add a test for this API for both REALTIME and OFFLINE 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. wilco |
||
|
||
JsonNode jsonResponse = | ||
JsonUtils.stringToJsonNode(_webTarget.path(tableMetadataPath).request().get(String.class)); | ||
TableMetadataInfo metadataInfo = JsonUtils.jsonNodeToObject(jsonResponse, TableMetadataInfo.class); | ||
Assert.assertNotNull(metadataInfo); | ||
Assert.assertEquals(metadataInfo.getNumSegments(), 2); | ||
Assert.assertEquals(metadataInfo.getTableName(), TableNameBuilder.REALTIME.tableNameWithType(TABLE_NAME)); | ||
Assert.assertEquals(metadataInfo.getColumnLengthMap().size(), 0); | ||
Assert.assertEquals(metadataInfo.getColumnCardinalityMap().size(), 0); | ||
Assert.assertEquals(metadataInfo.getColumnIndexSizeMap().size(), 0); | ||
|
||
jsonResponse = JsonUtils.stringToJsonNode(_webTarget.path(tableMetadataPath) | ||
.queryParam("columns", "column1").queryParam("columns", "column2").request().get(String.class)); | ||
metadataInfo = JsonUtils.jsonNodeToObject(jsonResponse, TableMetadataInfo.class); | ||
Assert.assertEquals(metadataInfo.getColumnLengthMap().size(), 2); | ||
Assert.assertEquals(metadataInfo.getColumnCardinalityMap().size(), 2); | ||
Assert.assertEquals(metadataInfo.getColumnIndexSizeMap().size(), 2); | ||
Assert.assertTrue(metadataInfo.getColumnIndexSizeMap().get("column1") | ||
.containsKey(ColumnIndexType.DICTIONARY.getIndexName())); | ||
Assert.assertTrue(metadataInfo.getColumnIndexSizeMap().get("column2") | ||
.containsKey(ColumnIndexType.FORWARD_INDEX.getIndexName())); | ||
|
||
// No such table | ||
Response response = _webTarget.path("/tables/noSuchTable/metadata").request().get(Response.class); | ||
Assert.assertNotNull(response); | ||
Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); | ||
} | ||
|
||
@Test | ||
public void testSegmentMetadata() | ||
throws Exception { | ||
|
@@ -124,6 +158,8 @@ public void testSegmentMetadata() | |
.get(String.class)); | ||
Assert.assertEquals(jsonResponse.get("columns").size(), 2); | ||
Assert.assertEquals(jsonResponse.get("indexes").size(), 2); | ||
Assert.assertNotNull(jsonResponse.get("columns").get(0).get("indexSizeMap")); | ||
Assert.assertNotNull(jsonResponse.get("columns").get(1).get("indexSizeMap")); | ||
|
||
jsonResponse = JsonUtils.stringToJsonNode( | ||
(_webTarget.path(segmentMetadataPath).queryParam("columns", "*").request().get(String.class))); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we make this Nullable property?
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.
columnIndexSize map will not be null. it will be empty if there's no index scheme. but unless a pinot table contains all non-dictionary columns, at least it will show the forward index size and dictionary size for some columns