Search in sources :

Example 16 with ColumnSchema

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);
}
Also used : ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) Test(org.junit.Test)

Example 17 with ColumnSchema

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));
}
Also used : ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) Test(org.junit.Test)

Example 18 with ColumnSchema

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));
}
Also used : ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) Test(org.junit.Test)

Example 19 with ColumnSchema

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));
}
Also used : ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) Test(org.junit.Test)

Example 20 with ColumnSchema

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;
}
Also used : ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema)

Aggregations

ColumnSchema (com.nearinfinity.honeycomb.mysql.schema.ColumnSchema)28 Test (org.junit.Test)22 TableSchema (com.nearinfinity.honeycomb.mysql.schema.TableSchema)9 IndexSchema (com.nearinfinity.honeycomb.mysql.schema.IndexSchema)5 Predicate (com.google.common.base.Predicate)1 ImmutableList (com.google.common.collect.ImmutableList)1 UnsignedBytes (com.google.common.primitives.UnsignedBytes)1 RowKey (com.nearinfinity.honeycomb.hbase.rowkey.RowKey)1 HandlerProxy (com.nearinfinity.honeycomb.mysql.HandlerProxy)1 Row (com.nearinfinity.honeycomb.mysql.Row)1 ColumnType (com.nearinfinity.honeycomb.mysql.gen.ColumnType)1 HoneycombIntegrationTest (integrationtests.HoneycombIntegrationTest)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 HTableInterface (org.apache.hadoop.hbase.client.HTableInterface)1 Bytes (org.apache.hadoop.hbase.util.Bytes)1