public void write(Writable w) throws IOException {
if (w instanceof TypedBytesWritable) {
writeTypedBytes((TypedBytesWritable) w);
} else if (w instanceof BytesWritable) {
writeBytes((BytesWritable) w);
} else if (w instanceof ByteWritable) {
writeByte((ByteWritable) w);
} else if (w instanceof BooleanWritable) {
writeBoolean((BooleanWritable) w);
} else if (w instanceof IntWritable) {
writeInt((IntWritable) w);
} else if (w instanceof VIntWritable) {
writeVInt((VIntWritable) w);
} else if (w instanceof LongWritable) {
writeLong((LongWritable) w);
} else if (w instanceof VLongWritable) {
writeVLong((VLongWritable) w);
} else if (w instanceof FloatWritable) {
writeFloat((FloatWritable) w);
} else if (w instanceof DoubleWritable) {
writeDouble((DoubleWritable) w);
} else if (w instanceof Text) {
writeText((Text) w);
} else if (w instanceof ArrayWritable) {
writeArray((ArrayWritable) w);
} else if (w instanceof MapWritable) {
writeMap((MapWritable) w);
} else if (w instanceof SortedMapWritable) {
writeSortedMap((SortedMapWritable) w);
} else if (w instanceof Record) {
writeRecord((Record) w);
} else {
writeWritable(w); // last resort
}
}
java类org.apache.hadoop.io.FloatWritable的实例源码
TypedBytesWritableOutput.java 文件源码
项目:hadoop
阅读 24
收藏 0
点赞 0
评论 0
TypedBytesWritableInput.java 文件源码
项目:hadoop
阅读 30
收藏 0
点赞 0
评论 0
public Class<? extends Writable> readType() throws IOException {
Type type = in.readType();
if (type == null) {
return null;
}
switch (type) {
case BYTES:
return BytesWritable.class;
case BYTE:
return ByteWritable.class;
case BOOL:
return BooleanWritable.class;
case INT:
return VIntWritable.class;
case LONG:
return VLongWritable.class;
case FLOAT:
return FloatWritable.class;
case DOUBLE:
return DoubleWritable.class;
case STRING:
return Text.class;
case VECTOR:
return ArrayWritable.class;
case MAP:
return MapWritable.class;
case WRITABLE:
return Writable.class;
default:
throw new RuntimeException("unknown type");
}
}
TestPipeApplication.java 文件源码
项目:aliyun-oss-hadoop-fs
阅读 28
收藏 0
点赞 0
评论 0
@Override
public boolean next(FloatWritable key, NullWritable value)
throws IOException {
progress = key;
index++;
return index <= 10;
}
AngularDistanceUDF.java 文件源码
项目:incubator-hivemall
阅读 23
收藏 0
点赞 0
评论 0
@Override
public FloatWritable evaluate(DeferredObject[] arguments) throws HiveException {
List<String> ftvec1 = HiveUtils.asStringList(arguments[0], arg0ListOI);
List<String> ftvec2 = HiveUtils.asStringList(arguments[1], arg1ListOI);
float d = 1.f - AngularSimilarityUDF.angularSimilarity(ftvec1, ftvec2);
return new FloatWritable(d);
}
EuclidSimilarity.java 文件源码
项目:incubator-hivemall
阅读 18
收藏 0
点赞 0
评论 0
@Override
public FloatWritable evaluate(DeferredObject[] arguments) throws HiveException {
List<String> ftvec1 = HiveUtils.asStringList(arguments[0], arg0ListOI);
List<String> ftvec2 = HiveUtils.asStringList(arguments[1], arg1ListOI);
float d = (float) EuclidDistanceUDF.euclidDistance(ftvec1, ftvec2);
float sim = 1.0f / (1.0f + d);
return new FloatWritable(sim);
}
TestTaskContext.java 文件源码
项目:aliyun-oss-hadoop-fs
阅读 23
收藏 0
点赞 0
评论 0
public void testTaskContext() {
TaskContext context = new TaskContext(null, null, null, null, null, null, null);
context.setInputKeyClass(IntWritable.class);
assertEquals(IntWritable.class.getName(), context.getInputKeyClass().getName());
context.setInputValueClass(Text.class);
assertEquals(Text.class.getName(), context.getInputValueClass().getName());
context.setOutputKeyClass(LongWritable.class);
assertEquals(LongWritable.class.getName(), context.getOutputKeyClass().getName());
context.setOutputValueClass(FloatWritable.class);
assertEquals(FloatWritable.class.getName(), context.getOutputValueClass().getName());
}
BytesFactory.java 文件源码
项目:aliyun-oss-hadoop-fs
阅读 20
收藏 0
点赞 0
评论 0
public static void updateObject(Writable obj, byte[] seed) {
if (obj instanceof IntWritable) {
((IntWritable)obj).set(Ints.fromByteArray(seed));
} else if (obj instanceof FloatWritable) {
((FloatWritable)obj).set(r.nextFloat());
} else if (obj instanceof DoubleWritable) {
((DoubleWritable)obj).set(r.nextDouble());
} else if (obj instanceof LongWritable) {
((LongWritable)obj).set(Longs.fromByteArray(seed));
} else if (obj instanceof VIntWritable) {
((VIntWritable)obj).set(Ints.fromByteArray(seed));
} else if (obj instanceof VLongWritable) {
((VLongWritable)obj).set(Longs.fromByteArray(seed));
} else if (obj instanceof BooleanWritable) {
((BooleanWritable)obj).set(seed[0] % 2 == 1 ? true : false);
} else if (obj instanceof Text) {
((Text)obj).set(BytesUtil.toStringBinary(seed));
} else if (obj instanceof ByteWritable) {
((ByteWritable)obj).set(seed.length > 0 ? seed[0] : 0);
} else if (obj instanceof BytesWritable) {
((BytesWritable)obj).set(seed, 0, seed.length);
} else if (obj instanceof UTF8) {
((UTF8)obj).set(BytesUtil.toStringBinary(seed));
} else if (obj instanceof MockValueClass) {
((MockValueClass)obj).set(seed);
} else {
throw new IllegalArgumentException("unknown writable: " +
obj.getClass().getName());
}
}
OutputHandler.java 文件源码
项目:aliyun-oss-hadoop-fs
阅读 24
收藏 0
点赞 0
评论 0
/**
* Create a handler that will handle any records output from the application.
* @param collector the "real" collector that takes the output
* @param reporter the reporter for reporting progress
*/
public OutputHandler(OutputCollector<K, V> collector, Reporter reporter,
RecordReader<FloatWritable,NullWritable> recordReader,
String expectedDigest) {
this.reporter = reporter;
this.collector = collector;
this.recordReader = recordReader;
this.expectedDigest = expectedDigest;
}
TypedBytesWritableOutput.java 文件源码
项目:aliyun-oss-hadoop-fs
阅读 22
收藏 0
点赞 0
评论 0
public void write(Writable w) throws IOException {
if (w instanceof TypedBytesWritable) {
writeTypedBytes((TypedBytesWritable) w);
} else if (w instanceof BytesWritable) {
writeBytes((BytesWritable) w);
} else if (w instanceof ByteWritable) {
writeByte((ByteWritable) w);
} else if (w instanceof BooleanWritable) {
writeBoolean((BooleanWritable) w);
} else if (w instanceof IntWritable) {
writeInt((IntWritable) w);
} else if (w instanceof VIntWritable) {
writeVInt((VIntWritable) w);
} else if (w instanceof LongWritable) {
writeLong((LongWritable) w);
} else if (w instanceof VLongWritable) {
writeVLong((VLongWritable) w);
} else if (w instanceof FloatWritable) {
writeFloat((FloatWritable) w);
} else if (w instanceof DoubleWritable) {
writeDouble((DoubleWritable) w);
} else if (w instanceof Text) {
writeText((Text) w);
} else if (w instanceof ArrayWritable) {
writeArray((ArrayWritable) w);
} else if (w instanceof MapWritable) {
writeMap((MapWritable) w);
} else if (w instanceof SortedMapWritable) {
writeSortedMap((SortedMapWritable<?>) w);
} else if (w instanceof Record) {
writeRecord((Record) w);
} else {
writeWritable(w); // last resort
}
}
ZScoreUDF.java 文件源码
项目:incubator-hivemall
阅读 18
收藏 0
点赞 0
评论 0
public FloatWritable evaluate(float value, float mean, float stddev) {
if (stddev == 0.f) {
return new FloatWritable(0.f);
}
float v = (value - mean) / stddev;
return new FloatWritable(v);
}