use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseInvalidTimeFormat.
@Test(expected = ParseException.class)
public void testParseInvalidTimeFormat() throws ParseException {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.TIME).build();
FieldParser.parse("07_32_15", schema);
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseEmptyValueNullableMetadataLongType.
/**
* Tests a parse request with an empty value and a nullable
* {@link ColumnSchema} with a {@link ColumnType} not equal to
* {@link ColumnType#STRING} or {@link ColumnType#BINARY}
*
* @throws ParseException
*/
@Test
public void testParseEmptyValueNullableMetadataLongType() throws ParseException {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.LONG).build();
assertNull(FieldParser.parse(EMPTY_STRING, schema));
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseDecimal.
@Test
public void testParseDecimal() throws Exception {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.DECIMAL).setPrecision(5).setScale(2).build();
assertEquals(ByteBuffer.wrap(Arrays.copyOfRange(Bytes.toBytes(0x807B2DL), 5, 8)), FieldParser.parse("123.45", schema));
assertEquals(ByteBuffer.wrap(Arrays.copyOfRange(Bytes.toBytes(0x7F84D2L), 5, 8)), FieldParser.parse("-123.45", schema));
assertEquals(ByteBuffer.wrap(Arrays.copyOfRange(Bytes.toBytes(0x800000L), 5, 8)), FieldParser.parse("000.00", schema));
assertEquals(ByteBuffer.wrap(Arrays.copyOfRange(Bytes.toBytes(0x800000L), 5, 8)), FieldParser.parse("-000.00", schema));
assertEquals(ByteBuffer.wrap(Arrays.copyOfRange(Bytes.toBytes(0x83E763L), 5, 8)), FieldParser.parse("999.99", schema));
assertEquals(ByteBuffer.wrap(Arrays.copyOfRange(Bytes.toBytes(0x7C189CL), 5, 8)), FieldParser.parse("-999.99", schema));
schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.DECIMAL).setPrecision(10).setScale(3).build();
assertEquals(ByteBuffer.wrap(Arrays.copyOfRange(Bytes.toBytes(0x008012D687037AL), 2, 8)), FieldParser.parse("1234567.890", schema));
assertEquals(ByteBuffer.wrap(Arrays.copyOfRange(Bytes.toBytes(0x008000000501F4L), 2, 8)), FieldParser.parse("5.5", schema));
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseLong.
@Test
public void testParseLong() throws ParseException {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.LONG).build();
assertEquals(ByteBuffer.wrap(Longs.toByteArray(0x00L)), FieldParser.parse("0", schema));
assertEquals(ByteBuffer.wrap(Longs.toByteArray(0xFFFFFFFFFFFFFF85L)), FieldParser.parse("-123", schema));
assertEquals(ByteBuffer.wrap(Longs.toByteArray(0x7BL)), FieldParser.parse("123", schema));
assertEquals(ByteBuffer.wrap(Longs.toByteArray(0x7FFFFFFFFFFFFFFFL)), FieldParser.parse("9223372036854775807", schema));
assertEquals(ByteBuffer.wrap(Longs.toByteArray(0x8000000000000000L)), FieldParser.parse("-9223372036854775808", schema));
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class HBaseMetadata method putColumnIds.
private Put putColumnIds(long tableId, Collection<ColumnSchema> columns) {
long columnId = getNextColumnId(tableId, columns.size());
Put put = new Put(new ColumnsRowKey(tableId).encode());
for (ColumnSchema columnEntry : columns) {
put.add(columnFamily, serializeName(columnEntry.getColumnName()), serializeId(columnId--));
}
return put;
}
Aggregations