use of org.apache.phoenix.mapreduce.PhoenixInputFormat in project DataX by alibaba.
the class HbaseSQLHelper method split.
public static List<Configuration> split(HbaseSQLReaderConfig readerConfig) {
PhoenixInputFormat inputFormat = new PhoenixInputFormat<PhoenixRecordWritable>();
org.apache.hadoop.conf.Configuration conf = generatePhoenixConf(readerConfig);
JobID jobId = new JobID(Key.MOCK_JOBID_IDENTIFIER, Key.MOCK_JOBID);
JobContextImpl jobContext = new JobContextImpl(conf, jobId);
List<Configuration> resultConfigurations = new ArrayList<Configuration>();
List<InputSplit> rawSplits = null;
try {
rawSplits = inputFormat.getSplits(jobContext);
LOG.info("split size is " + rawSplits.size());
for (InputSplit split : rawSplits) {
Configuration cfg = readerConfig.getOriginalConfig().clone();
byte[] splitSer = HadoopSerializationUtil.serialize((PhoenixInputSplit) split);
String splitBase64Str = org.apache.commons.codec.binary.Base64.encodeBase64String(splitSer);
cfg.set(Key.SPLIT_KEY, splitBase64Str);
resultConfigurations.add(cfg);
}
} catch (IOException e) {
throw DataXException.asDataXException(HbaseSQLReaderErrorCode.GET_PHOENIX_SPLITS_ERROR, "获取表的split信息时出现了异常,请检查hbase集群服务是否正常," + e.getMessage(), e);
} catch (InterruptedException e) {
throw DataXException.asDataXException(HbaseSQLReaderErrorCode.GET_PHOENIX_SPLITS_ERROR, "获取表的split信息时被中断,请重试,若还有问题请联系datax管理员," + e.getMessage(), e);
}
return resultConfigurations;
}
use of org.apache.phoenix.mapreduce.PhoenixInputFormat in project Datax by n-kong.
the class HbaseSQLHelper method split.
public static List<Configuration> split(HbaseSQLReaderConfig readerConfig) {
PhoenixInputFormat inputFormat = new PhoenixInputFormat<PhoenixRecordWritable>();
org.apache.hadoop.conf.Configuration conf = generatePhoenixConf(readerConfig);
JobID jobId = new JobID(Key.MOCK_JOBID_IDENTIFIER, Key.MOCK_JOBID);
JobContextImpl jobContext = new JobContextImpl(conf, jobId);
List<Configuration> resultConfigurations = new ArrayList<Configuration>();
List<InputSplit> rawSplits = null;
try {
rawSplits = inputFormat.getSplits(jobContext);
LOG.info("split size is " + rawSplits.size());
for (InputSplit split : rawSplits) {
Configuration cfg = readerConfig.getOriginalConfig().clone();
byte[] splitSer = HadoopSerializationUtil.serialize((PhoenixInputSplit) split);
String splitBase64Str = org.apache.commons.codec.binary.Base64.encodeBase64String(splitSer);
cfg.set(Key.SPLIT_KEY, splitBase64Str);
resultConfigurations.add(cfg);
}
} catch (IOException e) {
throw DataXException.asDataXException(HbaseSQLReaderErrorCode.GET_PHOENIX_SPLITS_ERROR, "获取表的split信息时出现了异常,请检查hbase集群服务是否正常," + e.getMessage(), e);
} catch (InterruptedException e) {
throw DataXException.asDataXException(HbaseSQLReaderErrorCode.GET_PHOENIX_SPLITS_ERROR, "获取表的split信息时被中断,请重试,若还有问题请联系datax管理员," + e.getMessage(), e);
}
return resultConfigurations;
}
Aggregations