當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。