@Override public void batch(List<Row> writes, Object[] results) throws IOException, InterruptedException { table.batch(writes, results); table.flushCommits(); }
@Override public void batch(List<Row> writes, Object[] results) throws IOException, InterruptedException { table.batch(writes, results); table.flushCommits(); }
@Override public void batch(List<Row> writes, Object[] results) throws IOException, InterruptedException { table.batch(writes, results); table.flushCommits(); }
/** * Submits all queued Mutations. * @return The number of mutation submitted. */ public int mutate() { int mutationCount = mutations.size(); Object[] result = new Object[mutationCount]; try { table.batch(mutations, result); mutations.clear(); } catch (InterruptedException | IOException e) { LOG.warn("Error performing a mutation to HBase.", e); throw new RuntimeException(e); } return mutationCount; }
/** * Do the actual write to the primary table. We don't need to worry about closing the table * because that is handled the {@link CachingHTableFactory}. */ @Override public Boolean call() throws Exception { try { // this may have been queued, but there was an abort/stop so we try to early exit throwFailureIfDone(); if (LOG.isDebugEnabled()) { LOG.debug("Writing index update:" + mutations + " to table: " + tableReference); } HTableInterface table = factory.getTable(tableReference.get()); throwFailureIfDone(); table.batch(mutations); } catch (InterruptedException e) { // reset the interrupt status on the thread Thread.currentThread().interrupt(); throw e; } catch (Exception e) { throw e; } return Boolean.TRUE; }
/** * Do the actual write to the primary table. We don't need to worry about closing the table * because that is handled the {@link CachingHTableFactory}. */ @Override public Void call() throws Exception { // this may have been queued, so another task infront of us may have failed, so we should // early exit, if that's the case throwFailureIfDone(); if (LOG.isDebugEnabled()) { LOG.debug("Writing index update:" + mutations + " to table: " + tableReference); } try { HTableInterface table = factory.getTable(tableReference.get()); throwFailureIfDone(); table.batch(mutations); } catch (SingleIndexWriteFailureException e) { throw e; } catch (IOException e) { throw new SingleIndexWriteFailureException(tableReference.toString(), mutations, e); } catch (InterruptedException e) { // reset the interrupt status on the thread Thread.currentThread().interrupt(); throw new SingleIndexWriteFailureException(tableReference.toString(), mutations, e); } return null; }
SQLException sqlE = null; try { resultObjects= hTable.batch(incrementBatch); } catch (IOException e){ sqlE = ServerUtil.parseServerException(e);
SQLException sqlE = null; try { resultObjects= hTable.batch(mutations); } catch (IOException e){ sqlE = ServerUtil.parseServerException(e);
SQLException sqlE = null; try { hTable.batch(mutations); } catch (IOException e){ sqlE = ServerUtil.parseServerException(e);
private static void initTableValues() throws Exception { ConnectionQueryServices services = driver.getConnectionQueryServices(getUrl(), TEST_PROPERTIES); HTableInterface hTable = services.getTable(SchemaUtil.getTableNameAsBytes(HBASE_DYNAMIC_COLUMNS_SCHEMA_NAME,HBASE_DYNAMIC_COLUMNS)); try { // Insert rows using standard HBase mechanism with standard HBase "types" List<Row> mutations = new ArrayList<Row>(); byte[] dv = Bytes.toBytes("DV"); byte[] first = Bytes.toBytes("F"); byte[] f1v1 = Bytes.toBytes("F1V1"); byte[] f1v2 = Bytes.toBytes("F1V2"); byte[] f2v1 = Bytes.toBytes("F2V1"); byte[] f2v2 = Bytes.toBytes("F2V2"); byte[] key = Bytes.toBytes("entry1"); Put put = new Put(key); put.add(QueryConstants.EMPTY_COLUMN_BYTES, dv, Bytes.toBytes("default")); put.add(QueryConstants.EMPTY_COLUMN_BYTES, first, Bytes.toBytes("first")); put.add(FAMILY_NAME, f1v1, Bytes.toBytes("f1value1")); put.add(FAMILY_NAME, f1v2, Bytes.toBytes("f1value2")); put.add(FAMILY_NAME2, f2v1, Bytes.toBytes("f2value1")); put.add(FAMILY_NAME2, f2v2, Bytes.toBytes("f2value2")); mutations.add(put); hTable.batch(mutations); } finally { hTable.close(); } // Create Phoenix table after HBase table was created through the native APIs // The timestamp of the table creation must be later than the timestamp of the data ensureTableCreated(getUrl(), HBASE_DYNAMIC_COLUMNS); }
put.add(family, QueryConstants.EMPTY_COLUMN_BYTES, ts+6, ByteUtil.EMPTY_BYTE_ARRAY); mutations.add(put); hTable.batch(mutations);
mutations.add(put); hTable.batch(mutations);
if (logger.isDebugEnabled()) logMutationSize(hTable, mutations); long startTime = System.currentTimeMillis(); hTable.batch(mutations); shouldRetry = false; if (logger.isDebugEnabled()) logger.debug("Total time for batch call of " + mutations.size() + " mutations into " + table.getName().getString() + ": " + (System.currentTimeMillis() - startTime) + " ms");
Mockito.when(table.batch(Mockito.anyList())).thenAnswer(new Answer<Void>() {
mutations.add(put); hTable.batch(mutations);
Mockito.when(table.batch(Mockito.anyList())).thenAnswer(new Answer<Void>() {
Mockito.when(table.batch(Mockito.anyList())).thenAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable {
Mockito.when(table.batch(Mockito.anyList())).thenAnswer(new Answer<Void>() {
Mockito.when(table.batch(Mockito.anyList())).thenThrow( new IOException("Intentional IOException for failed first write.")); Mockito.when(table.getTableName()).thenReturn(tableName); HTableInterface table2 = Mockito.mock(HTableInterface.class); Mockito.when(table2.getTableName()).thenReturn(tableName2); Mockito.when(table2.batch(Mockito.anyList())).thenAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable {
@Override public Object[] batch(List<? extends Row> actions) throws IOException, InterruptedException { if (tx == null) { throw new IOException("Transaction not started"); } return hTable.batch(transactionalizeActions(actions)); }