Github user manishgupta88 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2654#discussion_r214049718
--- Diff:
processing/src/main/java/org/apache/carbondata/processing/util/CarbonDataProcessorUtil.java
---
@@ -450,6 +450,114 @@ public static boolean isHeaderValid(String tableName,
String[] csvHeader,
return type;
}
+ /**
+ * Get the no dictionary data types on the table
+ *
+ * @param databaseName
+ * @param tableName
+ * @return
+ */
+ public static DataType[] getNoDicDataTypes(String databaseName, String
tableName) {
+ CarbonTable carbonTable =
CarbonMetadata.getInstance().getCarbonTable(databaseName, tableName);
+ List<CarbonDimension> dimensions =
carbonTable.getDimensionByTableName(tableName);
+ int noDicCount = 0;
+ for (int i = 0; i < dimensions.size(); i++) {
+ if (!dimensions.get(i).hasEncoding(Encoding.DICTIONARY)) {
+ noDicCount++;
+ }
+ }
+ DataType[] type = new DataType[noDicCount];
+ noDicCount = 0;
+ for (int i = 0; i < dimensions.size(); i++) {
+ if (!dimensions.get(i).hasEncoding(Encoding.DICTIONARY)) {
+ type[noDicCount++] = dimensions.get(i).getDataType();
+ }
+ }
+ return type;
+ }
+
+ /**
+ * Get the no dictionary sort column mapping of the table
+ *
+ * @param databaseName
+ * @param tableName
+ * @return
+ */
+ public static boolean[] getNoDicSortColMapping(String databaseName,
String tableName) {
+ CarbonTable carbonTable =
CarbonMetadata.getInstance().getCarbonTable(databaseName, tableName);
+ List<CarbonDimension> dimensions =
carbonTable.getDimensionByTableName(tableName);
+ List<Integer> noDicIndexes = new ArrayList<>(dimensions.size());
+ int noDicCount = 0;
+ for (int i = 0; i < dimensions.size(); i++) {
+ if (!dimensions.get(i).hasEncoding(Encoding.DICTIONARY)) {
+ noDicIndexes.add(i);
+ noDicCount++;
+ }
+ }
+
+ boolean[] noDicSortColMapping = new boolean[noDicCount];
+ for (int i = 0; i < noDicSortColMapping.length; i++) {
+ if (dimensions.get(noDicIndexes.get(i)).isSortColumn()) {
+ noDicSortColMapping[i] = true;
+ }
+ }
+ return noDicSortColMapping;
+ }
+
+ /**
+ * Get the data types of the no dictionary sort columns
+ *
+ * @param databaseName
+ * @param tableName
+ * @return
+ */
+ public static DataType[] getNoDicSortDataTypes(String databaseName,
String tableName) {
+ CarbonTable carbonTable =
CarbonMetadata.getInstance().getCarbonTable(databaseName, tableName);
+ List<CarbonDimension> dimensions =
carbonTable.getDimensionByTableName(tableName);
+ int noDicSortCount = 0;
+ for (int i = 0; i < dimensions.size(); i++) {
+ if (!dimensions.get(i).hasEncoding(Encoding.DICTIONARY) &&
dimensions.get(i).isSortColumn()) {
+ noDicSortCount++;
+ }
+ }
+ DataType[] type = new DataType[noDicSortCount];
+ noDicSortCount = 0;
+ for (int i = 0; i < dimensions.size(); i++) {
+ if (!dimensions.get(i).hasEncoding(Encoding.DICTIONARY) &&
dimensions.get(i).isSortColumn()) {
+ type[noDicSortCount++] = dimensions.get(i).getDataType();
+ }
--- End diff --
same comment as above. Check on the callers and merge all 3 methods into
one if possible
---