Java 类org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange 实例源码

项目:ditb    文件:TestTerminatedWrapper.java   
@Test
public void testReadWriteSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(14);
  for (OrderedString t : new OrderedString[] {
      OrderedString.ASCENDING, OrderedString.DESCENDING
  }) {
    for (byte[] term : TERMINATORS) {
      for (String val : VALUES_STRINGS) {
        buff.setPosition(0);
        DataType<String> type = new TerminatedWrapper<String>(t, term);
        assertEquals(val.length() + 2 + term.length, type.encode(buff, val));
        buff.setPosition(0);
        assertEquals(val, type.decode(buff));
        assertEquals(val.length() + 2 + term.length, buff.getPosition());
      }
    }
  }
}
项目:ditb    文件:TestTerminatedWrapper.java   
@Test
public void testReadWriteNonSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(12);
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    for (byte[] term : TERMINATORS) {
      for (byte[] val : VALUES_BYTES) {
        buff.setPosition(0);
        DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(ord), term);
        assertEquals(val.length + term.length, type.encode(buff, val));
        buff.setPosition(0);
        assertArrayEquals(val, type.decode(buff));
        assertEquals(val.length + term.length, buff.getPosition());
      }
    }
  }
}
项目:ditb    文件:TestTerminatedWrapper.java   
@Test
public void testSkipSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(14);
  for (OrderedString t : new OrderedString[] {
      OrderedString.ASCENDING, OrderedString.DESCENDING
  }) {
    for (byte[] term : TERMINATORS) {
      for (String val : VALUES_STRINGS) {
        buff.setPosition(0);
        DataType<String> type = new TerminatedWrapper<String>(t, term);
        int expected = val.length() + 2 + term.length;
        assertEquals(expected, type.encode(buff, val));
        buff.setPosition(0);
        assertEquals(expected, type.skip(buff));
        assertEquals(expected, buff.getPosition());
      }
    }
  }
}
项目:ditb    文件:TestTerminatedWrapper.java   
@Test
public void testSkipNonSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(12);
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    for (byte[] term : TERMINATORS) {
      for (byte[] val : VALUES_BYTES) {
        buff.setPosition(0);
        DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(ord), term);
        int expected = type.encode(buff, val);
        buff.setPosition(0);
        assertEquals(expected, type.skip(buff));
        assertEquals(expected, buff.getPosition());
      }
    }
  }
}
项目:ditb    文件:TestFixedLengthWrapper.java   
@Test
public void testReadWrite() {
  for (int limit : limits) {
    PositionedByteRange buff = new SimplePositionedMutableByteRange(limit);
    for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
      for (byte[] val : VALUES) {
        buff.setPosition(0);
        DataType<byte[]> type = new FixedLengthWrapper<byte[]>(new RawBytes(ord), limit);
        assertEquals(limit, type.encode(buff, val));
        buff.setPosition(0);
        byte[] actual = type.decode(buff);
        assertTrue("Decoding output differs from expected", 
          Bytes.equals(val, 0, val.length, actual, 0, val.length));
        buff.setPosition(0);
        assertEquals(limit, type.skip(buff));
      }
    }
  }
}
项目:ditb    文件:TestRawString.java   
@Test
public void testReadWrite() {
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    RawString type =
        Order.ASCENDING == ord ? RawString.ASCENDING : RawString.DESCENDING;
    for (String val : VALUES) {
      PositionedByteRange buff = new SimplePositionedMutableByteRange(Bytes.toBytes(val).length);
      assertEquals(buff.getLength(), type.encode(buff, val));
      byte[] expected = Bytes.toBytes(val);
      ord.apply(expected);
      assertArrayEquals(expected, buff.getBytes());
      buff.setPosition(0);
      assertEquals(val, type.decode(buff));
      buff.setPosition(0);
      assertEquals(buff.getLength(), type.skip(buff));
      assertEquals(buff.getLength(), buff.getPosition());
    }
  }
}
项目:drill    文件:MaprDBCompareFunctionsProcessor.java   
@Override
protected ByteBuf getByteBuf(LogicalExpression valueArg, String encodingType) {
  switch (encodingType) {
    case "UTF8_OB":
    case "UTF8_OBD":
      if (valueArg instanceof ValueExpressions.QuotedString) {
        int stringLen = ((ValueExpressions.QuotedString) valueArg).value.getBytes(Charsets.UTF_8).length;
        ByteBuf bb = newByteBuf(stringLen + 2, true);
        PositionedByteRange br = new SimplePositionedMutableByteRange(bb.array(), 0, stringLen + 2);
        if (encodingType.endsWith("_OBD")) {
          org.apache.hadoop.hbase.util.OrderedBytes.encodeString(br, ((ValueExpressions.QuotedString) valueArg).value,
                                                                Order.DESCENDING);
          setSortOrderAscending(false);
        } else {
          org.apache.hadoop.hbase.util.OrderedBytes.encodeString(br, ((ValueExpressions.QuotedString) valueArg).value,
                                                                Order.ASCENDING);
        }
        return bb;
      }
  }
  return null;
}
项目:pbase    文件:TestTerminatedWrapper.java   
@Test
public void testReadWriteSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(14);
  for (OrderedString t : new OrderedString[] {
      OrderedString.ASCENDING, OrderedString.DESCENDING
  }) {
    for (byte[] term : TERMINATORS) {
      for (String val : VALUES_STRINGS) {
        buff.setPosition(0);
        DataType<String> type = new TerminatedWrapper<String>(t, term);
        assertEquals(val.length() + 2 + term.length, type.encode(buff, val));
        buff.setPosition(0);
        assertEquals(val, type.decode(buff));
        assertEquals(val.length() + 2 + term.length, buff.getPosition());
      }
    }
  }
}
项目:pbase    文件:TestTerminatedWrapper.java   
@Test
public void testReadWriteNonSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(12);
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    for (byte[] term : TERMINATORS) {
      for (byte[] val : VALUES_BYTES) {
        buff.setPosition(0);
        DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(ord), term);
        assertEquals(val.length + term.length, type.encode(buff, val));
        buff.setPosition(0);
        assertArrayEquals(val, type.decode(buff));
        assertEquals(val.length + term.length, buff.getPosition());
      }
    }
  }
}
项目:pbase    文件:TestTerminatedWrapper.java   
@Test
public void testSkipSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(14);
  for (OrderedString t : new OrderedString[] {
      OrderedString.ASCENDING, OrderedString.DESCENDING
  }) {
    for (byte[] term : TERMINATORS) {
      for (String val : VALUES_STRINGS) {
        buff.setPosition(0);
        DataType<String> type = new TerminatedWrapper<String>(t, term);
        int expected = val.length() + 2 + term.length;
        assertEquals(expected, type.encode(buff, val));
        buff.setPosition(0);
        assertEquals(expected, type.skip(buff));
        assertEquals(expected, buff.getPosition());
      }
    }
  }
}
项目:pbase    文件:TestTerminatedWrapper.java   
@Test
public void testSkipNonSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(12);
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    for (byte[] term : TERMINATORS) {
      for (byte[] val : VALUES_BYTES) {
        buff.setPosition(0);
        DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(ord), term);
        int expected = type.encode(buff, val);
        buff.setPosition(0);
        assertEquals(expected, type.skip(buff));
        assertEquals(expected, buff.getPosition());
      }
    }
  }
}
项目:pbase    文件:TestFixedLengthWrapper.java   
@Test
public void testReadWrite() {
  for (int limit : limits) {
    PositionedByteRange buff = new SimplePositionedMutableByteRange(limit);
    for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
      for (byte[] val : VALUES) {
        buff.setPosition(0);
        DataType<byte[]> type = new FixedLengthWrapper<byte[]>(new RawBytes(ord), limit);
        assertEquals(limit, type.encode(buff, val));
        buff.setPosition(0);
        byte[] actual = type.decode(buff);
        assertTrue("Decoding output differs from expected", 
          Bytes.equals(val, 0, val.length, actual, 0, val.length));
        buff.setPosition(0);
        assertEquals(limit, type.skip(buff));
      }
    }
  }
}
项目:pbase    文件:TestRawString.java   
@Test
public void testReadWrite() {
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    RawString type =
        Order.ASCENDING == ord ? RawString.ASCENDING : RawString.DESCENDING;
    for (String val : VALUES) {
      PositionedByteRange buff = new SimplePositionedMutableByteRange(Bytes.toBytes(val).length);
      assertEquals(buff.getLength(), type.encode(buff, val));
      byte[] expected = Bytes.toBytes(val);
      ord.apply(expected);
      assertArrayEquals(expected, buff.getBytes());
      buff.setPosition(0);
      assertEquals(val, type.decode(buff));
      buff.setPosition(0);
      assertEquals(buff.getLength(), type.skip(buff));
      assertEquals(buff.getLength(), buff.getPosition());
    }
  }
}
项目:hbase    文件:TestTerminatedWrapper.java   
@Test
public void testReadWriteSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(14);
  for (OrderedString t : new OrderedString[] {
      OrderedString.ASCENDING, OrderedString.DESCENDING
  }) {
    for (byte[] term : TERMINATORS) {
      for (String val : VALUES_STRINGS) {
        buff.setPosition(0);
        DataType<String> type = new TerminatedWrapper<>(t, term);
        assertEquals(val.length() + 2 + term.length, type.encode(buff, val));
        buff.setPosition(0);
        assertEquals(val, type.decode(buff));
        assertEquals(val.length() + 2 + term.length, buff.getPosition());
      }
    }
  }
}
项目:hbase    文件:TestTerminatedWrapper.java   
@Test
public void testReadWriteNonSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(12);
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    for (byte[] term : TERMINATORS) {
      for (byte[] val : VALUES_BYTES) {
        buff.setPosition(0);
        DataType<byte[]> type = new TerminatedWrapper<>(new RawBytes(ord), term);
        assertEquals(val.length + term.length, type.encode(buff, val));
        buff.setPosition(0);
        assertArrayEquals(val, type.decode(buff));
        assertEquals(val.length + term.length, buff.getPosition());
      }
    }
  }
}
项目:hbase    文件:TestTerminatedWrapper.java   
@Test
public void testSkipSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(14);
  for (OrderedString t : new OrderedString[] {
      OrderedString.ASCENDING, OrderedString.DESCENDING
  }) {
    for (byte[] term : TERMINATORS) {
      for (String val : VALUES_STRINGS) {
        buff.setPosition(0);
        DataType<String> type = new TerminatedWrapper<>(t, term);
        int expected = val.length() + 2 + term.length;
        assertEquals(expected, type.encode(buff, val));
        buff.setPosition(0);
        assertEquals(expected, type.skip(buff));
        assertEquals(expected, buff.getPosition());
      }
    }
  }
}
项目:hbase    文件:TestTerminatedWrapper.java   
@Test
public void testSkipNonSkippable() {
  PositionedByteRange buff = new SimplePositionedMutableByteRange(12);
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    for (byte[] term : TERMINATORS) {
      for (byte[] val : VALUES_BYTES) {
        buff.setPosition(0);
        DataType<byte[]> type = new TerminatedWrapper<>(new RawBytes(ord), term);
        int expected = type.encode(buff, val);
        buff.setPosition(0);
        assertEquals(expected, type.skip(buff));
        assertEquals(expected, buff.getPosition());
      }
    }
  }
}
项目:hbase    文件:TestFixedLengthWrapper.java   
@Test
public void testReadWrite() {
  for (int limit : limits) {
    PositionedByteRange buff = new SimplePositionedMutableByteRange(limit);
    for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
      for (byte[] val : VALUES) {
        buff.setPosition(0);
        DataType<byte[]> type = new FixedLengthWrapper<>(new RawBytes(ord), limit);
        assertEquals(limit, type.encode(buff, val));
        buff.setPosition(0);
        byte[] actual = type.decode(buff);
        assertTrue("Decoding output differs from expected",
          Bytes.equals(val, 0, val.length, actual, 0, val.length));
        buff.setPosition(0);
        assertEquals(limit, type.skip(buff));
      }
    }
  }
}
项目:hbase    文件:TestRawString.java   
@Test
public void testReadWrite() {
  for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
    RawString type =
        Order.ASCENDING == ord ? RawString.ASCENDING : RawString.DESCENDING;
    for (String val : VALUES) {
      PositionedByteRange buff = new SimplePositionedMutableByteRange(Bytes.toBytes(val).length);
      assertEquals(buff.getLength(), type.encode(buff, val));
      byte[] expected = Bytes.toBytes(val);
      ord.apply(expected);
      assertArrayEquals(expected, buff.getBytes());
      buff.setPosition(0);
      assertEquals(val, type.decode(buff));
      buff.setPosition(0);
      assertEquals(buff.getLength(), type.skip(buff));
      assertEquals(buff.getLength(), buff.getPosition());
    }
  }
}
项目:spliceengine    文件:SQLTinyIntTest.java   
@Test
public void serdeKeyData() throws Exception {
        SQLTinyint value1 = new SQLTinyint(Byte.valueOf("1"));
        SQLTinyint value2 = new SQLTinyint(Byte.valueOf("2"));
        SQLTinyint value1a = new SQLTinyint();
        SQLTinyint value2a = new SQLTinyint();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getByte(),value1a.getByte());
        Assert.assertEquals("2 incorrect",value2.getByte(),value2a.getByte());
}
项目:spliceengine    文件:SQLDoubleTest.java   
@Test
public void serdeKeyData() throws Exception {
        SQLDouble value1 = new SQLDouble(100.0d);
        SQLDouble value2 = new SQLDouble(200.0d);
        SQLDouble value1a = new SQLDouble();
        SQLDouble value2a = new SQLDouble();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getDouble(),value1a.getDouble(),0.0d);
        Assert.assertEquals("2 incorrect",value2.getDouble(),value2a.getDouble(),0.0d);
    }
