use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.
the class BulkLoadMapper method map.
@Override
public void map(LongWritable offset, Text line, Context context) {
try {
Row row = rowParser.parseRow(line.toString());
List<Put> puts = mutationFactory.insert(tableId, row);
for (Put put : puts) {
context.write(new ImmutableBytesWritable(put.getRow()), put);
}
context.getCounter(Counters.ROWS).increment(1);
context.getCounter(Counters.PUTS).increment(puts.size());
} catch (IOException e) {
LOG.error("CSVParser unable to parse line: " + line.toString(), e);
context.getCounter(Counters.FAILED_ROWS).increment(1);
} catch (IllegalArgumentException e) {
LOG.error(format("The line %s was incorrectly formatted. Error %s", line.toString(), e.getMessage()));
context.getCounter(Counters.FAILED_ROWS).increment(1);
} catch (ParseException e) {
LOG.error(format("Parsing failed on line %s with message %s", line.toString(), e.getMessage()));
context.getCounter(Counters.FAILED_ROWS).increment(1);
} catch (Exception e) {
LOG.error(format("The following error %s occurred during mapping" + " for line %s", e.getMessage(), line.toString()));
context.getCounter(Counters.FAILED_ROWS).increment(1);
}
}
use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.
the class MySqlBugIT method testRowInsertNotExcludingFieldsFromIndexKey.
/*
create table t1 (c1 int, c2 int, unique(c1,c2));
insert into t1 values (1,1),(1,1);
Expected failure
*/
@Test
public void testRowInsertNotExcludingFieldsFromIndexKey() {
ITUtils.insertData(proxy, 1, 1);
Row row = ITUtils.createRow(1);
assertTrue(proxy.indexContainsDuplicate(TestConstants.INDEX1, row.serialize()));
}
use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.
the class MySqlBugIT method testInsertBuildsIndexCorrectlyOnNullColumns.
/*
DROP TABLE if exists t1;
CREATE TABLE t1(c1 BIGINT SIGNED NULL,c2 BIGINT SIGNED NULL , INDEX(c1, c2));
INSERT INTO t1 VALUES
(4611686018427387903, NULL),
(4611686018427387903, NULL);
SELECT * FROM t1 WHERE c1 = 4611686018427387903 AND c2 is null ORDER BY c1 ASC;
Expected two rows
Actual was zero rows
*/
@Test
public void testInsertBuildsIndexCorrectlyOnNullColumns() {
final Map<String, ByteBuffer> map = Maps.newHashMap();
map.put(TestConstants.COLUMN1, ITUtils.encodeValue(INDEX_COL_VALUE));
final Row row = new Row(map, UUID.randomUUID());
proxy.insertRow(row.serialize());
proxy.flush();
HashMap<String, ByteBuffer> keys = Maps.newHashMap();
keys.put(TestConstants.COLUMN1, ITUtils.encodeValue(INDEX_COL_VALUE));
keys.put(TestConstants.COLUMN2, null);
final QueryKey key = new QueryKey(TestConstants.INDEX2, QueryType.EXACT_KEY, keys);
ITUtils.assertReceivingDifferentRows(proxy, key, ROW_COUNT);
}
use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.
the class MySqlBugIT method testUpdateNotChangingIndicesWhenUpdatedColumnNotInIndex.
/*
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(c1 INT, c2 INT, INDEX(c1));
INSERT INTO t1 VALUES(NULL, 1);
UPDATE t1 SET c2=2 WHERE c1 IS NULL;
Index scan: Null, 1
Table scan: Null, 2
*/
@Test
public void testUpdateNotChangingIndicesWhenUpdatedColumnNotInIndex() {
Map<String, ByteBuffer> values = Maps.newHashMap();
values.put(TestConstants.COLUMN2, ITUtils.encodeValue(1));
Row row = new Row(values, UUID.randomUUID());
proxy.insertRow(row.serialize());
proxy.flush();
proxy.startTableScan();
byte[] nextRow = proxy.getNextRow();
row = Row.deserialize(nextRow);
proxy.endScan();
// update t1 set c2=2 where c1 is null
row.getRecords().put(TestConstants.COLUMN2, ITUtils.encodeValue(2));
proxy.updateRow(nextRow, row.serialize());
Map<String, ByteBuffer> searchMap = Maps.newHashMap();
searchMap.put(TestConstants.COLUMN1, null);
QueryKey key = new QueryKey(TestConstants.INDEX1, QueryType.EXACT_KEY, searchMap);
proxy.startIndexScan(key.serialize());
Row result = Row.deserialize(proxy.getNextRow());
assertEquals(result.getRecords().get(TestConstants.COLUMN2).getLong(), ITUtils.encodeValue(2).getLong());
proxy.endScan();
}
use of com.nearinfinity.honeycomb.mysql.Row in project honeycomb by altamiracorp.
the class RowOperationsIT method testUpdateRow.
@Test
public void testUpdateRow() {
final Map<String, ByteBuffer> map = Maps.newHashMap();
map.put(TestConstants.COLUMN1, ITUtils.encodeValue(INDEX_COL_VALUE));
map.put(TestConstants.COLUMN2, ITUtils.encodeValue(6));
final Row row = new Row(map, UUID.randomUUID());
proxy.insertRow(row.serialize());
proxy.flush();
final QueryKey key = ITUtils.createKey(INDEX_COL_VALUE, QueryType.EXACT_KEY);
proxy.startIndexScan(key.serialize());
final Row r = Row.deserialize(proxy.getNextRow());
map.put(TestConstants.COLUMN1, ITUtils.encodeValue(3));
final Row newRow = new Row(map, r.getUUID());
proxy.updateRow(r.serialize(), newRow.serialize());
proxy.flush();
final byte[] result = proxy.getRow(Util.UUIDToBytes(r.getUUID()));
assertThat(Row.deserialize(result), equalTo(newRow));
}
Aggregations