Package org.apache.hadoop.typedbytes

Examples of org.apache.hadoop.typedbytes.TypedBytesWritable


           
            TypedBytesOutput out =
                new TypedBytesOutput(new DataOutputStream(bytes));
            out.writeInt(rand.nextInt(2000000000));
           
            TypedBytesWritable val =
                new TypedBytesWritable(bytes.toByteArray());
           
            return val;
        }
View Full Code Here


            out.writeVectorHeader(array.length);
            for (int i=0; i<array.length; ++i) {
                out.writeDouble(array[i]);
            }
           
            TypedBytesWritable val =
                new TypedBytesWritable(bytes.toByteArray());
           
            return val;
        }
View Full Code Here

   *
   * @see org.apache.hadoop.mapred.RecordReader#createKey()
   */
  public TypedBytesWritable createKey() {
      //return this.recordReaderImpl.createKey();
      return new TypedBytesWritable();
  }
View Full Code Here

   *
   * @see org.apache.hadoop.mapred.RecordReader#createValue()
   */
  public TypedBytesWritable createValue() {
      //return this.recordReaderImpl.createValue();
      return new TypedBytesWritable();
  }
View Full Code Here

      Path file = new Path(root, "test.seq");
      assertTrue(fs.exists(file));
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, conf);
      int counter = 0;
      TypedBytesWritable key = new TypedBytesWritable();
      TypedBytesWritable value = new TypedBytesWritable();
      while (reader.next(key, value)) {
        assertEquals(Long.class, key.getValue().getClass());
        assertEquals(String.class, value.getValue().getClass());
        assertTrue("Invalid record.",
          Integer.parseInt(value.toString()) % 10 == 0);
        counter++;
      }
      assertEquals("Wrong number of records.", 100, counter);
    } finally {
      try {
View Full Code Here

 
  @Override
  public void initialize(PipeMapRed pipeMapRed) throws IOException {
    super.initialize(pipeMapRed);
    clientIn = pipeMapRed.getClientInput();
    key = new TypedBytesWritable();
    value = new TypedBytesWritable();
    in = new TypedBytesInput(clientIn);
  }
View Full Code Here

    return value;
  }

  @Override
  public String getLastOutput() {
    return new TypedBytesWritable(bytes).toString();
  }
View Full Code Here

    }
    TypedBytesInput tbinput = new TypedBytesInput(new DataInputStream(System.in));
    SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, path,
      TypedBytesWritable.class, TypedBytesWritable.class);
    try {
      TypedBytesWritable key = new TypedBytesWritable();
      TypedBytesWritable value = new TypedBytesWritable();
      byte[] rawKey = tbinput.readRaw();
      while (rawKey != null) {
        byte[] rawValue = tbinput.readRaw();
        key.set(rawKey, 0, rawKey.length);
        value.set(rawValue, 0, rawValue.length);
        writer.append(key, value);
        rawKey = tbinput.readRaw();
      }
    } finally {
      writer.close();
View Full Code Here

    }
    TypedBytesInput tbinput = new TypedBytesInput(new DataInputStream(System.in));
    SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, path,
      TypedBytesWritable.class, TypedBytesWritable.class);
    try {
      TypedBytesWritable key = new TypedBytesWritable();
      TypedBytesWritable value = new TypedBytesWritable();
      byte[] rawKey = tbinput.readRaw();
      while (rawKey != null) {
        byte[] rawValue = tbinput.readRaw();
        key.set(rawKey, 0, rawKey.length);
        value.set(rawValue, 0, rawValue.length);
        writer.append(key, value);
        rawKey = tbinput.readRaw();
      }
    } finally {
      writer.close();
View Full Code Here

      Path file = new Path(root, "test.seq");
      assertTrue(fs.exists(file));
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, conf);
      int counter = 0;
      TypedBytesWritable key = new TypedBytesWritable();
      TypedBytesWritable value = new TypedBytesWritable();
      while (reader.next(key, value)) {
        assertEquals(Long.class, key.getValue().getClass());
        assertEquals(String.class, value.getValue().getClass());
        assertTrue("Invalid record.",
          Integer.parseInt(value.toString()) % 10 == 0);
        counter++;
      }
      assertEquals("Wrong number of records.", 100, counter);
    } finally {
      try {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.typedbytes.TypedBytesWritable

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.