本文整理汇总了Java中com.cloudera.sqoop.io.LobReaderCache类的典型用法代码示例。如果您正苦于以下问题:Java LobReaderCache类的具体用法?Java LobReaderCache怎么用?Java LobReaderCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LobReaderCache类属于com.cloudera.sqoop.io包,在下文中一共展示了LobReaderCache类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataStream
import com.cloudera.sqoop.io.LobReaderCache; //导入依赖的package包/类
/**
* Get access to the LOB data itself.
* This method returns a lazy reader of the LOB data, accessing the
* filesystem for external LOB storage as necessary.
* @param conf the Configuration used to access the filesystem
* @param basePath the base directory where the table records are
* stored.
* @return an object that lazily streams the record to the client.
* @throws IOException if it could not read the LOB from external storage.
*/
public ACCESSORTYPE getDataStream(Configuration conf, Path basePath)
throws IOException {
if (isExternal()) {
// Read from external storage.
Path pathToRead = LobReaderCache.qualify(
new Path(basePath, fileName), conf);
LOG.debug("Retreving data stream from external path: " + pathToRead);
if (lobReader != null) {
// We already have a reader open to a LobFile. Is it the correct file?
if (!pathToRead.equals(lobReader.getPath())) {
// No. Close this.lobReader and get the correct one.
LOG.debug("Releasing previous external reader for "
+ lobReader.getPath());
LobReaderCache.getCache().recycle(lobReader);
lobReader = LobReaderCache.getCache().get(pathToRead, conf);
}
} else {
lobReader = LobReaderCache.getCache().get(pathToRead, conf);
}
// We now have a LobFile.Reader associated with the correct file. Get to
// the correct offset and return an InputStream/Reader to the user.
if (lobReader.tell() != offset) {
LOG.debug("Seeking to record start offset " + offset);
lobReader.seek(offset);
}
if (!lobReader.next()) {
throw new IOException("Could not locate record at " + pathToRead
+ ":" + offset);
}
return getExternalSource(lobReader);
} else {
// This data is already materialized in memory; wrap it and return.
return getInternalSource(realData);
}
}
示例2: V0Writer
import com.cloudera.sqoop.io.LobReaderCache; //导入依赖的package包/类
/**
* Creates a LobFile Writer for file format version 0.
* @param p the path to create.
* @param conf the configuration to use to interact with the filesystem.
* @param isCharData true if this is for CLOBs, false for BLOBs.
* @param codecName the compression codec to use (or null for none).
* @param entriesPerSegment the number of index entries per IndexSegment.
*/
V0Writer(Path p, Configuration conf, boolean isCharData,
String codecName, int entriesPerSegment) throws IOException {
this.path = LobReaderCache.qualify(p, conf);
this.conf = conf;
this.isCharData = isCharData;
this.header = new LobFileHeader();
this.indexSegments = new LinkedList<IndexSegment>();
this.indexTable = new IndexTable();
this.maxEntriesPerSegment = entriesPerSegment;
this.codecName = codecName;
if (this.codecName != null) {
this.codec = CodecMap.getCodec(codecName, conf);
if (null != this.codec) {
this.compressor = codec.createCompressor();
}
}
init();
}
示例3: V0Reader
import com.cloudera.sqoop.io.LobReaderCache; //导入依赖的package包/类
V0Reader(Path path, Configuration conf, LobFileHeader header,
DataInputStream dis, FSDataInputStream stream, long fileLen)
throws IOException {
this.path = LobReaderCache.qualify(path, conf);
this.conf = conf;
this.header = header;
this.dataIn = dis;
this.underlyingInput = stream;
this.isAligned = false;
this.tmpRsmBuf = new byte[RecordStartMark.START_MARK_LENGTH];
this.fileLen = fileLen;
LOG.debug("Opening LobFile path: " + path);
openCodec();
openIndex();
}
示例4: close
import com.cloudera.sqoop.io.LobReaderCache; //导入依赖的package包/类
public void close() throws IOException {
// Discard any open LobReader.
if (null != this.lobReader) {
LobReaderCache.getCache().recycle(this.lobReader);
}
}