当前位置: 首页>>代码示例>>Java>>正文


Java UploadSession类代码示例

本文整理汇总了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;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:12,代码来源:OdpsTunnelWriter.java

示例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;
}
 
开发者ID:DTStack,项目名称:jlogstash-output-plugin,代码行数:8,代码来源:OutOdps.java

示例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);
    }
}
 
开发者ID:DTStack,项目名称:jlogstash-output-plugin,代码行数:9,代码来源:OutOdps.java

示例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);
}
     }
 
开发者ID:DTStack,项目名称:jlogstash-output-plugin,代码行数:29,代码来源:OutOdps.java

示例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);
   	}
  }
 
开发者ID:DTStack,项目名称:jlogstash-output-plugin,代码行数:15,代码来源:OutOdps.java

示例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;
}
 
开发者ID:DTStack,项目名称:jlogstash-output-plugin,代码行数:31,代码来源:OutOdps.java

示例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};
}
 
开发者ID:DTStack,项目名称:jlogstash-output-plugin,代码行数:7,代码来源:OutOdps.java


注:本文中的com.aliyun.odps.tunnel.TableTunnel.UploadSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。