Package org.apache.hadoop.hbase.codec

Examples of org.apache.hadoop.hbase.codec.KeyValueCodec$KeyValueDecoder


    this.util = new IPCUtil(new Configuration());
  }
 
  @Test
  public void testBuildCellBlock() throws IOException {
    doBuildCellBlockUndoCellBlock(new KeyValueCodec(), null);
    doBuildCellBlockUndoCellBlock(new KeyValueCodec(), new DefaultCodec());
    doBuildCellBlockUndoCellBlock(new KeyValueCodec(), new GzipCodec());
  }
View Full Code Here


    this.util = new IPCUtil(new Configuration());
  }
 
  @Test
  public void testBuildCellBlock() throws IOException {
    doBuildCellBlockUndoCellBlock(this.util, new KeyValueCodec(), null);
    doBuildCellBlockUndoCellBlock(this.util, new KeyValueCodec(), new DefaultCodec());
    doBuildCellBlockUndoCellBlock(this.util, new KeyValueCodec(), new GzipCodec());
  }
View Full Code Here

        usage(1);
      }
    }
    IPCUtil util = new IPCUtil(HBaseConfiguration.create());
    ((Log4JLogger)IPCUtil.LOG).getLogger().setLevel(Level.ALL);
    timerTests(util, count, size,  new KeyValueCodec(), null);
    timerTests(util, count, size,  new KeyValueCodec(), new DefaultCodec());
    timerTests(util, count, size,  new KeyValueCodec(), new GzipCodec());
  }
View Full Code Here

    Cell [] cells = getCells(count);
    int size = getRoughSize(cells);
    int initialBufferSize = 2 * size; // Multiply by 2 to ensure we don't have to grow buffer

    // Test KeyValue codec.
    doCodec(new KeyValueCodec(), cells, cycles, count, initialBufferSize);
    doCodec(new CellCodec(), cells, cycles, count, initialBufferSize);
    doCodec(new MessageCodec(), cells, cycles, count, initialBufferSize);
  }
View Full Code Here

    this.util = new IPCUtil(new Configuration());
  }
 
  @Test
  public void testBuildCellBlock() throws IOException {
    doBuildCellBlockUndoCellBlock(this.util, new KeyValueCodec(), null);
    doBuildCellBlockUndoCellBlock(this.util, new KeyValueCodec(), new DefaultCodec());
    doBuildCellBlockUndoCellBlock(this.util, new KeyValueCodec(), new GzipCodec());
  }
View Full Code Here

        usage(1);
      }
    }
    IPCUtil util = new IPCUtil(HBaseConfiguration.create());
    ((Log4JLogger)IPCUtil.LOG).getLogger().setLevel(Level.ALL);
    timerTests(util, count, size,  new KeyValueCodec(), null);
    timerTests(util, count, size,  new KeyValueCodec(), new DefaultCodec());
    timerTests(util, count, size,  new KeyValueCodec(), new GzipCodec());
  }
View Full Code Here

    Cell [] cells = getCells(count);
    int size = getRoughSize(cells);
    int initialBufferSize = 2 * size; // Multiply by 2 to ensure we don't have to grow buffer

    // Test KeyValue codec.
    doCodec(new KeyValueCodec(), cells, cycles, count, initialBufferSize);
    doCodec(new CellCodec(), cells, cycles, count, initialBufferSize);
    doCodec(new MessageCodec(), cells, cycles, count, initialBufferSize);
  }
View Full Code Here

  @Test
  public void testEmptyWorks() throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    CountingOutputStream cos = new CountingOutputStream(baos);
    DataOutputStream dos = new DataOutputStream(cos);
    KeyValueCodec kvc = new KeyValueCodec();
    Codec.Encoder encoder = kvc.getEncoder(dos);
    encoder.flush();
    dos.close();
    long offset = cos.getCount();
    assertEquals(0, offset);
    CountingInputStream cis =
      new CountingInputStream(new ByteArrayInputStream(baos.toByteArray()));
    DataInputStream dis = new DataInputStream(cis);
    Codec.Decoder decoder = kvc.getDecoder(dis);
    assertFalse(decoder.advance());
    dis.close();
    assertEquals(0, cis.getCount());
  }
View Full Code Here

  @Test
  public void testOne() throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    CountingOutputStream cos = new CountingOutputStream(baos);
    DataOutputStream dos = new DataOutputStream(cos);
    KeyValueCodec kvc = new KeyValueCodec();
    Codec.Encoder encoder = kvc.getEncoder(dos);
    final KeyValue kv =
      new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("q"), Bytes.toBytes("v"));
    final long length = kv.getLength() + Bytes.SIZEOF_INT;
    encoder.write(kv);
    encoder.flush();
    dos.close();
    long offset = cos.getCount();
    assertEquals(length, offset);
    CountingInputStream cis =
      new CountingInputStream(new ByteArrayInputStream(baos.toByteArray()));
    DataInputStream dis = new DataInputStream(cis);
    Codec.Decoder decoder = kvc.getDecoder(dis);
    assertTrue(decoder.advance()); // First read should pull in the KV
    // Second read should trip over the end-of-stream  marker and return false
    assertFalse(decoder.advance());
    dis.close();
    assertEquals(length, cis.getCount());
View Full Code Here

  @Test
  public void testThree() throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    CountingOutputStream cos = new CountingOutputStream(baos);
    DataOutputStream dos = new DataOutputStream(cos);
    KeyValueCodec kvc = new KeyValueCodec();
    Codec.Encoder encoder = kvc.getEncoder(dos);
    final KeyValue kv1 =
      new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("1"), Bytes.toBytes("1"));
    final KeyValue kv2 =
      new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("2"), Bytes.toBytes("2"));
    final KeyValue kv3 =
      new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("3"), Bytes.toBytes("3"));
    final long length = kv1.getLength() + Bytes.SIZEOF_INT;
    encoder.write(kv1);
    encoder.write(kv2);
    encoder.write(kv3);
    encoder.flush();
    dos.close();
    long offset = cos.getCount();
    assertEquals(length * 3, offset);
    CountingInputStream cis =
      new CountingInputStream(new ByteArrayInputStream(baos.toByteArray()));
    DataInputStream dis = new DataInputStream(cis);
    Codec.Decoder decoder = kvc.getDecoder(dis);
    assertTrue(decoder.advance());
    KeyValue kv = (KeyValue)decoder.current();
    assertTrue(kv1.equals(kv));
    assertTrue(decoder.advance());
    kv = (KeyValue)decoder.current();
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.codec.KeyValueCodec$KeyValueDecoder

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.