Package org.apache.hadoop.io

Examples of org.apache.hadoop.io.VLongWritable


      new Text("test1"), new Text("test2"), new Text("test3")
    };
    ArrayWritable vector = new ArrayWritable(Text.class, vectorValues);
    MapWritable map = new MapWritable();
    map.put(new Text("one"), new VIntWritable(1));
    map.put(new Text("two"), new VLongWritable(2));
    Writable[] writables = new Writable[] {
      new BytesWritable(new byte[] { 1, 2, 3, 4 }),
      new ByteWritable((byte) 123), new BooleanWritable(true),
      new VIntWritable(12345), new VLongWritable(123456789L),
      new FloatWritable((float) 1.2), new DoubleWritable(1.234),
      new Text("random string"),
      new ObjectWritable("test")
    };
    TypedBytesWritable tbw = new TypedBytesWritable();
View Full Code Here


  @Override
  public void readFields(DataInput in) throws IOException {
    representedAsList = in.readBoolean();
   
    VIntWritable vInt = new VIntWritable();
    VLongWritable vLong = new VLongWritable();
   
    if (representedAsList) {
      transactionSet = new ArrayList<Pair<List<Integer>,Long>>();
      vInt.readFields(in);
      int numTransactions = vInt.get();
      for (int i = 0; i < numTransactions; i++) {
        vLong.readFields(in);
        Long support = vLong.get();
       
        vInt.readFields(in);
        int length = vInt.get();
       
        Integer[] items = new Integer[length];
        for (int j = 0; j < length; j++) {
          vInt.readFields(in);
          items[j] = vInt.get();
        }
        Pair<List<Integer>,Long> transaction = new Pair<List<Integer>,Long>(Arrays.asList(items), support);
        transactionSet.add(transaction);
      }
    } else {
      vInt.readFields(in);
      nodes = vInt.get();
      attribute = new int[nodes];
      nodeCount = new long[nodes];
      childCount = new int[nodes];
      nodeChildren = new int[nodes][];
      for (int i = 0; i < nodes; i++) {
        vInt.readFields(in);
        attribute[i] = vInt.get();
        vLong.readFields(in);
        nodeCount[i] = vLong.get();
        vInt.readFields(in);
        childCount[i] = vInt.get();
        nodeChildren[i] = new int[childCount[i]];
        for (int j = 0, k = childCount[i]; j < k; j++) {
          vInt.readFields(in);
View Full Code Here

 
  @Override
  public void write(DataOutput out) throws IOException {
    out.writeBoolean(representedAsList);
    VIntWritable vInt = new VIntWritable();
    VLongWritable vLong = new VLongWritable();
    if (representedAsList) {
      vInt.set(transactionSet.size());
      vInt.write(out);
      for (int i = 0, j = transactionSet.size(); i < j; i++) {
        Pair<List<Integer>,Long> transaction = transactionSet.get(i);
       
        vLong.set(transaction.getSecond());
        vLong.write(out);
       
        vInt.set(transaction.getFirst().size());
        vInt.write(out);
       
        for (Integer item : transaction.getFirst()) {
          vInt.set(item);
          vInt.write(out);
        }
      }
    } else {
      vInt.set(nodes);
      vInt.write(out);
      for (int i = 0; i < nodes; i++) {
        vInt.set(attribute[i]);
        vInt.write(out);
        vLong.set(nodeCount[i]);
        vLong.write(out);
        vInt.set(childCount[i]);
        vInt.write(out);
        for (int j = 0, k = childCount[i]; j < k; j++) {
          vInt.set(nodeChildren[i][j]);
          vInt.write(out);
View Full Code Here

      VIntWritable vint = new VIntWritable();
      vint.readFields(in);
      return vint.get();

    case DataType.LONG:
      VLongWritable vlong = new VLongWritable();
      vlong.readFields(in);
      return vlong.get();

    case DataType.FLOAT:
      return in.readFloat();

    case DataType.DOUBLE:
View Full Code Here

      new VIntWritable((Integer)val).write(out);
      return;

    case DataType.LONG:
      out.writeByte(DataType.LONG);
      new VLongWritable((Long)val).write(out);
      return;

    case DataType.FLOAT:
      out.writeByte(DataType.FLOAT);
      out.writeFloat((Float)val);
View Full Code Here

      VIntWritable vint = new VIntWritable();
      vint.readFields(in);
      return vint.get();

    case DataType.LONG:
      VLongWritable vlong = new VLongWritable();
      vlong.readFields(in);
      return vlong.get();

    case DataType.FLOAT:
      return in.readFloat();

    case DataType.DOUBLE:
View Full Code Here

      new VIntWritable((Integer) val).write(out);
      return;

    case DataType.LONG:
      out.writeByte(DataType.LONG);
      new VLongWritable((Long) val).write(out);
      return;

    case DataType.FLOAT:
      out.writeByte(DataType.FLOAT);
      out.writeFloat((Float) val);
View Full Code Here

        writableTypeToJson(new VIntWritable(Integer.MAX_VALUE));
    }

    @Test
    public void testVLong() {
        writableTypeToJson(new VLongWritable(Long.MAX_VALUE));
    }
View Full Code Here

      VIntWritable vint = new VIntWritable();
      vint.readFields(in);
      return vint.get();

    case DataType.LONG:
      VLongWritable vlong = new VLongWritable();
      vlong.readFields(in);
      return vlong.get();

    case DataType.FLOAT:
      return in.readFloat();

    case DataType.DOUBLE:
View Full Code Here

      new VIntWritable((Integer)val).write(out);
      return;

    case DataType.LONG:
      out.writeByte(DataType.LONG);
      new VLongWritable((Long)val).write(out);
      return;

    case DataType.FLOAT:
      out.writeByte(DataType.FLOAT);
      out.writeFloat((Float)val);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.VLongWritable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.