java类org.apache.hadoop.io.VLongWritable的实例源码

TypedBytesWritableInput.java 文件源码 项目:hadoop-2.6.0-cdh5.4.3 阅读 27 收藏 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");
  }
}
TypedBytesWritableOutput.java 文件源码 项目:hadoop-plus 阅读 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
  }
}
TypedBytesWritableInput.java 文件源码 项目:hadoop-plus 阅读 23 收藏 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");
  }
}
TypedBytesWritableOutput.java 文件源码 项目:hops 阅读 27 收藏 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
  }
}
TypedBytesWritableInput.java 文件源码 项目:hops 阅读 20 收藏 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");
  }
}
DataGenerator.java 文件源码 项目:pregelix 阅读 23 收藏 0 点赞 0 评论 0
@Override
public void map(LongWritable id, Text inputValue, OutputCollector<NullWritable, VLongWritable> output,
        Reporter reporter) throws IOException {
    String[] vertices = inputValue.toString().split(" ");
    long max = Long.parseLong(vertices[0]);
    for (int i = 1; i < vertices.length; i++) {
        long vid = Long.parseLong(vertices[i]);
        if (vid > max)
            max = vid;
    }
    value.set(max);
    output.collect(key, value);
}
DataGenerator.java 文件源码 项目:pregelix 阅读 22 收藏 0 点赞 0 评论 0
@Override
public void reduce(NullWritable inputKey, Iterator<VLongWritable> inputValue,
        OutputCollector<NullWritable, Text> output, Reporter reporter) throws IOException {
    while (inputValue.hasNext()) {
        long vid = inputValue.next().get();
        if (vid > max)
            max = vid;
    }
    if (this.output == null)
        this.output = output;

}
DataGenerator.java 文件源码 项目:pregelix 阅读 22 收藏 0 点赞 0 评论 0
@Override
public void reduce(NullWritable inputKey, Iterator<VLongWritable> inputValue,
        OutputCollector<NullWritable, VLongWritable> output, Reporter reporter) throws IOException {
    while (inputValue.hasNext()) {
        long vid = inputValue.next().get();
        if (vid > max)
            max = vid;
    }
    if (this.output == null)
        this.output = output;
}
ConnectedComponentsVertex.java 文件源码 项目:pregelix 阅读 25 收藏 0 点赞 0 评论 0
@Override
public void combine(VLongWritable vertexIndex, VLongWritable originalMessage, VLongWritable messageToCombine) {
    long oldValue = messageToCombine.get();
    long newValue = originalMessage.get();
    if (newValue < oldValue) {
        messageToCombine.set(newValue);
    }
}
ShortestPathsVertex.java 文件源码 项目:pregelix 阅读 17 收藏 0 点赞 0 评论 0
@Override
public void combine(VLongWritable vertexIndex, DoubleWritable originalMessage, DoubleWritable messageToCombine) {
    double oldValue = messageToCombine.get();
    double newValue = originalMessage.get();
    if (newValue < oldValue) {
        messageToCombine.set(newValue);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号