當前位置: 首頁>>代碼示例>>Java>>正文


Java LobReaderCache類代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:49,代碼來源:LobRef.java

示例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();
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:30,代碼來源:LobFile.java

示例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();
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:16,代碼來源:LobFile.java

示例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);
  }
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:7,代碼來源:LobRef.java


注:本文中的com.cloudera.sqoop.io.LobReaderCache類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。