use of org.apache.carbondata.core.index.IndexInputFormat in project carbondata by apache.
the class CarbonInputFormat method getDistributedCount.
/**
* This method will execute a distributed job to get the count for the
* table. If the job fails for some reason then an embedded job is fired to
* get the count.
*/
Long getDistributedCount(CarbonTable table, List<PartitionSpec> partitionNames, List<Segment> validSegments, Configuration configuration) {
IndexInputFormat indexInputFormat = new IndexInputFormat(table, null, validSegments, new ArrayList<>(), partitionNames, false, null, false, false);
indexInputFormat.setIsWriteToFile(false);
try {
IndexJob indexJob = (IndexJob) IndexUtil.createIndexJob(IndexUtil.DISTRIBUTED_JOB_NAME);
if (indexJob == null) {
throw new ExceptionInInitializerError("Unable to create index job");
}
return indexJob.executeCountJob(indexInputFormat, configuration);
} catch (Exception e) {
if (CarbonProperties.getInstance().isFallBackDisabled()) {
LOG.error("Fallback is disabled");
throw e;
}
LOG.error("Failed to get count from index server. Initializing fallback", e);
IndexJob indexJob = IndexUtil.getEmbeddedJob();
return indexJob.executeCountJob(indexInputFormat, configuration);
}
}
Aggregations