|
@@ -79,14 +79,10 @@ public class TunnelBatchStreamSink<T, IN extends List<T>> extends RichSinkFuncti
|
|
|
*/
|
|
|
@Override
|
|
|
public void invoke(IN value, Context context) throws TunnelException, IOException, InvocationTargetException, IllegalAccessException {
|
|
|
- long start = System.currentTimeMillis();
|
|
|
T element = value.get(0);
|
|
|
String partitionStr = generatePartitionStr(element);
|
|
|
TableTunnel.StreamUploadSession uploadSession = tunnel.createStreamUploadSession(projectName, tableName, StringUtils.isBlank(partitionStr) ? null : new PartitionSpec(partitionStr), true);
|
|
|
TableTunnel.StreamRecordPack pack = uploadSession.newRecordPack();
|
|
|
- long end = System.currentTimeMillis();
|
|
|
- log.error("准备写入 maxCompute[{}], 准备用时:{}", value.size(), (end - start));
|
|
|
- start = end;
|
|
|
for (T t : value) {
|
|
|
Record record = uploadSession.newRecord();
|
|
|
for (BeanUtil.FieldInfo fieldInfo : fieldInfoList) {
|
|
@@ -104,9 +100,6 @@ public class TunnelBatchStreamSink<T, IN extends List<T>> extends RichSinkFuncti
|
|
|
// append只是写入内存
|
|
|
pack.append(record);
|
|
|
}
|
|
|
- end = System.currentTimeMillis();
|
|
|
- log.error("append {}条数据用时:{}", value.size(), end - start);
|
|
|
- start = end;
|
|
|
int retry = 0;
|
|
|
do {
|
|
|
try {
|
|
@@ -120,8 +113,6 @@ public class TunnelBatchStreamSink<T, IN extends List<T>> extends RichSinkFuncti
|
|
|
}
|
|
|
}
|
|
|
} while (retry++ < 3);
|
|
|
- end = System.currentTimeMillis();
|
|
|
- log.error("写入 {}条数据用时:{}", value.size(), end - start);
|
|
|
}
|
|
|
|
|
|
@Override
|