项目:spliceengine    文件:SQLDecimalTest.java   
@Test
@Ignore
public void serdeKeyData() throws Exception {
        SQLDecimal value1 = new SQLDecimal(new BigDecimal(100.0d));
        SQLDecimal value2 = new SQLDecimal(new BigDecimal(200.0d));
        SQLDecimal value1a = new SQLDecimal();
        value1a.setPrecision(value1.getPrecision());
        value1a.setScale(value1.getScale());
        SQLDecimal value2a = new SQLDecimal();
        value2a.setPrecision(value2.getPrecision());
        value2a.setScale(value2.getScale());
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getBigDecimal().doubleValue(),value1a.getBigDecimal().doubleValue(),0.1d);
        Assert.assertEquals("2 incorrect",value2.getBigDecimal().doubleValue(),value2a.getBigDecimal().doubleValue(),0.1d);
}
项目:spliceengine    文件:SQLLongIntTest.java   
@Test
public void serdeKeyData() throws Exception {
        SQLLongint value1 = new SQLLongint(100l);
        SQLLongint value2 = new SQLLongint(200l);
        SQLLongint value1a = new SQLLongint();
        SQLLongint value2a = new SQLLongint();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getLong(),value1a.getLong(),0l);
        Assert.assertEquals("2 incorrect",value2.getLong(),value2a.getLong(),0l);
}
项目:spliceengine    文件:SQLSmallIntTest.java   
@Test
public void serdeKeyData() throws Exception {
        SQLSmallint value1 = new SQLSmallint(100);
        SQLSmallint value2 = new SQLSmallint(200);
        SQLSmallint value1a = new SQLSmallint();
        SQLSmallint value2a = new SQLSmallint();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getInt(),value1a.getInt(),0);
        Assert.assertEquals("2 incorrect",value2.getInt(),value2a.getInt(),0);
}
项目:spliceengine    文件:SQLVarcharTest.java   
@Test
public void serdeKeyData() throws Exception {
        SQLChar value1 = new SQLChar("Splice Machine");
        SQLChar value2 = new SQLChar("Xplice Machine");
        SQLChar value1a = new SQLChar();
        SQLChar value2a = new SQLChar();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getString(),value1a.getString());
        Assert.assertEquals("2 incorrect",value2.getString(),value2a.getString());
}
项目:spliceengine    文件:SQLTimestampTest.java   
@Test
public void serdeKeyData() throws Exception {
        GregorianCalendar gc = new GregorianCalendar();
        long currentTimeMillis = System.currentTimeMillis();
        SQLTimestamp value1 = new SQLTimestamp(new Timestamp(currentTimeMillis));
        SQLTimestamp value2 = new SQLTimestamp(new Timestamp(currentTimeMillis+200));
        SQLTimestamp value1a = new SQLTimestamp();
        SQLTimestamp value2a = new SQLTimestamp();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getTimestamp(gc),value1a.getTimestamp(gc));
        Assert.assertEquals("2 incorrect",value2.getTimestamp(gc),value2a.getTimestamp(gc));
}
项目:spliceengine    文件:SQLTimeTest.java   
@Test
public void serdeKeyData() throws Exception {
        GregorianCalendar gc = new GregorianCalendar();
        long currentTimeMillis = System.currentTimeMillis();
        SQLTime value1 = new SQLTime(new Time(currentTimeMillis));
        SQLTime value2 = new SQLTime(new Time(currentTimeMillis+200));
        SQLTime value1a = new SQLTime();
        SQLTime value2a = new SQLTime();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getTime(gc),value1a.getTime(gc));
        Assert.assertEquals("2 incorrect",value2.getTime(gc),value2a.getTime(gc));
}
项目:spliceengine    文件:SQLRealTest.java   
@Test
public void serdeKeyData() throws Exception {
        SQLReal value1 = new SQLReal(100.0f);
        SQLReal value2 = new SQLReal(200.0f);
        SQLReal value1a = new SQLReal();
        SQLReal value2a = new SQLReal();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getFloat(),value1a.getFloat(),0.0f);
        Assert.assertEquals("2 incorrect",value2.getFloat(),value2a.getFloat(),0.0f);
    }
