本文整理汇总了Java中com.aliyun.odps.tunnel.TableTunnel.UploadSession类的典型用法代码示例。如果您正苦于以下问题:Java UploadSession类的具体用法?Java UploadSession怎么用?Java UploadSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UploadSession类属于com.aliyun.odps.tunnel.TableTunnel包,在下文中一共展示了UploadSession类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OdpsTunnelWriter
import com.aliyun.odps.tunnel.TableTunnel.UploadSession; //导入依赖的package包/类
public OdpsTunnelWriter(TableTunnel tunnel, String project, String tableName, int retryCount,
UploadSession uploadSession, boolean useCompress) throws TunnelException {
this.tunnel = tunnel;
this.project = project;
this.tableName = tableName;
this.retryCount = retryCount;
this.sharedUploadSession = uploadSession;
sharedWriter = uploadSession.openBufferedWriter(true);
((TunnelBufferedWriter)sharedWriter).setBufferSize(256*1024*1024);
this.useCompress = useCompress;
}
示例2: createTunnelBufferedWriter
import com.aliyun.odps.tunnel.TableTunnel.UploadSession; //导入依赖的package包/类
private TunnelBufferedWriter createTunnelBufferedWriter(UploadSession uploadSession) throws TunnelException{
TunnelBufferedWriter writer =(TunnelBufferedWriter) uploadSession.openBufferedWriter();
if(bufferSize > 0 ){
writer.setBufferSize(bufferSize);
}
return writer;
}
示例3: createUploadSession
import com.aliyun.odps.tunnel.TableTunnel.UploadSession; //导入依赖的package包/类
public UploadSession createUploadSession(String par) throws TunnelException{
if(StringUtils.isNotBlank(par)&&!"jlogstash".equals(par)){
PartitionSpec partitionSpec = new PartitionSpec(par);
return tunnel.createUploadSession(project,table, partitionSpec);
}else{
return tunnel.createUploadSession(project,table);
}
}
示例4: emit
import com.aliyun.odps.tunnel.TableTunnel.UploadSession; //导入依赖的package包/类
@Override
protected void emit(Map event) {
// TODO Auto-generated method stub
try {
String par = Formatter.format(event, partition, timezone);
Object[] objs = objects.get(par);
if(objs == null){
objs = createArrayObject(par);
objects.put(par, objs);
}
Record record = createRecord(event,(UploadSession)objs[0],(TableSchema)objs[1]);
Object[] cols = record.toArray();
if(cols==null||cols.length ==0){
return ;
}
((TunnelBufferedWriter)objs[2]).write(record);
long t1 = System.currentTimeMillis();
if(t1 - current > interval){
commit();
objects.clear();
current = t1;
logger.warn("uploadSession is committed...");
}
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("OutOdps emit error:",e);
}
}
示例5: commit
import com.aliyun.odps.tunnel.TableTunnel.UploadSession; //导入依赖的package包/类
private synchronized void commit(){
try{
if(objects.size()>0){
Set<Map.Entry<String,Object[]>> entrys = objects.entrySet();
for(Map.Entry<String,Object[]> entry:entrys){
Object[] objs = entry.getValue();
((TunnelBufferedWriter)objs[2]).close();
((UploadSession)objs[0]).commit();
}
}
}catch(Throwable e){
logger.error("OutOdps commit error:",e);
}
}
示例6: createRecord
import com.aliyun.odps.tunnel.TableTunnel.UploadSession; //导入依赖的package包/类
private Record createRecord(Map event,UploadSession uploadSession,TableSchema tableSchema){
Record record = uploadSession.newRecord();
for (int i = 0; i < tableSchema.getColumns().size(); i++) {
Column column = tableSchema.getColumn(i);
String name = column.getName();
Object value = event.get(name);
if(value!=null){
switch (column.getType()) {
case BIGINT:
record.set(name, Long.parseLong(value.toString()));
break;
case BOOLEAN:
record.set(name, Boolean.parseBoolean(value.toString()));
break;
case DATETIME:
record.set(name, value);
break;
case DOUBLE:
record.set(name, Double.parseDouble(value.toString()));
break;
case STRING:
record.set(name, value.toString());
break;
default:
logger.warn("{}:Unknown column type: "+ column.getType(),name);
}
}
}
return record;
}
示例7: createArrayObject
import com.aliyun.odps.tunnel.TableTunnel.UploadSession; //导入依赖的package包/类
private Object[] createArrayObject(String par) throws TunnelException{
UploadSession uploadSession = createUploadSession(par);
TableSchema tableSchema = uploadSession.getSchema();
TunnelBufferedWriter tunnelBufferedWriter = createTunnelBufferedWriter(uploadSession);
return new Object[]{uploadSession,tableSchema,tunnelBufferedWriter};
}