本文整理汇总了Java中org.apache.zookeeper.common.IOUtils类的典型用法代码示例。如果您正苦于以下问题:Java IOUtils类的具体用法?Java IOUtils怎么用?Java IOUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IOUtils类属于org.apache.zookeeper.common包,在下文中一共展示了IOUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadLSMapFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public static LocalStructureJiang [][] loadLSMapFile(Configuration conf) {
String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);
LocalStructureJiang [][] result = null;
WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);
LSJiangArray value = (LSJiangArray) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);
try {
while(lsmapfile.next(key, value)) {
result = (LocalStructureJiang [][]) ArrayUtils.add(result,
Arrays.copyOf(value.get(), value.get().length, LocalStructureJiang[].class));
}
} catch (Exception e) {
System.err.println("LocalStructureJiang.loadLSMapFile: unable to read fingerprint "
+ key + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
IOUtils.closeStream(lsmapfile);
return result;
}
示例2: loadInfoFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public Map<String, Integer> loadInfoFile(Configuration conf) {
String name = conf.get(Util.INFOFILENAMEPROPERTY, Util.INFOFILEDEFAULTNAME);
MapFile.Reader infofile = Util.createMapFileReader(conf, name);
Map<String, Integer> infomap = new HashMap<String,Integer>();
Text key = new Text();
IntWritable value = new IntWritable();
try {
while(infofile.next(key, value)) {
infomap.put(key.toString(), value.get());
}
} catch (Exception e) {
System.err.println("PartialScoreCylinder.loadInfoFile: unable to read fingerprint "
+ key + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
IOUtils.closeStream(infofile);
return infomap;
}
示例3: loadInfoFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public static Map<String, Minutia[]> loadInfoFile(Configuration conf) {
Map<String, Minutia[]> infomap = new HashMap<String, Minutia[]>();
String name = conf.get(Util.INFOFILENAMEPROPERTY, Util.INFOFILEDEFAULTNAME);
MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);
WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);
MinutiaArray value = (MinutiaArray) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);
try {
while(lsmapfile.next(key, value)) {
Writable [] w = value.get();
infomap.put(key.toString(), Arrays.copyOf(w, w.length, Minutia[].class));
}
} catch (Exception e) {
System.err.println("PartialScoreLSSR.loadInfoFile: unable to read fingerprint "
+ key + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
IOUtils.closeStream(lsmapfile);
return infomap;
}
示例4: loadLSMapFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public static LocalStructureCylinder [][] loadLSMapFile(Configuration conf) {
String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);
LocalStructureCylinder [][] result = null;
WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);
LSCylinderArray value = (LSCylinderArray) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);
try {
while(lsmapfile.next(key, value)) {
result = (LocalStructureCylinder [][]) ArrayUtils.add(result,
Arrays.copyOf(value.get(), value.get().length, LocalStructureCylinder[].class));
}
} catch (Exception e) {
System.err.println("LocalStructureCylinder.loadLSMapFile: unable to read fingerprint "
+ key + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
IOUtils.closeStream(lsmapfile);
return result;
}
示例5: loadLSMapFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public static LocalStructureCylinder [][] loadLSMapFile(Configuration conf) {
String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);
LocalStructureCylinder [][] result = null;
WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);
LSCylinderArray value = (LSCylinderArray) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);
try {
while(lsmapfile.next(key, value)) {
result = (LocalStructureCylinder [][]) ArrayUtils.add(result,
Arrays.copyOf(value.get(), value.get().length, LocalStructureCylinder[].class));
}
} catch (Exception e) {
System.err.println("LocalStructureCylinder.loadLSMapFile: unable to read fingerprint "
+ key + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
IOUtils.closeStream(lsmapfile);
return result;
}
示例6: loadInfoFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public static Map<String, Minutia[]> loadInfoFile(Configuration conf) {
Map<String, Minutia[]> infomap = new HashMap<String, Minutia[]>();
String name = conf.get(Util.INFOFILENAMEPROPERTY, Util.INFOFILEDEFAULTNAME);
MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);
WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);
MinutiaArray value = (MinutiaArray) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);
try {
while(lsmapfile.next(key, value)) {
infomap.put(key.toString(), Arrays.copyOf(value.get(), value.get().length, Minutia[].class));
}
} catch (Exception e) {
System.err.println("PartialScoreLSSR.loadInfoFile: unable to read fingerprint "
+ key + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
IOUtils.closeStream(lsmapfile);
return infomap;
}
示例7: writeJobSplitMetaInfo
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
private static void writeJobSplitMetaInfo(FileSystem fs, Path filename, FsPermission p, int splitMetaInfoVersion,
JobSplit.SplitMetaInfo[] allSplitMetaInfo) throws IOException {
// write the splits meta-info to a file for the job tracker
FSDataOutputStream out = null;
try {
out = FileSystem.create(fs, filename, p);
out.write(META_SPLIT_FILE_HEADER);
WritableUtils.writeVInt(out, splitMetaInfoVersion);
WritableUtils.writeVInt(out, allSplitMetaInfo.length);
for(JobSplit.SplitMetaInfo splitMetaInfo: allSplitMetaInfo) {
splitMetaInfo.write(out);
}
} finally {
IOUtils.closeStream(out);
}
}
示例8: getSplitDetails
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "unused" })
private <T> T getSplitDetails(Path file, long offset) throws IOException {
FileSystem fs = file.getFileSystem(getYarnConf());
FSDataInputStream inFile = null;
T split = null;
try {
inFile = fs.open(file);
inFile.seek(offset);
String className = Text.readString(inFile);
Class<T> cls;
try {
cls = (Class<T>) getYarnConf().getClassByName(className);
} catch (ClassNotFoundException ce) {
IOException wrap = new IOException(String.format("Split class %s not found", className));
wrap.initCause(ce);
throw wrap;
}
SerializationFactory factory = new SerializationFactory(getYarnConf());
Deserializer<T> deserializer = (Deserializer<T>) factory.getDeserializer(cls);
deserializer.open(inFile);
split = deserializer.deserialize(null);
} finally {
IOUtils.closeStream(inFile);
}
return split;
}
示例9: readFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public static String readFile(File file) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
BufferedInputStream is = new BufferedInputStream(new FileInputStream(file));
try {
IOUtils.copyBytes(is, os, 1024, true);
} finally {
is.close();
}
return os.toString();
}
示例10: buildSetTraceMaskRequest
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
/**
* Builds a SetTraceMask request to be sent to the server, consisting of
* "stmk" followed by the 8-byte long representation of the trace mask.
*
* @param mask trace mask to set
* @return built request
* @throws IOException if there is an I/O error
*/
private String buildSetTraceMaskRequest(long mask) throws IOException {
ByteArrayOutputStream baos = null;
DataOutputStream dos = null;
try {
baos = new ByteArrayOutputStream();
dos = new DataOutputStream(baos);
dos.writeBytes("stmk");
dos.writeLong(mask);
} finally {
IOUtils.closeStream(dos);
IOUtils.closeStream(baos);
}
return new String(baos.toByteArray());
}
示例11: saveInfoFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public void saveInfoFile(LocalStructure[][] inputls, Configuration conf) {
String name = conf.get(Util.INFOFILENAMEPROPERTY, Util.INFOFILEDEFAULTNAME);
MapFile.Writer lsmapfile = Util.createMapFileWriter(conf, name, Text.class, MinutiaArray.class);
Arrays.sort(inputls, new Comparator<LocalStructure[]>() {
public int compare(LocalStructure [] als1, LocalStructure [] als2) {
return als1[0].getFpid().compareTo(als2[0].getFpid());
}
});
Text fpid = new Text();
for(LocalStructure [] ails : inputls) {
fpid.set(ails[0].getFpid());
Minutia [] ma = new Minutia[ails.length];
try {
for(int i = 0; i < ails.length; i++)
ma[i] = ((LocalStructureCylinder) ails[i]).getMinutia();
lsmapfile.append(fpid, new MinutiaArray(ma));
} catch (IOException e) {
System.err.println("LocalStructure.saveInfoFile: unable to save fingerprint "
+ fpid.toString() + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
}
IOUtils.closeStream(lsmapfile);
return;
}
示例12: saveLSMapFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public static void saveLSMapFile(LocalStructure[][] inputls, Configuration conf) {
String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
MapFile.Writer lsmapfile = Util.createMapFileWriter(conf, name, Text.class, inputls[0][0].newArrayWritable().getClass());
Arrays.sort(inputls, new Comparator<LocalStructure[]>() {
public int compare(LocalStructure [] als1, LocalStructure [] als2) {
return als1[0].getFpid().compareTo(als2[0].getFpid());
}
});
Text fpid = new Text();
ArrayWritable aw = null;
for(LocalStructure [] ails : inputls) {
fpid.set(ails[0].getFpid());
ails = Util.removeNonValidLS(ails);
try {
aw = ails[0].newArrayWritable(ails);
lsmapfile.append(fpid, aw);
} catch (IOException e) {
System.err.println("LocalStructure.saveLSMapFile: unable to save fingerprint "
+ fpid.toString() + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
}
IOUtils.closeStream(lsmapfile);
}
示例13: loadLSMapFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public static <T extends LocalStructure> LocalStructure [][] loadLSMapFile(Configuration conf) {
String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
int length = Integer.parseInt(conf.get(Util.MAPFILELENGTHPROPERTY));
MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);
LocalStructure [][] result = new LocalStructure[length][];
int i = 0;
WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);
ArrayWritable value = (ArrayWritable) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);
try {
while(lsmapfile.next(key, value)) {
Writable [] aw = value.get();
result[i] = (LocalStructure []) Arrays.copyOf(aw, aw.length, LocalStructure[].class);
i++;
}
} catch (Exception e) {
System.err.println("LocalStructure.loadLSMapFile: unable to read fingerprint "
+ key + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
IOUtils.closeStream(lsmapfile);
return result;
}
示例14: saveLSMapFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public static void saveLSMapFile(LocalStructure[][] inputls, Configuration conf) {
String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
MapFile.Writer lsmapfile = Util.createMapFileWriter(conf, name, Text.class, inputls[0][0].newArrayWritable().getClass());
Arrays.sort(inputls, new Comparator<LocalStructure[]>() {
public int compare(LocalStructure [] als1, LocalStructure [] als2) {
return als1[0].getFpid().compareTo(als2[0].getFpid());
}
});
Text fpid = new Text();
ArrayWritable aw = null;
for(LocalStructure [] ails : inputls) {
fpid.set(ails[0].getFpid());
try {
aw = ails[0].newArrayWritable(ails);
lsmapfile.append(fpid, aw);
} catch (IOException e) {
System.err.println("LocalStructureCylinder.saveLSMapFile: unable to save fingerprint "
+ fpid.toString() + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
}
IOUtils.closeStream(lsmapfile);
}
示例15: saveInfoFile
import org.apache.zookeeper.common.IOUtils; //导入依赖的package包/类
public void saveInfoFile(LocalStructure[][] inputls, Configuration conf) {
String name = conf.get(Util.INFOFILENAMEPROPERTY, Util.INFOFILEDEFAULTNAME);
MapFile.Writer lsmapfile = Util.createMapFileWriter(conf, name, Text.class, MinutiaArray.class);
Arrays.sort(inputls, new Comparator<LocalStructure[]>() {
public int compare(LocalStructure [] als1, LocalStructure [] als2) {
return als1[0].getFpid().compareTo(als2[0].getFpid());
}
});
Text fpid = new Text();
for(LocalStructure [] ails : inputls) {
fpid.set(ails[0].getFpid());
Minutia [] ma = new Minutia[ails.length];
try {
for(int i = 0; i < ails.length; i++)
ma[i] = ((LocalStructureCylinder) ails[i]).getMinutia();
lsmapfile.append(fpid, new MinutiaArray(ma));
} catch (IOException e) {
System.err.println("LocalStructure.saveLSMapFile: unable to save fingerprint "
+ fpid.toString() + " in MapFile " + name + ": " + e.getMessage());
e.printStackTrace();
}
}
IOUtils.closeStream(lsmapfile);
return;
}