コード例 #1
0
ファイル: TestWritable.java プロジェクト: ukulililixl/core
  /** Utility method for testing writables. */
  public static Writable testWritable(Writable before, Configuration conf) throws Exception {
    DataOutputBuffer dob = new DataOutputBuffer();
    before.write(dob);

    DataInputBuffer dib = new DataInputBuffer();
    dib.reset(dob.getData(), dob.getLength());

    Writable after = (Writable) ReflectionUtils.newInstance(before.getClass(), conf);
    after.readFields(dib);

    assertEquals(before, after);
    return after;
  }
コード例 #2
0
  /** Used by child copy constructors. */
  protected synchronized void copy(Writable other) {
    if (other != null) {
      try {
        DataOutputBuffer out = new DataOutputBuffer();
        other.write(out);
        DataInputBuffer in = new DataInputBuffer();
        in.reset(out.getData(), out.getLength());
        readFields(in);

      } catch (IOException e) {
        throw new IllegalArgumentException("map cannot be copied: " + e.getMessage());
      }

    } else {
      throw new IllegalArgumentException("source map cannot be null");
    }
  }
コード例 #3
0
ファイル: WritableUtils.java プロジェクト: bruthe/hadoop-0.1r
 /** Move the data from the output buffer to the input buffer. */
 void moveData() {
   inBuffer.reset(outBuffer.getData(), outBuffer.getLength());
 }