WritableComparable (Hadoop 1.2.1 API)
Date: 2013-07-22

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.hadoop.io
Interface WritableComparable<T>

All Superinterfaces:
  Comparable<T>, Writable

All Known Implementing Classes:
  BooleanWritable, BytesWritable, ByteWritable, DocumentID, DoubleWritable, FloatWritable, ID, ID, IntWritable, JobID, JobID, Key, LongWritable, MD5Hash, MultiFileWordCount.WordOffset, NullWritable, Record, RecordTypeInfo, SecondarySort.IntPair, Shard, TaskAttemptID, TaskAttemptID, TaskID, TaskID, Text, TypedBytesWritable, UTF8, VIntWritable, VLongWritable

    public interface WritableComparable<T>

extends Writable, Comparable<T>

A `Writable` which is also `Comparable`.

`WritableComparable`s can be compared to each other, typically via `Comparator`s. Any type which is to be used as a `key` in the Hadoop Map-Reduce framework should implement this interface.

Example:

>          public class MyWritableComparable implements WritableComparable {
>            // Some data
>            private int counter;
>            private long timestamp;

>            public void write(DataOutput out) throws IOException {
>              out.writeInt(counter);
>              out.writeLong(timestamp);
>            }

>            public void readFields(DataInput in) throws IOException {
>              counter = in.readInt();
>              timestamp = in.readLong();
>            }

>            public int compareTo(MyWritableComparable w) {
>              int thisValue = this.value;
>              int thatValue = ((IntWritable)o).value;
>              return (thisValue < thatValue ? -1 : (thisValue==thatValue ? 0 : 1));
>            }
>          }

Method Summary

Methods inherited from interface org.apache.hadoop.io.Writable
`readFields, write`

Methods inherited from interface java.lang.Comparable
`compareTo`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 The Apache Software Foundation