You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ra...@apache.org on 2018/09/03 16:52:28 UTC
carbondata git commit: [CARBONDATA-2906] Output segment size in SHOW
SEGMENT command
Repository: carbondata
Updated Branches:
refs/heads/master 5a1496f3e -> 2b704349d
[CARBONDATA-2906] Output segment size in SHOW SEGMENT command
In SHOW SEGMENT command, output the segment data size and index size so that user can check the size of each segment easier.
This closes #2681
Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/2b704349
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/2b704349
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/2b704349
Branch: refs/heads/master
Commit: 2b704349de0c2331b5887fe0ce5eeb8d3de2841c
Parents: 5a1496f
Author: Jacky Li <ja...@qq.com>
Authored: Sat Sep 1 18:23:26 2018 +0800
Committer: ravipesala <ra...@gmail.com>
Committed: Mon Sep 3 22:22:18 2018 +0530
----------------------------------------------------------------------
.../org/apache/carbondata/common/Strings.java | 25 ++++++++++++++++++++
.../org/apache/carbondata/api/CarbonStore.scala | 10 +++++---
.../management/CarbonShowLoadsCommand.scala | 8 +++++--
3 files changed, 38 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/carbondata/blob/2b704349/common/src/main/java/org/apache/carbondata/common/Strings.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/carbondata/common/Strings.java b/common/src/main/java/org/apache/carbondata/common/Strings.java
index 23c7f9f..35c24ba 100644
--- a/common/src/main/java/org/apache/carbondata/common/Strings.java
+++ b/common/src/main/java/org/apache/carbondata/common/Strings.java
@@ -40,4 +40,29 @@ public class Strings {
}
return builder.toString();
}
+
+ /**
+ * Append KB/MB/GB/TB to the input size and return
+ * @param size data size
+ * @return data size with unit
+ */
+ public static String formatSize(float size) {
+ long KB = 1024L;
+ long MB = KB << 10;
+ long GB = MB << 10;
+ long TB = GB << 10;
+ if (size < 0) {
+ return "NA";
+ } else if (size >= 0 && size < KB) {
+ return String.format("%sB", size);
+ } else if (size >= KB && size < MB) {
+ return String.format("%.2fKB", size / KB);
+ } else if (size >= MB && size < GB) {
+ return String.format("%.2fMB", size / MB);
+ } else if (size >= GB && size < TB) {
+ return String.format("%.2fGB", size / GB);
+ } else {
+ return String.format("%.2fTB", size / TB);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/carbondata/blob/2b704349/integration/spark-common/src/main/scala/org/apache/carbondata/api/CarbonStore.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common/src/main/scala/org/apache/carbondata/api/CarbonStore.scala b/integration/spark-common/src/main/scala/org/apache/carbondata/api/CarbonStore.scala
index 26c32ee..02c8607 100644
--- a/integration/spark-common/src/main/scala/org/apache/carbondata/api/CarbonStore.scala
+++ b/integration/spark-common/src/main/scala/org/apache/carbondata/api/CarbonStore.scala
@@ -21,12 +21,12 @@ import java.lang.Long
import scala.collection.JavaConverters._
-import org.apache.hadoop.fs.{LocatedFileStatus, Path, RemoteIterator}
import org.apache.spark.sql.Row
import org.apache.spark.sql.catalyst.util.DateTimeUtils
import org.apache.spark.sql.util.CarbonException
import org.apache.spark.unsafe.types.UTF8String
+import org.apache.carbondata.common.Strings
import org.apache.carbondata.common.exceptions.sql.MalformedCarbonCommandException
import org.apache.carbondata.common.logging.LogServiceFactory
import org.apache.carbondata.core.constants.CarbonCommonConstants
@@ -104,7 +104,9 @@ object CarbonStore {
endTime,
mergedTo,
load.getFileFormat.toString,
- load.getVisibility())
+ load.getVisibility(),
+ Strings.formatSize(if (load.getDataSize == null) 0 else load.getDataSize.toFloat),
+ Strings.formatSize(if (load.getIndexSize == null) 0 else load.getIndexSize.toFloat))
} else {
Row(
load.getLoadName,
@@ -112,7 +114,9 @@ object CarbonStore {
startTime,
endTime,
mergedTo,
- load.getFileFormat.toString)
+ load.getFileFormat.toString,
+ Strings.formatSize(if (load.getDataSize == null) 0 else load.getDataSize.toFloat),
+ Strings.formatSize(if (load.getIndexSize == null) 0 else load.getIndexSize.toFloat))
}
}.toSeq
} else {
http://git-wip-us.apache.org/repos/asf/carbondata/blob/2b704349/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonShowLoadsCommand.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonShowLoadsCommand.scala b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonShowLoadsCommand.scala
index 0fb05e0..3d57a99 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonShowLoadsCommand.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonShowLoadsCommand.scala
@@ -41,14 +41,18 @@ case class CarbonShowLoadsCommand(
AttributeReference("Load End Time", TimestampType, nullable = true)(),
AttributeReference("Merged To", StringType, nullable = false)(),
AttributeReference("File Format", StringType, nullable = false)(),
- AttributeReference("Visibility", StringType, nullable = false)())
+ AttributeReference("Visibility", StringType, nullable = false)(),
+ AttributeReference("Data Size", StringType, nullable = false)(),
+ AttributeReference("Index Size", StringType, nullable = false)())
} else {
Seq(AttributeReference("SegmentSequenceId", StringType, nullable = false)(),
AttributeReference("Status", StringType, nullable = false)(),
AttributeReference("Load Start Time", TimestampType, nullable = false)(),
AttributeReference("Load End Time", TimestampType, nullable = true)(),
AttributeReference("Merged To", StringType, nullable = false)(),
- AttributeReference("File Format", StringType, nullable = false)())
+ AttributeReference("File Format", StringType, nullable = false)(),
+ AttributeReference("Data Size", StringType, nullable = false)(),
+ AttributeReference("Index Size", StringType, nullable = false)())
}
}