Skip to content
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

[CARBONDATA-3223] Fixed Wrong Datasize and Indexsize calculation for old store using Show Segments #3047

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,7 @@ public static void setSegmentsToAccess(Configuration configuration, List<Segment
public static void setQuerySegment(Configuration conf, AbsoluteTableIdentifier identifier) {
String dbName = identifier.getCarbonTableIdentifier().getDatabaseName().toLowerCase();
String tbName = identifier.getCarbonTableIdentifier().getTableName().toLowerCase();
String segmentNumbersFromProperty = CarbonProperties.getInstance()
.getProperty(CarbonCommonConstants.CARBON_INPUT_SEGMENTS + dbName + "." + tbName, "*");
if (!segmentNumbersFromProperty.trim().equals("*")) {
CarbonInputFormat.setSegmentsToAccess(conf,
Segment.toSegmentList(segmentNumbersFromProperty.split(","), null));
}
getQuerySegmentToAccess(conf, dbName, tbName);
}

/**
Expand Down Expand Up @@ -788,4 +783,22 @@ public String[] projectAllColumns(CarbonTable carbonTable) {
}
return projectColumns.toArray(new String[projectColumns.size()]);
}

private static void getQuerySegmentToAccess(Configuration conf, String dbName, String tableName) {
String segmentNumbersFromProperty = CarbonProperties.getInstance()
.getProperty(CarbonCommonConstants.CARBON_INPUT_SEGMENTS + dbName + "." + tableName, "*");
if (!segmentNumbersFromProperty.trim().equals("*")) {
CarbonInputFormat.setSegmentsToAccess(conf,
Segment.toSegmentList(segmentNumbersFromProperty.split(","), null));
}
}

/**
* Set `CARBON_INPUT_SEGMENTS` from property to configuration
*/
public static void setQuerySegment(Configuration conf, CarbonTable carbonTable) {
String tableName = carbonTable.getTableName();
getQuerySegmentToAccess(conf, carbonTable.getDatabaseName(), tableName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ object CarbonStore {
(indices.asScala.map(_.getFile_size).sum, FileFactory.getCarbonFile(indexPath).getSize)
} else {
// for batch segment, we can get the data size from table status file directly
(if (load.getDataSize == null) 0L else load.getDataSize.toLong,
if (load.getIndexSize == null) 0L else load.getIndexSize.toLong)
(if (load.getDataSize == null) -1L else load.getDataSize.toLong,
if (load.getIndexSize == null) -1L else load.getIndexSize.toLong)
}

if (showHistory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ case class CarbonCountStar(
.setConfigurationToCurrentThread(sparkSession.sessionState.newHadoopConf())
val absoluteTableIdentifier = carbonTable.getAbsoluteTableIdentifier
val (job, tableInputFormat) = createCarbonInputFormat(absoluteTableIdentifier)
CarbonInputFormat.setQuerySegment(job.getConfiguration, absoluteTableIdentifier)
CarbonInputFormat.setQuerySegment(job.getConfiguration, carbonTable)

// get row count
val rowCount = CarbonUpdateUtil.getRowCount(
Expand Down