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


Java LobFile.create方法代码示例

本文整理汇总了Java中com.cloudera.sqoop.io.LobFile.create方法的典型用法代码示例。如果您正苦于以下问题:Java LobFile.create方法的具体用法?Java LobFile.create怎么用?Java LobFile.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cloudera.sqoop.io.LobFile的用法示例。


在下文中一共展示了LobFile.create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBlobWriter

import com.cloudera.sqoop.io.LobFile; //导入方法依赖的package包/类
/**
 * @return the current LobFile writer for BLOBs, creating one if necessary.
 */
private LobFile.Writer getBlobWriter() throws IOException {
  if (null == this.curBlobWriter) {
    this.curBlobWriter = LobFile.create(getNextLobFilePath(), conf, false);
  }

  return this.curBlobWriter;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:11,代码来源:LargeObjectLoader.java

示例2: getClobWriter

import com.cloudera.sqoop.io.LobFile; //导入方法依赖的package包/类
/**
 * @return the current LobFile writer for CLOBs, creating one if necessary.
 */
private LobFile.Writer getClobWriter() throws IOException {
  if (null == this.curClobWriter) {
    this.curClobWriter = LobFile.create(getNextLobFilePath(), conf, true);
  }

  return this.curClobWriter;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:11,代码来源:LargeObjectLoader.java

示例3: doExternalTest

import com.cloudera.sqoop.io.LobFile; //导入方法依赖的package包/类
private void doExternalTest(final String data, final String filename)
    throws IOException {

  Configuration conf = new Configuration();
  if (!BaseSqoopTestCase.isOnPhysicalCluster()) {
    conf.set(CommonArgs.FS_DEFAULT_NAME, CommonArgs.LOCAL_FS);
  }
  FileSystem fs = FileSystem.get(conf);
  String tmpDir = System.getProperty("test.build.data", "/tmp/");

  Path tmpPath = new Path(tmpDir);
  Path clobFile = new Path(tmpPath, filename);

  // make any necessary parent dirs.
  Path clobParent = clobFile.getParent();
  if (!fs.exists(clobParent)) {
    fs.mkdirs(clobParent);
  }

  LobFile.Writer lw = LobFile.create(clobFile, conf, true);
  try {
    long off = lw.tell();
    long len = data.length();
    Writer w = lw.writeClobRecord(len);
    w.append(data);
    w.close();
    lw.close();

    String refString = "externalLob(lf," + filename
              + "," + off + "," + len + ")";
    ClobRef clob = ClobRef.parse(refString);
    assertTrue(clob.isExternal());
    assertEquals(refString, clob.toString());
    Reader r = clob.getDataStream(conf, tmpPath);
    assertNotNull(r);

    char [] buf = new char[4096];
    int chars = r.read(buf, 0, 4096);
    r.close();

    String str = new String(buf, 0, chars);
    assertEquals(data, str);
  } finally {
    fs.delete(clobFile, false);
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:47,代码来源:TestClobRef.java

示例4: doExternalTest

import com.cloudera.sqoop.io.LobFile; //导入方法依赖的package包/类
private void doExternalTest(final byte [] data, final String filename)
    throws IOException {

  Configuration conf = new Configuration();
  if (!BaseSqoopTestCase.isOnPhysicalCluster()) {
    conf.set(CommonArgs.FS_DEFAULT_NAME, CommonArgs.LOCAL_FS);
  }
  FileSystem fs = FileSystem.get(conf);
  String tmpDir = System.getProperty("test.build.data", "/tmp/");

  Path tmpPath = new Path(tmpDir);
  Path blobFile = new Path(tmpPath, filename);

  // make any necessary parent dirs.
  Path blobParent = blobFile.getParent();
  if (!fs.exists(blobParent)) {
    fs.mkdirs(blobParent);
  }

  LobFile.Writer lw = LobFile.create(blobFile, conf, false);
  try {
    long off = lw.tell();
    long len = data.length;
    OutputStream os = lw.writeBlobRecord(len);
    os.write(data, 0, data.length);
    os.close();
    lw.close();

    String refString = "externalLob(lf," + filename
        + "," + off + "," + len + ")";
    BlobRef blob = BlobRef.parse(refString);
    assertTrue(blob.isExternal());
    assertEquals(refString, blob.toString());
    InputStream is = blob.getDataStream(conf, tmpPath);
    assertNotNull(is);

    byte [] buf = new byte[4096];
    int bytes = is.read(buf, 0, 4096);
    is.close();

    assertEquals(data.length, bytes);
    for (int i = 0; i < bytes; i++) {
      assertEquals(data[i], buf[i]);
    }
  } finally {
    fs.delete(blobFile, false);
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:49,代码来源:TestBlobRef.java


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