Java Code Examples for org.apache.hadoop.io.Text#writeString()

The following examples show how to use org.apache.hadoop.io.Text#writeString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Metadata.java    From anthelion with Apache License 2.0 6 votes vote down vote up
public final void write(DataOutput out) throws IOException {
  out.writeInt(size());
  String[] values = null;
  String[] names = names();
  for (int i = 0; i < names.length; i++) {
    Text.writeString(out, names[i]);
    values = _getValues(names[i]);
    int cnt = 0;
    for (int j = 0; j < values.length; j++) {
      if (values[j] != null)
        cnt++;
    }
    out.writeInt(cnt);
    for (int j = 0; j < values.length; j++) {
      if (values[j] != null) {
        Text.writeString(out, values[j]);
      }
    }
  }
}
 
Example 2
Source File: SequenceFile.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/** Write and flush the file header. */
private void writeFileHeader() 
  throws IOException {
  out.write(VERSION);
  Text.writeString(out, keyClass.getName());
  Text.writeString(out, valClass.getName());
  
  out.writeBoolean(this.isCompressed());
  out.writeBoolean(this.isBlockCompressed());
  
  if (this.isCompressed()) {
    Text.writeString(out, (codec.getClass()).getName());
  }
  this.metadata.write(out);
  out.write(sync);                       // write the sync bytes
  out.flush();                           // flush header
}
 
Example 3
Source File: TezGroupedSplit.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
  if (wrappedSplits == null) {
    throw new TezUncheckedException("Wrapped splits cannot be empty");
  }

  Text.writeString(out, wrappedInputFormatName);
  Text.writeString(out, wrappedSplits.get(0).getClass().getName());
  out.writeInt(wrappedSplits.size());
  for(InputSplit split : wrappedSplits) {
    writeWrappedSplit(split, out);
  }
  out.writeLong(length);
  
  if (locations == null || locations.length == 0) {
    out.writeInt(0);
  } else {
    out.writeInt(locations.length);
    for (String location : locations) {
      Text.writeString(out, location);
    }
  }
}
 
Example 4
Source File: JobSplit.java    From big-c with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
  WritableUtils.writeVInt(out, locations.length);
  for (int i = 0; i < locations.length; i++) {
    Text.writeString(out, locations[i]);
  }
  WritableUtils.writeVLong(out, startOffset);
  WritableUtils.writeVLong(out, inputDataLength);
}
 
Example 5
Source File: LinkDatum.java    From nutch-htmlunit with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out)
  throws IOException {
  Text.writeString(out, url);
  Text.writeString(out, anchor != null ? anchor : "");
  out.writeFloat(score);
  out.writeLong(timestamp);
  out.writeByte(linkType);
}
 
Example 6
Source File: JobProfile.java    From RDFS with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
  jobid.write(out);
  Text.writeString(out, jobFile);
  Text.writeString(out, url);
  Text.writeString(out, user);
  Text.writeString(out, name);
  Text.writeString(out, queueName);
}
 
Example 7
Source File: CombineDocumentSplit.java    From marklogic-contentpump with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
    // splits
    out.writeInt(splits.size());
    for (FileSplit split : splits) {
        Text.writeString(out, split.getPath().toString());  
        out.writeLong(split.getStart());
        out.writeLong(split.getLength());
    }
    // length
    out.writeLong(length);
    // locations: not needed for serialization.  See FileSplit.write().
}
 
Example 8
Source File: JobProfile.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
  jobid.write(out);
  Text.writeString(out, jobFile);
  Text.writeString(out, url);
  Text.writeString(out, user);
  Text.writeString(out, name);
  Text.writeString(out, queueName);
}
 
