Search in sources :

Example 6 with Row

use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.

the class ITUtils method insertData.

/**
     * Inserts the number of specified rows with each row containing a column,
     * {@link TestConstants#COLUMN1}, with the value provided and another column,
     * {@link TestConstants#COLUMN2}, with an arbitrary value
     *
     * @param proxy          The proxy to use for invoking a scan, not null
     * @param rowCount       The valid number of rows expected to be returned from the scan
     * @param keyColumnValue The value stored in the first column, which is intended to be indexed
     * @param uuid           The unique identifier to associate with each row inserted, not null
     */
public static void insertData(final HandlerProxy proxy, final int rowCount, final long keyColumnValue, final UUID uuid) {
    checkNotNull(proxy);
    verifyRowCount(rowCount);
    checkNotNull(uuid);
    final Map<String, ByteBuffer> map = Maps.newHashMap();
    map.put(TestConstants.COLUMN1, encodeValue(keyColumnValue));
    for (int x = 0; x < rowCount; x++) {
        map.put(TestConstants.COLUMN2, encodeValue(x));
        final Row row = new Row(map, uuid);
        proxy.insertRow(row.serialize());
    }
    proxy.flush();
}
Also used : Row(com.nearinfinity.honeycomb.mysql.Row) ByteBuffer(java.nio.ByteBuffer)

Example 7 with Row

use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.

the class ITUtils method insertNullData.

/**
     * Inserts the number of specified rows with each row containing the provided
     * column name with an arbitrary value and random {@link UUID}.  The rows created
     * do not use columns used for indexing such as {@link TestConstants#COLUMN1} and
     * {@link TestConstants#COLUMN2}
     *
     * @param proxy      The proxy to use for invoking a scan, not null
     * @param rowCount   The valid number of rows expected to be returned from the scan
     * @param columnName The column name to associated with the inserted row, not null or empty
     */
public static void insertNullData(final HandlerProxy proxy, final int rowCount, final String columnName) {
    checkNotNull(proxy);
    verifyRowCount(rowCount);
    Verify.isNotNullOrEmpty(columnName);
    final Map<String, ByteBuffer> map = Maps.newHashMap();
    for (int x = 0; x < rowCount; x++) {
        map.put(columnName, encodeValue(x));
        final Row row = new Row(map, UUID.randomUUID());
        proxy.insertRow(row.serialize());
    }
    proxy.flush();
}
Also used : Row(com.nearinfinity.honeycomb.mysql.Row) ByteBuffer(java.nio.ByteBuffer)

Example 8 with Row

use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.

the class MySqlBugIT method testNullsAreNotDuplicatesInUniqueIndex.

/*
    drop table if exists t1;
    create table t1 (c1 int, unique(c1));
    insert into t1 values (null),(null);
    Expected: 2 insert
    Actual: Error duplicate entry
     */
@Test
public void testNullsAreNotDuplicatesInUniqueIndex() {
    ITUtils.insertNullData(proxy, 1);
    Map<String, ByteBuffer> values = Maps.newHashMap();
    values.put(TestConstants.COLUMN2, ITUtils.encodeValue(1));
    Row row = new Row(values, UUID.randomUUID());
    assertFalse(proxy.indexContainsDuplicate(TestConstants.INDEX3, row.serialize()));
}
Also used : Row(com.nearinfinity.honeycomb.mysql.Row) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 9 with Row

use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.

the class IndexOperationsIT method testDropIndex.

@Test(expected = NullPointerException.class)
public void testDropIndex() {
    final int keyValue = 7;
    final QueryKey key = ITUtils.createKey(keyValue, QueryType.EXACT_KEY);
    // Add data rows to index
    ITUtils.insertData(proxy, ROW_COUNT, keyValue);
    // Verify that we can get a row from the index scan
    proxy.startIndexScan(key.serialize());
    final Row row = Row.deserialize(proxy.getNextRow());
    byte[] result = proxy.getRow(Util.UUIDToBytes(row.getUUID()));
    assertNotNull(row);
    assertEquals(Row.deserialize(result).getUUID(), row.getUUID());
    proxy.endScan();
    // Drop the index from the table
    proxy.dropIndex(TestConstants.INDEX1);
    // Verify that the data row is still available after the index has been removed
    result = proxy.getRow(Util.UUIDToBytes(row.getUUID()));
    assertEquals(Row.deserialize(result).getUUID(), row.getUUID());
    // Verify that the scan is unable to execute
    proxy.startIndexScan(key.serialize());
}
Also used : QueryKey(com.nearinfinity.honeycomb.mysql.QueryKey) Row(com.nearinfinity.honeycomb.mysql.Row) HoneycombIntegrationTest(integrationtests.HoneycombIntegrationTest) Test(org.junit.Test)

Example 10 with Row

use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.

the class RowOperationsIT method testGetRow.

@Test
public void testGetRow() {
    ITUtils.insertData(proxy, ROW_COUNT, INDEX_COL_VALUE);
    final QueryKey key = ITUtils.createKey(INDEX_COL_VALUE, QueryType.EXACT_KEY);
    proxy.startIndexScan(key.serialize());
    final Row r = Row.deserialize(proxy.getNextRow());
    final byte[] result = proxy.getRow(Util.UUIDToBytes(r.getUUID()));
    assertNotNull(result);
    assertThat(Row.deserialize(result).getUUID(), equalTo(r.getUUID()));
}
Also used : QueryKey(com.nearinfinity.honeycomb.mysql.QueryKey) Row(com.nearinfinity.honeycomb.mysql.Row) HoneycombIntegrationTest(integrationtests.HoneycombIntegrationTest) Test(org.junit.Test)

Aggregations

Row (com.nearinfinity.honeycomb.mysql.Row)12 Test (org.junit.Test)9 ByteBuffer (java.nio.ByteBuffer)7 QueryKey (com.nearinfinity.honeycomb.mysql.QueryKey)6 HoneycombIntegrationTest (integrationtests.HoneycombIntegrationTest)5 HandlerProxy (com.nearinfinity.honeycomb.mysql.HandlerProxy)1 ColumnSchema (com.nearinfinity.honeycomb.mysql.schema.ColumnSchema)1 IndexSchema (com.nearinfinity.honeycomb.mysql.schema.IndexSchema)1 TableSchema (com.nearinfinity.honeycomb.mysql.schema.TableSchema)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Put (org.apache.hadoop.hbase.client.Put)1 ImmutableBytesWritable (org.apache.hadoop.hbase.io.ImmutableBytesWritable)1