项目:spliceengine    文件:SQLBooleanTest.java   
@Test
public void serdeKeyData() throws Exception {
        SQLBoolean value1 = new SQLBoolean(false);
        SQLBoolean value2 = new SQLBoolean(true);
        SQLBoolean value1a = new SQLBoolean();
        SQLBoolean value2a = new SQLBoolean();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getBoolean(),value1a.getBoolean());
        Assert.assertEquals("2 incorrect",value2.getBoolean(),value2a.getBoolean());
}
项目:spliceengine    文件:SQLIntegerTest.java   
@Test
public void serdeKeyData() throws Exception {
        SQLInteger value1 = new SQLInteger(100);
        SQLInteger value2 = new SQLInteger(200);
        SQLInteger value1a = new SQLInteger();
        SQLInteger value2a = new SQLInteger();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getInt(),value1a.getInt(),0);
        Assert.assertEquals("2 incorrect",value2.getInt(),value2a.getInt(),0);
}
项目:spliceengine    文件:SQLCharTest.java   
@Test
public void serdeKeyData() throws Exception {
        SQLChar value1 = new SQLChar("Splice Machine");
        SQLChar value2 = new SQLChar("Xplice Machine");
        SQLChar value1a = new SQLChar();
        SQLChar value2a = new SQLChar();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getString(),value1a.getString());
        Assert.assertEquals("2 incorrect",value2.getString(),value2a.getString());
}
项目:spliceengine    文件:SQLDateTest.java   
@Test
public void serdeKeyData() throws Exception {
        GregorianCalendar gc = new GregorianCalendar();
        SQLDate value1 = new SQLDate(new Date(97,9,7));
        SQLDate value2 = new SQLDate(new Date(97,10,7));
        SQLDate value1a = new SQLDate();
        SQLDate value2a = new SQLDate();
        PositionedByteRange range1 = new SimplePositionedMutableByteRange(value1.encodedKeyLength());
        PositionedByteRange range2 = new SimplePositionedMutableByteRange(value2.encodedKeyLength());
        value1.encodeIntoKey(range1, Order.ASCENDING);
        value2.encodeIntoKey(range2, Order.ASCENDING);
        Assert.assertTrue("Positioning is Incorrect", Bytes.compareTo(range1.getBytes(), 0, 9, range2.getBytes(), 0, 9) < 0);
        range1.setPosition(0);
        range2.setPosition(0);
        value1a.decodeFromKey(range1);
        value2a.decodeFromKey(range2);
        Assert.assertEquals("1 incorrect",value1.getDate(gc),value1a.getDate(gc));
        Assert.assertEquals("2 incorrect",value2.getDate(gc),value2a.getDate(gc));
}
项目:dremio-oss    文件:TestTableGenerator.java   
public static void generateHBaseDatasetDoubleOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);

  for (double i = 0.5; i <= 100.00; i += 0.75) {
    byte[] bytes = new byte[9];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
    OrderedBytes.encodeFloat64(br, i, Order.ASCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}
项目:dremio-oss    文件:TestTableGenerator.java   
public static void generateHBaseDatasetFloatOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);

  for (float i = (float)0.5; i <= 100.00; i += 0.75) {
    byte[] bytes = new byte[5];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
    OrderedBytes.encodeFloat32(br, i,Order.ASCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}
项目:dremio-oss    文件:TestTableGenerator.java   
public static void generateHBaseDatasetBigIntOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);
  long startTime = (long)1438034423 * 1000;
  for (long i = startTime; i <= startTime + 100; i ++) {
    byte[] bytes = new byte[9];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
    OrderedBytes.encodeInt64(br, i, Order.ASCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}
项目:dremio-oss    文件:TestTableGenerator.java   
public static void generateHBaseDatasetIntOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);

  for (int i = -49; i <= 100; i ++) {
    byte[] bytes = new byte[5];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
    OrderedBytes.encodeInt32(br, i, Order.ASCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}
项目:dremio-oss    文件:TestTableGenerator.java   
public static void generateHBaseDatasetDoubleOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);

  for (double i = 0.5; i <= 100.00; i += 0.75) {
    byte[] bytes = new byte[9];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
    OrderedBytes.encodeFloat64(br, i, Order.DESCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}
项目:dremio-oss    文件:TestTableGenerator.java   
public static void generateHBaseDatasetFloatOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);

  for (float i = (float)0.5; i <= 100.00; i += 0.75) {
    byte[] bytes = new byte[5];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
    OrderedBytes.encodeFloat32(br, i, Order.DESCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}
项目:dremio-oss    文件:TestTableGenerator.java   
public static void generateHBaseDatasetBigIntOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);
  long startTime = (long)1438034423 * 1000;
  for (long i = startTime; i <= startTime + 100; i ++) {
    byte[] bytes = new byte[9];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
    OrderedBytes.encodeInt64(br, i, Order.DESCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}
项目:dremio-oss    文件:TestTableGenerator.java   
public static void generateHBaseDatasetIntOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);

  for (int i = -49; i <= 100; i ++) {
    byte[] bytes = new byte[5];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
    OrderedBytes.encodeInt32(br, i, Order.DESCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}