Example 9
Source File: JobSplitWriter.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static SplitMetaInfo[] writeOldSplits(
    org.apache.hadoop.mapred.InputSplit[] splits,
    FSDataOutputStream out, Configuration conf) throws IOException {
  SplitMetaInfo[] info = new SplitMetaInfo[splits.length];
  if (splits.length != 0) {
    int i = 0;
    long offset = out.getPos();
    int maxBlockLocations = conf.getInt(MRConfig.MAX_BLOCK_LOCATIONS_KEY,
        MRConfig.MAX_BLOCK_LOCATIONS_DEFAULT);
    for(org.apache.hadoop.mapred.InputSplit split: splits) {
      long prevLen = out.getPos();
      Text.writeString(out, split.getClass().getName());
      split.write(out);
      long currLen = out.getPos();
      String[] locations = split.getLocations();
      if (locations.length > maxBlockLocations) {
        LOG.warn("Max block location exceeded for split: "
            + split + " splitsize: " + locations.length +
            " maxsize: " + maxBlockLocations);
        locations = Arrays.copyOf(locations,maxBlockLocations);
      }
      info[i++] = new JobSplit.SplitMetaInfo( 
          locations, offset,
          split.getLength());
      offset += currLen - prevLen;
    }
  }
  return info;
}
 
Example 10
Source File: BinaryProtocol.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public void authenticate(String digest, String challenge)
    throws IOException {
  LOG.debug("Sending AUTHENTICATION_REQ, digest=" + digest + ", challenge="
      + challenge);
  WritableUtils.writeVInt(stream, MessageType.AUTHENTICATION_REQ.code);
  Text.writeString(stream, digest);
  Text.writeString(stream, challenge);
}
 
Example 11
Source File: TaskStatus.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
  taskid.write(out);
  out.writeFloat(progress);
  out.writeInt(numSlots);
  WritableUtils.writeEnum(out, runState);
  Text.writeString(out, diagnosticInfo);
  Text.writeString(out, stateString);
  WritableUtils.writeEnum(out, phase);
  out.writeLong(startTime);
  out.writeLong(finishTime);
  out.writeBoolean(includeAllCounters);
  out.writeLong(outputSize);
  counters.write(out);
  nextRecordRange.write(out);
}
 
Example 12
Source File: Counters.java    From RDFS with Apache License 2.0 5 votes vote down vote up
public synchronized void write(DataOutput out) throws IOException {
  Text.writeString(out, displayName);
  WritableUtils.writeVInt(out, subcounters.size());
  for(Counter counter: subcounters.values()) {
    counter.write(out);
  }
}
 
Example 13
Source File: DistCpV1.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public void write(DataOutput out) throws IOException {
  input.write(out);
  Text.writeString(out, output);
}
 
Example 14
Source File: BinaryProtocol.java    From RDFS with Apache License 2.0 4 votes vote down vote up
public void setInputTypes(String keyType, 
                          String valueType) throws IOException {
  WritableUtils.writeVInt(stream, MessageType.SET_INPUT_TYPES.code);
  Text.writeString(stream, keyType);
  Text.writeString(stream, valueType);
}
 
Example 15
Source File: Shard.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
  Text.writeString(out, dir);
}
 
Example 16
Source File: ShuffleHeader.java    From incubator-tez with Apache License 2.0 4 votes vote down vote up
public void write(DataOutput out) throws IOException {
  Text.writeString(out, mapId);
  WritableUtils.writeVLong(out, compressedLength);
  WritableUtils.writeVLong(out, uncompressedLength);
  WritableUtils.writeVInt(out, forReduce);
}
 
Example 17
Source File: DistTool.java    From RDFS with Apache License 2.0 4 votes vote down vote up
protected static void writeString(DataOutput out, String s
    ) throws IOException {
  boolean b = s != null;
  out.writeBoolean(b);
  if (b) {Text.writeString(out, s);}
}
 
Example 18
Source File: DistTool.java    From hadoop-gpu with Apache License 2.0 4 votes vote down vote up
protected static void writeString(DataOutput out, String s
    ) throws IOException {
  boolean b = s != null;
  out.writeBoolean(b);
  if (b) {Text.writeString(out, s);}
}
 
Example 19
Source File: HiveKuduTableInputFormat.java    From HiveKudu-Handler with Apache License 2.0 4 votes vote down vote up
public void write(DataOutput out) throws IOException {
    Text.writeString(out, path.toString());
    delegate.write(out);
}
 
Example 20
Source File: DataDrivenDBInputFormat.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
public void write(DataOutput output) throws IOException {
  Text.writeString(output, this.lowerBoundClause);
  Text.writeString(output, this.upperBoundClause);
}