本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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());
}
示例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())};
}