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