use of org.apache.carbondata.processing.loading.model.CarbonLoadModelBuilder in project carbondata by apache.
the class CarbonWriterBuilder method buildLoadModel.
/**
* Build a {@link CarbonLoadModel}
*/
private CarbonLoadModel buildLoadModel(CarbonTable table) throws InvalidLoadOptionException, IOException {
Map<String, String> options = new HashMap<>();
if (sortColumns != null) {
options.put("sort_columns", Strings.mkString(sortColumns, ","));
}
CarbonLoadModelBuilder builder = new CarbonLoadModelBuilder(table);
return builder.build(options);
}
use of org.apache.carbondata.processing.loading.model.CarbonLoadModelBuilder in project carbondata by apache.
the class HiveCarbonUtil method getCarbonLoadModel.
public static CarbonLoadModel getCarbonLoadModel(String tableName, String databaseName, String location, String sortColumnsString, String[] columns, String[] columnTypes, Configuration configuration) {
CarbonLoadModel loadModel;
CarbonTable carbonTable;
try {
String schemaFilePath = CarbonTablePath.getSchemaFilePath(location, configuration);
AbsoluteTableIdentifier absoluteTableIdentifier = AbsoluteTableIdentifier.from(location, databaseName, tableName, "");
if (FileFactory.getCarbonFile(schemaFilePath).exists()) {
carbonTable = SchemaReader.readCarbonTableFromStore(absoluteTableIdentifier);
carbonTable.setTransactionalTable(true);
} else {
String carbonDataFile = CarbonUtil.getFilePathExternalFilePath(location, configuration);
if (carbonDataFile == null) {
carbonTable = CarbonTable.buildFromTableInfo(getTableInfo(tableName, databaseName, location, sortColumnsString, columns, columnTypes, new ArrayList<>()));
} else {
carbonTable = CarbonTable.buildFromTableInfo(SchemaReader.inferSchema(absoluteTableIdentifier, false, configuration));
}
carbonTable.setTransactionalTable(false);
}
} catch (SQLException | IOException e) {
throw new RuntimeException("Unable to fetch schema for the table: " + tableName, e);
}
CarbonLoadModelBuilder carbonLoadModelBuilder = new CarbonLoadModelBuilder(carbonTable);
Map<String, String> options = new HashMap<>();
options.put("fileheader", Strings.mkString(columns, ","));
try {
loadModel = carbonLoadModelBuilder.build(options, System.currentTimeMillis(), "");
} catch (InvalidLoadOptionException | IOException e) {
throw new RuntimeException(e);
}
loadModel.setSkipParsers();
loadModel.setMetrics(new DataLoadMetrics());
return loadModel;
}
use of org.apache.carbondata.processing.loading.model.CarbonLoadModelBuilder in project carbondata by apache.
the class CarbonWriterBuilder method buildLoadModel.
/**
* Build a {@link CarbonLoadModel}
*/
private CarbonLoadModel buildLoadModel(CarbonTable table, long timestamp, String taskNo, Map<String, String> options) throws InvalidLoadOptionException, IOException {
if (options == null) {
options = new HashMap<>();
}
CarbonLoadModelBuilder builder = new CarbonLoadModelBuilder(table);
CarbonLoadModel model = builder.build(options, timestamp, taskNo);
setCsvHeader(model);
return model;
}
use of org.apache.carbondata.processing.loading.model.CarbonLoadModelBuilder in project hetu-core by openlookeng.
the class CarbondataHetuOutputFormat method createCarbonLoadModel.
private CarbonLoadModel createCarbonLoadModel(Configuration configuration, Properties tableProperties) throws IOException {
String[] tableUniqueName = tableProperties.get("name").toString().split("\\.");
String databaseName = tableUniqueName[0];
String tableName = tableUniqueName[1];
String tablePath = tableProperties.get("location").toString();
CarbonTable carbonTable = CarbonTable.buildFromTablePath(tableName, databaseName, tablePath, "");
CarbonLoadModelBuilder carbonLoadModelBuilder = new CarbonLoadModelBuilder(carbonTable);
try {
return carbonLoadModelBuilder.build(carbonTable.getTableInfo().getFactTable().getTableProperties(), System.currentTimeMillis(), "1");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations