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


Java FileChunk类代码示例

本文整理汇总了Java中org.apache.tajo.worker.dataserver.retriever.FileChunk的典型用法代码示例。如果您正苦于以下问题:Java FileChunk类的具体用法?Java FileChunk怎么用?Java FileChunk使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileChunk类属于org.apache.tajo.worker.dataserver.retriever包,在下文中一共展示了FileChunk类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendFile

import org.apache.tajo.worker.dataserver.retriever.FileChunk; //导入依赖的package包/类
private ChannelFuture sendFile(ChannelHandlerContext ctx, Channel ch, FileChunk file) throws IOException {
  RandomAccessFile raf;
  try {
    raf = new RandomAccessFile(file.getFile(), "r");
  } catch (FileNotFoundException fnfe) {
    return null;
  }

  ChannelFuture writeFuture;
  if (ch.getPipeline().get(SslHandler.class) != null) {
    // Cannot use zero-copy with HTTPS.
    writeFuture = ch.write(new ChunkedFile(raf, file.startOffset(), file.length(), 8192));
  } else {
    // No encryption - use zero-copy.
    final FileRegion region = new DefaultFileRegion(raf.getChannel(), file.startOffset(), file.length());
    writeFuture = ch.write(region);
    writeFuture.addListener(new ChannelFutureListener() {
      public void operationComplete(ChannelFuture future) {
        region.releaseExternalResources();
      }
    });
  }

  return writeFuture;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:26,代码来源:HttpDataServerHandler.java

示例2: getFileChunk

import org.apache.tajo.worker.dataserver.retriever.FileChunk; //导入依赖的package包/类
private FileChunk getFileChunk(RangeRetrieverHandler handler, Schema keySchema,
                               TupleRange range, boolean last) throws IOException {
  Map<String,List<String>> kvs = Maps.newHashMap();
  kvs.put("start", Lists.newArrayList(
      new String(Base64.encodeBase64(
          RowStoreUtil.RowStoreEncoder.toBytes(keySchema, range.getStart()),
          false))));
  kvs.put("end", Lists.newArrayList(
      new String(Base64.encodeBase64(
          RowStoreUtil.RowStoreEncoder.toBytes(keySchema, range.getEnd()), false))));

  if (last) {
    kvs.put("final", Lists.newArrayList("true"));
  }
  return handler.get(kvs);
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:17,代码来源:TestRangeRetrieverHandler.java

示例3: getFileChunk

import org.apache.tajo.worker.dataserver.retriever.FileChunk; //导入依赖的package包/类
private FileChunk getFileChunk(RangeRetrieverHandler handler, Schema keySchema,
                               TupleRange range, boolean last) throws IOException {
  Map<String,List<String>> kvs = Maps.newHashMap();
  RowStoreEncoder encoder = RowStoreUtil.createEncoder(keySchema);
  kvs.put("start", Lists.newArrayList(
      new String(Base64.encodeBase64(
          encoder.toBytes(range.getStart()),
          false))));
  kvs.put("end", Lists.newArrayList(
      new String(Base64.encodeBase64(
          encoder.toBytes(range.getEnd()), false))));

  if (last) {
    kvs.put("final", Lists.newArrayList("true"));
  }
  return handler.get(kvs);
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:18,代码来源:TestRangeRetrieverHandler.java

示例4: get

import org.apache.tajo.worker.dataserver.retriever.FileChunk; //导入依赖的package包/类
@Override
public FileChunk get(Map<String, List<String>> kvs) throws IOException {
  // nothing to verify the file because AdvancedDataRetriever checks
  // its validity of the file.
  File file = new File(baseDir + "/" + kvs.get("fn").get(0));

  return new FileChunk(file, 0, file.length());
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:9,代码来源:PartitionRetrieverHandler.java

示例5: handle

import org.apache.tajo.worker.dataserver.retriever.FileChunk; //导入依赖的package包/类
@Override
public FileChunk [] handle(ChannelHandlerContext ctx, HttpRequest request)
    throws IOException {
     
  int start = request.getUri().indexOf('?');
  if (start < 0) {
    throw new IllegalArgumentException("Wrong request: " + request.getUri());
  }
  
  String queryStr = request.getUri().substring(start + 1);
  LOG.info("QUERY: " + queryStr);
  String [] queries = queryStr.split("&");
  
  String qid = null;
  String fn = null;
  String [] kv;
  for (String query : queries) {
    kv = query.split("=");
    if (kv[0].equals("qid")) {
      qid = kv[1];
    } else if (kv[0].equals("fn")) {
      fn = kv[1];
    }
  }
  
  String baseDir = map.get(qid);
  if (baseDir == null) {
    throw new FileNotFoundException("No such qid: " + qid);
  }

  File file = new File(baseDir + "/" + fn);
  if (file.isHidden() || !file.exists()) {
    throw new FileNotFoundException("No such file: " + baseDir + "/" 
        + file.getName());
  }
  if (!file.isFile()) {
    throw new FileAccessForbiddenException("No such file: " 
        + baseDir + "/" + file.getName()); 
  }
  
  return new FileChunk[] {new FileChunk(file, 0, file.length())};
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:43,代码来源:InterDataRetriever.java


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