[GitHub] [carbondata] xuchuanyin commented on a change in pull request #3183: [CARBONDATA-3349] Show sort_columns for each segment

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] xuchuanyin commented on a change in pull request #3183: [CARBONDATA-3349] Show sort_columns for each segment

GitBox
xuchuanyin 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_r278945488
 
 

 ##########
 File path: integration/spark-common/src/main/scala/org/apache/carbondata/api/CarbonStore.scala
 ##########
 @@ -145,6 +152,208 @@ object CarbonStore {
     }
   }
 
+  def showSegments(
+      limit: Option[String],
+      carbonTable: CarbonTable,
+      hadoopConf: Configuration,
+      showHistory: Boolean): Seq[Row] = {
+    val metaFolder = CarbonTablePath.getMetadataPath(carbonTable.getTablePath)
+    val loadMetadataDetailsArray = if (showHistory) {
+      SegmentStatusManager.readLoadMetadata(metaFolder) ++
+      SegmentStatusManager.readLoadHistoryMetadata(metaFolder)
+    } else {
+      SegmentStatusManager.readLoadMetadata(metaFolder)
+    }
+
+    if (loadMetadataDetailsArray.nonEmpty) {
+      var loadMetadataDetailsSortedArray = loadMetadataDetailsArray.sortWith { (l1, l2) =>
+        java.lang.Double.parseDouble(l1.getLoadName) > java.lang.Double.parseDouble(l2.getLoadName)
+      }
+      if (!showHistory) {
+        loadMetadataDetailsSortedArray = loadMetadataDetailsSortedArray
+          .filter(_.getVisibility.equalsIgnoreCase("true"))
+      }
+      if (limit.isDefined) {
+        val limitLoads = limit.get
+        try {
+          val lim = Integer.parseInt(limitLoads)
+          loadMetadataDetailsSortedArray = loadMetadataDetailsSortedArray.slice(0, lim)
+        } catch {
+          case _: NumberFormatException =>
+            CarbonException.analysisException("Entered limit is not a valid Number")
+        }
+      }
+      val tableDataMap: TableDataMap =
+        DataMapStoreManager.getInstance.getDefaultDataMap(carbonTable)
+      val readCommitScope: ReadCommittedScope =
+        new TableStatusReadCommittedScope(
+          carbonTable.getAbsoluteTableIdentifier,
+          loadMetadataDetailsSortedArray.filter(_.getVisibility.equalsIgnoreCase("true")),
+          hadoopConf)
+      loadMetadataDetailsSortedArray
+        .map { load =>
+          val mergedTo =
 
 Review comment:
   suggest
   ```
   val mergedTo = Option(load.getMergedLoadName).getOrElse("NA")
   ```
   here to make the code simple

----------------------------------------------------------------
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