[120] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
---|
| 2 | <!--NewPage--> |
---|
| 3 | <HTML> |
---|
| 4 | <HEAD> |
---|
| 5 | <!-- Generated by javadoc (build 1.6.0_07) on Tue Sep 01 20:56:53 UTC 2009 --> |
---|
| 6 | <TITLE> |
---|
| 7 | WritableComparable (Hadoop 0.20.1 API) |
---|
| 8 | </TITLE> |
---|
| 9 | |
---|
| 10 | <META NAME="date" CONTENT="2009-09-01"> |
---|
| 11 | |
---|
| 12 | <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> |
---|
| 13 | |
---|
| 14 | <SCRIPT type="text/javascript"> |
---|
| 15 | function windowTitle() |
---|
| 16 | { |
---|
| 17 | if (location.href.indexOf('is-external=true') == -1) { |
---|
| 18 | parent.document.title="WritableComparable (Hadoop 0.20.1 API)"; |
---|
| 19 | } |
---|
| 20 | } |
---|
| 21 | </SCRIPT> |
---|
| 22 | <NOSCRIPT> |
---|
| 23 | </NOSCRIPT> |
---|
| 24 | |
---|
| 25 | </HEAD> |
---|
| 26 | |
---|
| 27 | <BODY BGCOLOR="white" onload="windowTitle();"> |
---|
| 28 | <HR> |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | <!-- ========= START OF TOP NAVBAR ======= --> |
---|
| 32 | <A NAME="navbar_top"><!-- --></A> |
---|
| 33 | <A HREF="#skip-navbar_top" title="Skip navigation links"></A> |
---|
| 34 | <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> |
---|
| 35 | <TR> |
---|
| 36 | <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> |
---|
| 37 | <A NAME="navbar_top_firstrow"><!-- --></A> |
---|
| 38 | <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> |
---|
| 39 | <TR ALIGN="center" VALIGN="top"> |
---|
| 40 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> |
---|
| 41 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
---|
| 42 | <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
---|
| 43 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/WritableComparable.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> |
---|
| 44 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
---|
| 45 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
---|
| 46 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
---|
| 47 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
---|
| 48 | </TR> |
---|
| 49 | </TABLE> |
---|
| 50 | </TD> |
---|
| 51 | <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
---|
| 52 | </EM> |
---|
| 53 | </TD> |
---|
| 54 | </TR> |
---|
| 55 | |
---|
| 56 | <TR> |
---|
| 57 | <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
---|
| 58 | <A HREF="../../../../org/apache/hadoop/io/Writable.html" title="interface in org.apache.hadoop.io"><B>PREV CLASS</B></A> |
---|
| 59 | <A HREF="../../../../org/apache/hadoop/io/WritableComparator.html" title="class in org.apache.hadoop.io"><B>NEXT CLASS</B></A></FONT></TD> |
---|
| 60 | <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
---|
| 61 | <A HREF="../../../../index.html?org/apache/hadoop/io/WritableComparable.html" target="_top"><B>FRAMES</B></A> |
---|
| 62 | <A HREF="WritableComparable.html" target="_top"><B>NO FRAMES</B></A> |
---|
| 63 | <SCRIPT type="text/javascript"> |
---|
| 64 | <!-- |
---|
| 65 | if(window==top) { |
---|
| 66 | document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); |
---|
| 67 | } |
---|
| 68 | //--> |
---|
| 69 | </SCRIPT> |
---|
| 70 | <NOSCRIPT> |
---|
| 71 | <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> |
---|
| 72 | </NOSCRIPT> |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | </FONT></TD> |
---|
| 76 | </TR> |
---|
| 77 | <TR> |
---|
| 78 | <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
---|
| 79 | SUMMARY: NESTED | FIELD | CONSTR | METHOD</FONT></TD> |
---|
| 80 | <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
---|
| 81 | DETAIL: FIELD | CONSTR | METHOD</FONT></TD> |
---|
| 82 | </TR> |
---|
| 83 | </TABLE> |
---|
| 84 | <A NAME="skip-navbar_top"></A> |
---|
| 85 | <!-- ========= END OF TOP NAVBAR ========= --> |
---|
| 86 | |
---|
| 87 | <HR> |
---|
| 88 | <!-- ======== START OF CLASS DATA ======== --> |
---|
| 89 | <H2> |
---|
| 90 | <FONT SIZE="-1"> |
---|
| 91 | org.apache.hadoop.io</FONT> |
---|
| 92 | <BR> |
---|
| 93 | Interface WritableComparable<T></H2> |
---|
| 94 | <DL> |
---|
| 95 | <DT><B>All Superinterfaces:</B> <DD><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang">Comparable</A><T>, <A HREF="../../../../org/apache/hadoop/io/Writable.html" title="interface in org.apache.hadoop.io">Writable</A></DD> |
---|
| 96 | </DL> |
---|
| 97 | <DL> |
---|
| 98 | <DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../../org/apache/hadoop/io/BooleanWritable.html" title="class in org.apache.hadoop.io">BooleanWritable</A>, <A HREF="../../../../org/apache/hadoop/io/BytesWritable.html" title="class in org.apache.hadoop.io">BytesWritable</A>, <A HREF="../../../../org/apache/hadoop/io/ByteWritable.html" title="class in org.apache.hadoop.io">ByteWritable</A>, <A HREF="../../../../org/apache/hadoop/contrib/index/mapred/DocumentID.html" title="class in org.apache.hadoop.contrib.index.mapred">DocumentID</A>, <A HREF="../../../../org/apache/hadoop/io/DoubleWritable.html" title="class in org.apache.hadoop.io">DoubleWritable</A>, <A HREF="../../../../org/apache/hadoop/io/FloatWritable.html" title="class in org.apache.hadoop.io">FloatWritable</A>, <A HREF="../../../../org/apache/hadoop/mapreduce/ID.html" title="class in org.apache.hadoop.mapreduce">ID</A>, <A HREF="../../../../org/apache/hadoop/mapred/ID.html" title="class in org.apache.hadoop.mapred">ID</A>, <A HREF="../../../../org/apache/hadoop/io/IntWritable.html" title="class in org.apache.hadoop.io">IntWritable</A>, <A HREF="../../../../org/apache/hadoop/mapreduce/JobID.html" title="class in org.apache.hadoop.mapreduce">JobID</A>, <A HREF="../../../../org/apache/hadoop/mapred/JobID.html" title="class in org.apache.hadoop.mapred">JobID</A>, <A HREF="../../../../org/apache/hadoop/util/bloom/Key.html" title="class in org.apache.hadoop.util.bloom">Key</A>, <A HREF="../../../../org/apache/hadoop/io/LongWritable.html" title="class in org.apache.hadoop.io">LongWritable</A>, <A HREF="../../../../org/apache/hadoop/io/MD5Hash.html" title="class in org.apache.hadoop.io">MD5Hash</A>, <A HREF="../../../../org/apache/hadoop/examples/MultiFileWordCount.WordOffset.html" title="class in org.apache.hadoop.examples">MultiFileWordCount.WordOffset</A>, <A HREF="../../../../org/apache/hadoop/io/NullWritable.html" title="class in org.apache.hadoop.io">NullWritable</A>, <A HREF="../../../../org/apache/hadoop/record/Record.html" title="class in org.apache.hadoop.record">Record</A>, <A HREF="../../../../org/apache/hadoop/record/meta/RecordTypeInfo.html" title="class in org.apache.hadoop.record.meta">RecordTypeInfo</A>, <A HREF="../../../../org/apache/hadoop/examples/SecondarySort.IntPair.html" title="class in org.apache.hadoop.examples">SecondarySort.IntPair</A>, <A HREF="../../../../org/apache/hadoop/contrib/index/mapred/Shard.html" title="class in org.apache.hadoop.contrib.index.mapred">Shard</A>, <A HREF="../../../../org/apache/hadoop/mapreduce/TaskAttemptID.html" title="class in org.apache.hadoop.mapreduce">TaskAttemptID</A>, <A HREF="../../../../org/apache/hadoop/mapred/TaskAttemptID.html" title="class in org.apache.hadoop.mapred">TaskAttemptID</A>, <A HREF="../../../../org/apache/hadoop/mapreduce/TaskID.html" title="class in org.apache.hadoop.mapreduce">TaskID</A>, <A HREF="../../../../org/apache/hadoop/mapred/TaskID.html" title="class in org.apache.hadoop.mapred">TaskID</A>, <A HREF="../../../../org/apache/hadoop/io/Text.html" title="class in org.apache.hadoop.io">Text</A>, <A HREF="../../../../org/apache/hadoop/io/UTF8.html" title="class in org.apache.hadoop.io">UTF8</A>, <A HREF="../../../../org/apache/hadoop/io/VIntWritable.html" title="class in org.apache.hadoop.io">VIntWritable</A>, <A HREF="../../../../org/apache/hadoop/io/VLongWritable.html" title="class in org.apache.hadoop.io">VLongWritable</A></DD> |
---|
| 99 | </DL> |
---|
| 100 | <HR> |
---|
| 101 | <DL> |
---|
| 102 | <DT><PRE>public interface <B>WritableComparable<T></B><DT>extends <A HREF="../../../../org/apache/hadoop/io/Writable.html" title="interface in org.apache.hadoop.io">Writable</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang">Comparable</A><T></DL> |
---|
| 103 | </PRE> |
---|
| 104 | |
---|
| 105 | <P> |
---|
| 106 | A <A HREF="../../../../org/apache/hadoop/io/Writable.html" title="interface in org.apache.hadoop.io"><CODE>Writable</CODE></A> which is also <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang"><CODE>Comparable</CODE></A>. |
---|
| 107 | |
---|
| 108 | <p><code>WritableComparable</code>s can be compared to each other, typically |
---|
| 109 | via <code>Comparator</code>s. Any type which is to be used as a |
---|
| 110 | <code>key</code> in the Hadoop Map-Reduce framework should implement this |
---|
| 111 | interface.</p> |
---|
| 112 | |
---|
| 113 | <p>Example:</p> |
---|
| 114 | <p><blockquote><pre> |
---|
| 115 | public class MyWritableComparable implements WritableComparable { |
---|
| 116 | // Some data |
---|
| 117 | private int counter; |
---|
| 118 | private long timestamp; |
---|
| 119 | |
---|
| 120 | public void write(DataOutput out) throws IOException { |
---|
| 121 | out.writeInt(counter); |
---|
| 122 | out.writeLong(timestamp); |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | public void readFields(DataInput in) throws IOException { |
---|
| 126 | counter = in.readInt(); |
---|
| 127 | timestamp = in.readLong(); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | public int compareTo(MyWritableComparable w) { |
---|
| 131 | int thisValue = this.value; |
---|
| 132 | int thatValue = ((IntWritable)o).value; |
---|
| 133 | return (thisValue < thatValue ? -1 : (thisValue==thatValue ? 0 : 1)); |
---|
| 134 | } |
---|
| 135 | } |
---|
| 136 | </pre></blockquote></p> |
---|
| 137 | <P> |
---|
| 138 | |
---|
| 139 | <P> |
---|
| 140 | <HR> |
---|
| 141 | |
---|
| 142 | <P> |
---|
| 143 | |
---|
| 144 | <!-- ========== METHOD SUMMARY =========== --> |
---|
| 145 | |
---|
| 146 | <A NAME="method_summary"><!-- --></A> |
---|
| 147 | <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
---|
| 148 | <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
---|
| 149 | <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> |
---|
| 150 | <B>Method Summary</B></FONT></TH> |
---|
| 151 | </TR> |
---|
| 152 | </TABLE> |
---|
| 153 | <A NAME="methods_inherited_from_class_org.apache.hadoop.io.Writable"><!-- --></A> |
---|
| 154 | <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
---|
| 155 | <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> |
---|
| 156 | <TH ALIGN="left"><B>Methods inherited from interface org.apache.hadoop.io.<A HREF="../../../../org/apache/hadoop/io/Writable.html" title="interface in org.apache.hadoop.io">Writable</A></B></TH> |
---|
| 157 | </TR> |
---|
| 158 | <TR BGCOLOR="white" CLASS="TableRowColor"> |
---|
| 159 | <TD><CODE><A HREF="../../../../org/apache/hadoop/io/Writable.html#readFields(java.io.DataInput)">readFields</A>, <A HREF="../../../../org/apache/hadoop/io/Writable.html#write(java.io.DataOutput)">write</A></CODE></TD> |
---|
| 160 | </TR> |
---|
| 161 | </TABLE> |
---|
| 162 | <A NAME="methods_inherited_from_class_java.lang.Comparable"><!-- --></A> |
---|
| 163 | <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
---|
| 164 | <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> |
---|
| 165 | <TH ALIGN="left"><B>Methods inherited from interface java.lang.<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang">Comparable</A></B></TH> |
---|
| 166 | </TR> |
---|
| 167 | <TR BGCOLOR="white" CLASS="TableRowColor"> |
---|
| 168 | <TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html?is-external=true#compareTo(T)" title="class or interface in java.lang">compareTo</A></CODE></TD> |
---|
| 169 | </TR> |
---|
| 170 | </TABLE> |
---|
| 171 | |
---|
| 172 | <P> |
---|
| 173 | <!-- ========= END OF CLASS DATA ========= --> |
---|
| 174 | <HR> |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | <!-- ======= START OF BOTTOM NAVBAR ====== --> |
---|
| 178 | <A NAME="navbar_bottom"><!-- --></A> |
---|
| 179 | <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> |
---|
| 180 | <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> |
---|
| 181 | <TR> |
---|
| 182 | <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> |
---|
| 183 | <A NAME="navbar_bottom_firstrow"><!-- --></A> |
---|
| 184 | <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> |
---|
| 185 | <TR ALIGN="center" VALIGN="top"> |
---|
| 186 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> |
---|
| 187 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
---|
| 188 | <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
---|
| 189 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/WritableComparable.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> |
---|
| 190 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
---|
| 191 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
---|
| 192 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
---|
| 193 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
---|
| 194 | </TR> |
---|
| 195 | </TABLE> |
---|
| 196 | </TD> |
---|
| 197 | <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
---|
| 198 | </EM> |
---|
| 199 | </TD> |
---|
| 200 | </TR> |
---|
| 201 | |
---|
| 202 | <TR> |
---|
| 203 | <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
---|
| 204 | <A HREF="../../../../org/apache/hadoop/io/Writable.html" title="interface in org.apache.hadoop.io"><B>PREV CLASS</B></A> |
---|
| 205 | <A HREF="../../../../org/apache/hadoop/io/WritableComparator.html" title="class in org.apache.hadoop.io"><B>NEXT CLASS</B></A></FONT></TD> |
---|
| 206 | <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
---|
| 207 | <A HREF="../../../../index.html?org/apache/hadoop/io/WritableComparable.html" target="_top"><B>FRAMES</B></A> |
---|
| 208 | <A HREF="WritableComparable.html" target="_top"><B>NO FRAMES</B></A> |
---|
| 209 | <SCRIPT type="text/javascript"> |
---|
| 210 | <!-- |
---|
| 211 | if(window==top) { |
---|
| 212 | document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); |
---|
| 213 | } |
---|
| 214 | //--> |
---|
| 215 | </SCRIPT> |
---|
| 216 | <NOSCRIPT> |
---|
| 217 | <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> |
---|
| 218 | </NOSCRIPT> |
---|
| 219 | |
---|
| 220 | |
---|
| 221 | </FONT></TD> |
---|
| 222 | </TR> |
---|
| 223 | <TR> |
---|
| 224 | <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
---|
| 225 | SUMMARY: NESTED | FIELD | CONSTR | METHOD</FONT></TD> |
---|
| 226 | <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
---|
| 227 | DETAIL: FIELD | CONSTR | METHOD</FONT></TD> |
---|
| 228 | </TR> |
---|
| 229 | </TABLE> |
---|
| 230 | <A NAME="skip-navbar_bottom"></A> |
---|
| 231 | <!-- ======== END OF BOTTOM NAVBAR ======= --> |
---|
| 232 | |
---|
| 233 | <HR> |
---|
| 234 | Copyright © 2009 The Apache Software Foundation |
---|
| 235 | </BODY> |
---|
| 236 | </HTML> |
---|