List of usage examples for org.apache.hadoop.io Text readString
public static String readString(DataInput in) throws IOException
From source file:org.goldenorb.io.input.RawSplit.java
License:Apache License
/** * Reads the fields in a given DataInput. * //from ww w. j a va2s.c om * @param in * - DataInput */ public void readFields(DataInput in) throws IOException { splitClass = Text.readString(in); dataLength = in.readLong(); bytes.readFields(in); int len = WritableUtils.readVInt(in); locations = new String[len]; for (int i = 0; i < len; ++i) { locations[i] = Text.readString(in); } }
From source file:org.goldenorb.jet.OrbPartitionMember.java
License:Apache License
/** * /* w w w .j ava 2s . c om*/ * @param DataInput in */ public void readFields(DataInput in) throws IOException { partitionID = in.readInt(); numberOfVertices = in.readInt(); superStep = in.readInt(); messagesSent = in.readInt(); percentComplete = in.readFloat(); hostname = Text.readString(in); leader = in.readBoolean(); port = in.readInt(); }
From source file:org.goldenorb.jet.OrbTrackerMember.java
License:Apache License
/** * /* www . ja v a 2 s . c o m*/ * @param DataInput * in */ public void readFields(DataInput in) throws IOException { partitionCapacity = in.readInt(); availablePartitions = in.readInt(); reservedPartitions = in.readInt(); inUsePartitions = in.readInt(); hostname = Text.readString(in); leader = in.readBoolean(); port = in.readInt(); }
From source file:org.goldenorb.jet.PartitionRequest.java
License:Apache License
/** * /*from ww w . j a v a 2s.co m*/ * @param DataInput in */ public void readFields(DataInput in) throws IOException { reservedPartitions = in.readInt(); activePartitions = in.readInt(); jobID = Text.readString(in); basePartitionID = in.readInt(); jobConf = new OrbConfiguration(); jobConf.readFields(in); }
From source file:org.gridgain.grid.kernal.processors.hadoop.v2.GridHadoopV2Job.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w w w . ja v a 2 s . c o m public Collection<GridHadoopInputSplit> input() throws GridException { Thread.currentThread().setContextClassLoader(jobConf.getClassLoader()); try { String jobDirPath = jobConf.get(MRJobConfig.MAPREDUCE_JOB_DIR); if (jobDirPath == null) { // Probably job was submitted not by hadoop client. // Assume that we have needed classes and try to generate input splits ourself. if (jobConf.getUseNewMapper()) return GridHadoopV2Splitter.splitJob(jobCtx); else return GridHadoopV1Splitter.splitJob(jobConf); } Path jobDir = new Path(jobDirPath); try (FileSystem fs = FileSystem.get(jobDir.toUri(), jobConf)) { JobSplit.TaskSplitMetaInfo[] metaInfos = SplitMetaInfoReader.readSplitMetaInfo(hadoopJobID, fs, jobConf, jobDir); if (F.isEmpty(metaInfos)) throw new GridException("No input splits found."); Path splitsFile = JobSubmissionFiles.getJobSplitFile(jobDir); try (FSDataInputStream in = fs.open(splitsFile)) { Collection<GridHadoopInputSplit> res = new ArrayList<>(metaInfos.length); for (JobSplit.TaskSplitMetaInfo metaInfo : metaInfos) { long off = metaInfo.getStartOffset(); String[] hosts = metaInfo.getLocations(); in.seek(off); String clsName = Text.readString(in); GridHadoopFileBlock block = GridHadoopV1Splitter.readFileBlock(clsName, in, hosts); if (block == null) block = GridHadoopV2Splitter.readFileBlock(clsName, in, hosts); res.add(block != null ? block : new GridHadoopExternalSplit(hosts, off)); } return res; } } catch (Throwable e) { throw transformException(e); } } finally { Thread.currentThread().setContextClassLoader(null); } }
From source file:org.gridgain.grid.kernal.processors.hadoop.v2.GridHadoopV2TaskContext.java
License:Open Source License
/** * @param split External split./*from w w w . j a v a2s . co m*/ * @return Native input split. * @throws GridException If failed. */ @SuppressWarnings("unchecked") private Object readExternalSplit(GridHadoopExternalSplit split) throws GridException { Path jobDir = new Path(jobConf().get(MRJobConfig.MAPREDUCE_JOB_DIR)); try (FileSystem fs = FileSystem.get(jobDir.toUri(), jobConf()); FSDataInputStream in = fs.open(JobSubmissionFiles.getJobSplitFile(jobDir))) { in.seek(split.offset()); String clsName = Text.readString(in); Class<?> cls = jobConf().getClassByName(clsName); assert cls != null; Serialization serialization = new SerializationFactory(jobConf()).getSerialization(cls); Deserializer deserializer = serialization.getDeserializer(cls); deserializer.open(in); Object res = deserializer.deserialize(null); deserializer.close(); assert res != null; return res; } catch (IOException | ClassNotFoundException e) { throw new GridException(e); } }
From source file:org.sf.xrime.algorithms.BC.BCLabel.java
License:Apache License
public void readFields(DataInput in) throws IOException { status = in.readInt();//from w ww . j a v a 2 s. c o m distance = in.readInt(); number = in.readInt(); bc = in.readFloat(); int prosize = in.readInt(); if (prosize != 0) { if (precessor == null) { precessor = new ArrayList<String>(); } else { precessor.clear(); } for (int i = 0; i < prosize; i++) { String item = Text.readString(in); precessor.add(item); } } }
From source file:org.sf.xrime.algorithms.BFS.BFSLabel.java
License:Apache License
@Override public void readFields(DataInput in) throws IOException { status = in.readInt();//from w w w.jav a 2s . c om int size = in.readInt(); if (preps == null) { preps = new ArrayList<String>(); } else { preps.clear(); } for (int ii = 0; ii < size; ii++) { String item = Text.readString(in); preps.add(item); } }
From source file:org.sf.xrime.algorithms.layout.radialtree.RadialTreeLabel.java
License:Apache License
@Override public void readFields(DataInput in) throws IOException { status = in.readInt();/*from w w w. j a va 2s . com*/ weight = in.readDouble(); coordinate_x = in.readInt(); coordinate_y = in.readInt(); angle_from = in.readDouble(); angle_to = in.readDouble(); angle_begin = in.readDouble(); distance = in.readLong(); end = in.readInt(); pre = Text.readString(in); predistance = in.readLong(); next = in.readLong(); succ_angle_from = in.readDouble(); succ_angle_to = in.readDouble(); int size1 = in.readInt(); if (preps == null) { preps = new ArrayList<String>(); } else { preps.clear(); } for (int ii = 0; ii < size1; ii++) { String item = Text.readString(in); preps.add(item); } int size2 = in.readInt(); if (succ == null) { succ = new ArrayList<String>(); } else { succ.clear(); } for (int ii = 0; ii < size2; ii++) { String item = Text.readString(in); succ.add(item); } }
From source file:org.sf.xrime.algorithms.MST.MSTLabel.MSTMessageInitiateLabel.java
License:Apache License
@Override public void readFields(DataInput in) throws IOException { // TODO Auto-generated method stub fragLevel = in.readInt();//from ww w .j av a 2s . c o m fragIdentity = Text.readString(in); state = in.readInt(); }