package org.apache.hadoop.io;
import java.io.*;
/** A WritableComparable for ints. */
public class IntWritable implements WritableComparable {
private int value; //对int的封装
public IntWritable() {}
public IntWritable(int value) { set(value); }
/** Set the value of this IntWritable. */
public void set(int value) { this.value = value; }
/** Return the value of this IntWritable. */
public int get() { return value; }
public void readFields(DataInput in) throws IOException {
value = in.readInt();
}
public void write(DataOutput out) throws IOException {
out.writeInt(value);
}
/** Returns true iff <code>o</code> is a IntWritable with the same value. */
public boolean equals(Object o) {
if (!(o instanceof IntWritable))
return false;
IntWritable other = (IntWritable)o;
return this.value == other.value;
}
p
hadoop (1.0.4) IntWritable 详解
最新推荐文章于 2024-03-08 16:46:49 发布