KanakaKumar commented on a change in pull request #3183: [CARBONDATA-3349] Show sort_columns for each segment
URL:
https://github.com/apache/carbondata/pull/3183#discussion_r281172034
##########
File path: integration/spark-common/src/main/scala/org/apache/carbondata/api/CarbonStore.scala
##########
@@ -137,14 +159,65 @@ object CarbonStore {
mergedTo,
load.getFileFormat.toString,
Strings.formatSize(dataSize.toFloat),
- Strings.formatSize(indexSize.toFloat))
+ Strings.formatSize(indexSize.toFloat),
+ isSorted,
+ sortColumns)
}
}.toSeq
} else {
Seq.empty
}
}
+ private def getSortColumnsOfSegment(
+ load: LoadMetadataDetails,
+ readCommitScope: ReadCommittedScope,
+ tableDataMap: TableDataMap,
+ hadoopConf: Configuration
+ ): (String, String) = {
+ // isSorted has 3 options: true, false, ""(for legacy store, before version 1.5.1)
+ var isSorted = ""
+ // when isSorted is true, need show sort_columns
+ var sortColumns = ""
+ if (load.getFileFormat == FileFormat.ROW_V1) {
+ isSorted = "false"
+ } else if (tableDataMap != null && load.getVisibility.equalsIgnoreCase("true")) {
+ val indexHeader = SegmentIndexFileStore
+ .getIndexHeaderOfSegment(load,
+ readCommitScope,
+ tableDataMap.getDataMapFactory.asInstanceOf[BlockletDataMapFactory])
+ if (indexHeader != null && indexHeader.isSetIs_sort) {
+ if (indexHeader.is_sort) {
+ isSorted = "true"
+ val columns = indexHeader.getTable_columns
+ sortColumns = (0 until columns.size())
+ .map { index =>
+ val column = columns.get(index)
+ if (column.isDimension && !column.isInvisible) {
+ val properties = column.getColumnProperties
+ if (properties != null) {
Review comment:
Can be simplified to combine multiple conditions to avoid many return null for readability
if(properties != null && properties.get(CarbonCommonConstants.SORT_COLUMNS) != null)
{
column.column_name
}
else
{
null
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[hidden email]
With regards,
Apache Git Services