Search in sources :

Example 1 with ColumnSchema

use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.

the class MySqlBugIT method getTableSchema.

/**
     * Provides the {@link com.nearinfinity.honeycomb.mysql.schema.TableSchema} to use for a test case
     *
     * @return The schema used for testing
     */
@Override
protected TableSchema getTableSchema() {
    final List<ColumnSchema> columns = Lists.newArrayList();
    final List<IndexSchema> indices = Lists.newArrayList();
    // Add nullable, non-autoincrementing columns
    columns.add(ColumnSchema.builder(TestConstants.COLUMN1, ColumnType.LONG).build());
    columns.add(ColumnSchema.builder(TestConstants.COLUMN2, ColumnType.LONG).build());
    // Add non-unique index on one column
    indices.add(new IndexSchema(TestConstants.INDEX1, Lists.newArrayList(TestConstants.COLUMN1), false));
    // Add non-unique compound index on (c1, c2)
    indices.add(new IndexSchema(TestConstants.INDEX2, Lists.newArrayList(TestConstants.COLUMN1, TestConstants.COLUMN2), false));
    // Add unique index on one column
    indices.add(new IndexSchema(TestConstants.INDEX3, Lists.newArrayList(TestConstants.COLUMN1), true));
    return new TableSchema(columns, indices);
}
Also used : TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema) ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) IndexSchema(com.nearinfinity.honeycomb.mysql.schema.IndexSchema)

Example 2 with ColumnSchema

use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.

the class HBaseMetadataTest method testLookupTableSchemaValidTableId.

@Test
public void testLookupTableSchemaValidTableId() {
    final TableSchema tableSchema = new TableSchema(COLUMN_SCHEMAS, ImmutableList.<IndexSchema>of());
    hbaseMetadata.createTable(TABLE_NAME, tableSchema);
    final long tableId = hbaseMetadata.getTableId(TABLE_NAME);
    final TableSchema schemaTwo = hbaseMetadata.getSchema(tableId);
    assertEquals(1, schemaTwo.getColumns().size());
    assertTrue(Iterables.any(schemaTwo.getColumns(), new Predicate<ColumnSchema>() {

        @Override
        public boolean apply(ColumnSchema input) {
            return input.getColumnName().equals(COLUMN_NAME);
        }
    }));
}
Also used : TableSchema(com.nearinfinity.honeycomb.mysql.schema.TableSchema) ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) Predicate(com.google.common.base.Predicate) Test(org.junit.Test)

Example 3 with ColumnSchema

use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.

the class FieldParserTest method testParseValidDateFormats.

@Test
public void testParseValidDateFormats() throws ParseException {
    ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.DATE).build();
    final String expectedParsedDate = "1989-05-13";
    final List<String> formats = ImmutableList.of(expectedParsedDate, "1989.05.13", "1989/05/13", "19890513");
    for (final String format : formats) {
        assertEquals(ByteBuffer.wrap(expectedParsedDate.getBytes()), FieldParser.parse(format, schema));
    }
}
Also used : ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) Test(org.junit.Test)

Example 4 with ColumnSchema

use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.

the class FieldParserTest method testParseInvalidDateFormat.

@Test(expected = ParseException.class)
public void testParseInvalidDateFormat() throws ParseException {
    ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.DATE).build();
    FieldParser.parse("1989_05_13", schema);
}
Also used : ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) Test(org.junit.Test)

Example 5 with ColumnSchema

use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.

the class FieldParserTest method testParseInvalidDateTimeFormat.

@Test(expected = ParseException.class)
public void testParseInvalidDateTimeFormat() throws ParseException {
    ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.DATETIME).build();
    FieldParser.parse("1989_05_13_07_32_15", schema);
}
Also used : ColumnSchema(com.nearinfinity.honeycomb.mysql.schema.ColumnSchema) Test(org.junit.Test)

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