Java 类org.apache.hadoop.hbase.codec.KeyValueCodec 实例源码

项目:ditb    文件:TestIPCUtil.java   
/**
 * For running a few tests of methods herein.
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
  int count = 1024;
  int size = 10240;
  for (String arg: args) {
    if (arg.startsWith(COUNT)) {
      count = Integer.parseInt(arg.replace(COUNT, ""));
    } else if (arg.startsWith(SIZE)) {
      size = Integer.parseInt(arg.replace(SIZE, ""));
    } else {
      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());
}
项目:pbase    文件:TestIPCUtil.java   
/**
 * For running a few tests of methods herein.
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
  int count = 1024;
  int size = 10240;
  for (String arg: args) {
    if (arg.startsWith(COUNT)) {
      count = Integer.parseInt(arg.replace(COUNT, ""));
    } else if (arg.startsWith(SIZE)) {
      size = Integer.parseInt(arg.replace(SIZE, ""));
    } else {
      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());
}
项目:HIndex    文件:TestIPCUtil.java   
/**
 * For running a few tests of methods herein.
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
  int count = 1024;
  int size = 10240;
  for (String arg: args) {
    if (arg.startsWith(COUNT)) {
      count = Integer.parseInt(arg.replace(COUNT, ""));
    } else if (arg.startsWith(SIZE)) {
      size = Integer.parseInt(arg.replace(SIZE, ""));
    } else {
      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());
}
项目:HIndex    文件:TestKeyValueCodec.java   
@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());
}
项目:HIndex    文件:TestKeyValueCodec.java   
@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());
}
项目:hbase    文件:TestMultiParallel.java   
@BeforeClass public static void beforeClass() throws Exception {
  // Uncomment the following lines if more verbosity is needed for
  // debugging (see HBASE-12285 for details).
  //((Log4JLogger)RpcServer.LOG).getLogger().setLevel(Level.ALL);
  //((Log4JLogger)RpcClient.LOG).getLogger().setLevel(Level.ALL);
  //((Log4JLogger)ScannerCallable.LOG).getLogger().setLevel(Level.ALL);
  UTIL.getConfiguration().set(HConstants.RPC_CODEC_CONF_KEY,
      KeyValueCodec.class.getCanonicalName());
  UTIL.getConfiguration().setBoolean(LoadBalancer.TABLES_ON_MASTER, true);
  // We used to ask for system tables on Master exclusively but not needed by test and doesn't
  // work anyways -- so commented out.
  // UTIL.getConfiguration().setBoolean(LoadBalancer.SYSTEM_TABLES_ON_MASTER, true);
  UTIL.getConfiguration()
      .set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MyMasterObserver.class.getName());
  UTIL.startMiniCluster(slaves);
  Table t = UTIL.createMultiRegionTable(TEST_TABLE, Bytes.toBytes(FAMILY));
  UTIL.waitTableEnabled(TEST_TABLE);
  t.close();
  CONNECTION = ConnectionFactory.createConnection(UTIL.getConfiguration());
  assertTrue(MyMasterObserver.start.get());
}
项目:hbase    文件:TestCellBlockBuilder.java   
/**
 * For running a few tests of methods herein.
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
  int count = 1024;
  int size = 10240;
  for (String arg : args) {
    if (arg.startsWith(COUNT)) {
      count = Integer.parseInt(arg.replace(COUNT, ""));
    } else if (arg.startsWith(SIZE)) {
      size = Integer.parseInt(arg.replace(SIZE, ""));
    } else {
      usage(1);
    }
  }
  CellBlockBuilder builder = new CellBlockBuilder(HBaseConfiguration.create());
  timerTests(builder, count, size, new KeyValueCodec(), null);
  timerTests(builder, count, size, new KeyValueCodec(), new DefaultCodec());
  timerTests(builder, count, size, new KeyValueCodec(), new GzipCodec());
}
项目:PyroDB    文件:TestIPCUtil.java   
/**
 * For running a few tests of methods herein.
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
  int count = 1024;
  int size = 10240;
  for (String arg: args) {
    if (arg.startsWith(COUNT)) {
      count = Integer.parseInt(arg.replace(COUNT, ""));
    } else if (arg.startsWith(SIZE)) {
      size = Integer.parseInt(arg.replace(SIZE, ""));
    } else {
      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());
}
项目:PyroDB    文件:TestKeyValueCodec.java   
@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());
}
项目:PyroDB    文件:TestKeyValueCodec.java   
@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());
}
项目:c5    文件:TestIPCUtil.java   
/**
 * For running a few tests of methods herein.
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
  int count = 1024;
  int size = 10240;
  for (String arg: args) {
    if (arg.startsWith(COUNT)) {
      count = Integer.parseInt(arg.replace(COUNT, ""));
    } else if (arg.startsWith(SIZE)) {
      size = Integer.parseInt(arg.replace(SIZE, ""));
    } else {
      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());
}
项目:c5    文件:TestKeyValueCodec.java   
@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());
}
项目:c5    文件:TestKeyValueCodec.java   
@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());
}
项目:ditb    文件:TestMultiParallel.java   
@BeforeClass public static void beforeClass() throws Exception {
  // Uncomment the following lines if more verbosity is needed for
  // debugging (see HBASE-12285 for details).
  //((Log4JLogger)RpcServer.LOG).getLogger().setLevel(Level.ALL);
  //((Log4JLogger)RpcClient.LOG).getLogger().setLevel(Level.ALL);
  //((Log4JLogger)ScannerCallable.LOG).getLogger().setLevel(Level.ALL);
  UTIL.getConfiguration().set(HConstants.RPC_CODEC_CONF_KEY,
      KeyValueCodec.class.getCanonicalName());
  UTIL.startMiniCluster(slaves);
  HTable t = UTIL.createMultiRegionTable(TEST_TABLE, Bytes.toBytes(FAMILY));
  UTIL.waitTableEnabled(TEST_TABLE);
  t.close();
  CONNECTION = ConnectionFactory.createConnection(UTIL.getConfiguration());
}
项目:ditb    文件:CodecPerformance.java   
public static void main(String[] args) throws IOException {
  // How many Cells to encode/decode on each cycle.
  final int count = 100000;
  // How many times to do an operation; repeat gives hotspot chance to warm up.
  final int cycles = 30;

  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);
}
项目:ditb    文件:AbstractRpcClient.java   
@VisibleForTesting
public static String getDefaultCodec(final Configuration c) {
  // If "hbase.client.default.rpc.codec" is empty string -- you can't set it to null because
  // Configuration will complain -- then no default codec (and we'll pb everything).  Else
  // default is KeyValueCodec
  return c.get(DEFAULT_CODEC_CLASS, KeyValueCodec.class.getCanonicalName());
}
项目:pbase    文件:CodecPerformance.java   
public static void main(String[] args) throws IOException {
  // How many Cells to encode/decode on each cycle.
  final int count = 100000;
  // How many times to do an operation; repeat gives hotspot chance to warm up.
  final int cycles = 30;

  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);
}
项目:pbase    文件:AbstractRpcClient.java   
@VisibleForTesting
public static String getDefaultCodec(final Configuration c) {
  // If "hbase.client.default.rpc.codec" is empty string -- you can't set it to null because
  // Configuration will complain -- then no default codec (and we'll pb everything).  Else
  // default is KeyValueCodec
  return c.get(DEFAULT_CODEC_CLASS, KeyValueCodec.class.getCanonicalName());
}
项目:HIndex    文件:CodecPerformance.java   
public static void main(String[] args) throws IOException {
  // How many Cells to encode/decode on each cycle.
  final int count = 100000;
  // How many times to do an operation; repeat gives hotspot chance to warm up.
  final int cycles = 30;

  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);
}
项目:HIndex    文件:RpcClient.java   
@VisibleForTesting
public static String getDefaultCodec(final Configuration c) {
  // If "hbase.client.default.rpc.codec" is empty string -- you can't set it to null because
  // Configuration will complain -- then no default codec (and we'll pb everything).  Else
  // default is KeyValueCodec
  return c.get("hbase.client.default.rpc.codec", KeyValueCodec.class.getCanonicalName());
}
项目:HIndex    文件:TestKeyValueCodec.java   
@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();
  assertTrue(kv2.equals(kv));
  assertTrue(decoder.advance());
  kv = (KeyValue)decoder.current();
  assertTrue(kv3.equals(kv));
  assertFalse(decoder.advance());
  dis.close();
  assertEquals((length * 3), cis.getCount());
}
项目:hbase    文件:CodecPerformance.java   
public static void main(String[] args) throws IOException {
  // How many Cells to encode/decode on each cycle.
  final int count = 100000;
  // How many times to do an operation; repeat gives hotspot chance to warm up.
  final int cycles = 30;

  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);
}
项目:hbase    文件:AbstractRpcClient.java   
@VisibleForTesting
public static String getDefaultCodec(final Configuration c) {
  // If "hbase.client.default.rpc.codec" is empty string -- you can't set it to null because
  // Configuration will complain -- then no default codec (and we'll pb everything). Else
  // default is KeyValueCodec
  return c.get(DEFAULT_CODEC_CLASS, KeyValueCodec.class.getCanonicalName());
}
项目:PyroDB    文件:CodecPerformance.java   
public static void main(String[] args) throws IOException {
  // How many Cells to encode/decode on each cycle.
  final int count = 100000;
  // How many times to do an operation; repeat gives hotspot chance to warm up.
  final int cycles = 30;

  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);
}
项目:PyroDB    文件:RpcClient.java   
@VisibleForTesting
public static String getDefaultCodec(final Configuration c) {
  // If "hbase.client.default.rpc.codec" is empty string -- you can't set it to null because
  // Configuration will complain -- then no default codec (and we'll pb everything).  Else
  // default is KeyValueCodec
  return c.get("hbase.client.default.rpc.codec", KeyValueCodec.class.getCanonicalName());
}
项目:PyroDB    文件:TestKeyValueCodec.java   
@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();
  assertTrue(kv2.equals(kv));
  assertTrue(decoder.advance());
  kv = (KeyValue)decoder.current();
  assertTrue(kv3.equals(kv));
  assertFalse(decoder.advance());
  dis.close();
  assertEquals((length * 3), cis.getCount());
}
项目:c5    文件:CodecPerformance.java   
public static void main(String[] args) throws IOException {
  // How many Cells to encode/decode on each cycle.
  final int count = 100000;
  // How many times to do an operation; repeat gives hotspot chance to warm up.
  final int cycles = 30;

  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);
}
项目:c5    文件:RpcClient.java   
@VisibleForTesting
public static String getDefaultCodec(final Configuration c) {
  // If "hbase.client.default.rpc.codec" is empty string -- you can't set it to null because
  // Configuration will complain -- then no default codec (and we'll pb everything).  Else
  // default is KeyValueCodec
  return c.get("hbase.client.default.rpc.codec", KeyValueCodec.class.getCanonicalName());
}
项目:c5    文件:TestKeyValueCodec.java   
@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();
  assertTrue(kv2.equals(kv));
  assertTrue(decoder.advance());
  kv = (KeyValue)decoder.current();
  assertTrue(kv3.equals(kv));
  assertFalse(decoder.advance());
  dis.close();
  assertEquals((length * 3), cis.getCount());
}
项目:async-hbase-client    文件:AbstractRpcClient.java   
@VisibleForTesting
public static String getDefaultCodec(final Configuration c) {
  // If "hbase.client.default.rpc.codec" is empty string -- you can't set it to null because
  // Configuration will complain -- then no default codec (and we'll pb everything).  Else
  // default is KeyValueCodec
  return c.get(DEFAULT_CODEC_CLASS, KeyValueCodec.class.getCanonicalName());
}
项目:ditb    文件:TestIPCUtil.java   
@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());
}
项目:LCIndex-HBase-0.94.16    文件:WALEditCodec.java   
@Override
public Decoder getDecoder(InputStream is) {
  return
      (compression == null) ? new KeyValueCodec.KeyValueDecoder((DataInputStream) is)
          : new KeyValueCompression.CompressedKvDecoder((DataInputStream) is, compression);
}
项目:LCIndex-HBase-0.94.16    文件:WALEditCodec.java   
@Override
public Encoder getEncoder(OutputStream os) {
  return
      (compression == null) ? new KeyValueCodec.KeyValueEncoder((DataOutputStream) os)
      : new CompressedKvEncoder((DataOutputStream) os, compression);
}
项目:pbase    文件:WALCellCodec.java   
@Override
public Decoder getDecoder(InputStream is) {
  return (compression == null)
      ? new KeyValueCodec.KeyValueDecoder(is) : new CompressedKvDecoder(is, compression);
}
项目:pbase    文件:TestIPCUtil.java   
@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());
}
项目:HIndex    文件:WALCellCodec.java   
@Override
public Decoder getDecoder(InputStream is) {
  return (compression == null)
      ? new KeyValueCodec.KeyValueDecoder(is) : new CompressedKvDecoder(is, compression);
}
项目:HIndex    文件:TestIPCUtil.java   
@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());
}
项目:IRIndex    文件:WALEditCodec.java   
@Override
public Decoder getDecoder(InputStream is) {
  return
      (compression == null) ? new KeyValueCodec.KeyValueDecoder((DataInputStream) is)
          : new KeyValueCompression.CompressedKvDecoder((DataInputStream) is, compression);
}
项目:IRIndex    文件:WALEditCodec.java   
@Override
public Encoder getEncoder(OutputStream os) {
  return
      (compression == null) ? new KeyValueCodec.KeyValueEncoder((DataOutputStream) os)
      : new CompressedKvEncoder((DataOutputStream) os, compression);
}
项目:hbase    文件:TestCellBlockBuilder.java   
@Test
public void testBuildCellBlock() throws IOException {
  doBuildCellBlockUndoCellBlock(this.builder, new KeyValueCodec(), null);
  doBuildCellBlockUndoCellBlock(this.builder, new KeyValueCodec(), new DefaultCodec());
  doBuildCellBlockUndoCellBlock(this.builder, new KeyValueCodec(), new GzipCodec());
}