@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("close")) { //$NON-NLS-1$ for (BlobHandler cleanup : toCleanup) { try { cleanup.freeTemporary(); } catch (Exception e) { SqlLoggers.LOGGER.error("failed to free temp blob", e); //$NON-NLS-1$ } } } try { return method.invoke(ps, args); } catch (InvocationTargetException e) { throw e.getCause(); } } }
private ArrayHandler rowsToOracleArray(Iterable<byte[]> rows) { List<Object[]> oraRows = Lists.newArrayListWithCapacity(Iterables.size(rows)); for (byte[] row : rows) { oraRows.add(new Object[] { row, null, null }); } return config.jdbcHandler().createStructArray( structArrayPrefix() + "CELL_TS", "" + structArrayPrefix() + "CELL_TS_TABLE", oraRows); }
private void setOracleStructArray(Connection c, PreparedStatement ps, int paramIndex, ArrayHandler array) { Preconditions.checkArgument(DBType.getTypeFromConnection(c) == DBType.ORACLE); try { PreparedStatements.setObject(ps, paramIndex, array.toOracleArray(c)); } catch (SQLException e) { throw BasicSQL.handleInterruptions(0, e); } }
BlobHandler blobHandler; try { blobHandler = getJdbcHandler().createBlob(c); } catch (SQLException e){ sqlExceptionlog.debug("Caught SQLException", e); //$NON-NLS-1$ os = blobHandler.setBinaryStream(0); PTStreams.copy(is, os); os.close(); ps.setBlob(i, blobHandler.getBlob()); } catch (Exception e) { try { blobHandler.freeTemporary(); } catch (Exception e1) { SqlLoggers.LOGGER.error("failed to free temp blob", e1); //$NON-NLS-1$
BlobHandler blobHandler; try { blobHandler = getJdbcHandler().createBlob(c); } catch (SQLException e){ sqlExceptionlog.debug("Caught SQLException", e); //$NON-NLS-1$ os = blobHandler.setBinaryStream(0); PTStreams.copy(is, os); os.close(); ps.setBlob(i, blobHandler.getBlob()); } catch (Exception e) { try { blobHandler.freeTemporary(); } catch (Exception e1) { SqlLoggers.LOGGER.error("failed to free temp blob", e1); //$NON-NLS-1$
private ArrayHandler rowsAndTimestampsToOracleArray(Collection<Map.Entry<byte[], Long>> rows) { List<Object[]> oraRows = Lists.newArrayListWithCapacity(rows.size()); for (Entry<byte[], Long> entry : rows) { oraRows.add(new Object[] { entry.getKey(), null, entry.getValue() }); } return config.jdbcHandler().createStructArray( structArrayPrefix() + "CELL_TS", "" + structArrayPrefix() + "CELL_TS_TABLE", oraRows); }
/** Encapsulates the logic for creating a prepared statement with the arguments set*/ private PreparedStatement createPreparedStatement(Connection c, String sql, Object[] vs) throws PalantirSqlException { PreparedStatement ps; ps = Connections.prepareStatement(c, sql); List<BlobHandler> toClean = Lists.newArrayList(); if (vs != null) { try { for (int i=0; i < vs.length; i++) { BlobHandler cleanup = setObject(c, ps, i+1, vs[i]); if (cleanup != null) { toClean.add(cleanup); } } } catch (Exception e) { // if we throw, we need to clean up any blobs we have already made for (BlobHandler cleanupBlob : toClean) { try { cleanupBlob.freeTemporary(); } catch (Exception e1) { SqlLoggers.LOGGER.error("failed to free temp blob", e1); //$NON-NLS-1$ } } BasicSQLUtils.throwUncheckedIfSQLException(e); throw Throwables.throwUncheckedException(e); } } return BlobCleanupPreparedStatement.create(ps, toClean); }
private void setOracleStructArray(Connection c, PreparedStatement ps, int paramIndex, ArrayHandler array) { Preconditions.checkArgument(DBType.getTypeFromConnection(c) == DBType.ORACLE); try { PreparedStatements.setObject(ps, paramIndex, array.toOracleArray(c)); } catch (SQLException e) { throw BasicSQL.handleInterruptions(0, e); } }
private ArrayHandler cellsAndTimestampsToOracleArray(Collection<Map.Entry<Cell, Long>> cells) { List<Object[]> oraRows = Lists.newArrayListWithCapacity(cells.size()); for (Entry<Cell, Long> entry : cells) { Cell cell = entry.getKey(); oraRows.add(new Object[] { cell.getRowName(), cell.getColumnName(), entry.getValue() }); } return config.jdbcHandler().createStructArray( structArrayPrefix() + "CELL_TS", "" + structArrayPrefix() + "CELL_TS_TABLE", oraRows); }
for (BlobHandler cleanup : cleanups) { try { cleanup.freeTemporary(); } catch (Exception e) { SqlLoggers.LOGGER.error("failed to free temp blob", e); //$NON-NLS-1$
private ArrayHandler cellsToOracleArray(Iterable<Cell> cells) { List<Object[]> oraRows = Lists.newArrayListWithCapacity(Iterables.size(cells)); for (Cell cell : cells) { oraRows.add(new Object[] { cell.getRowName(), cell.getColumnName(), null }); } return config.jdbcHandler().createStructArray( structArrayPrefix() + "CELL_TS", "" + structArrayPrefix() + "CELL_TS_TABLE", oraRows); }
for (BlobHandler cleanup : cleanups) { try { cleanup.freeTemporary(); } catch (Exception e) { SqlLoggers.LOGGER.error("failed to free temp blob", e); //$NON-NLS-1$
private List<FullQuery> getOverflowQueries(ConnectionSupplier conns, TableReference tableRef, Collection<Long> overflowIds) { List<Object[]> oraRows = Lists.newArrayListWithCapacity(overflowIds.size()); for (Long overflowId : overflowIds) { oraRows.add(new Object[] { null, null, overflowId }); } ArrayHandler arg = config.jdbcHandler().createStructArray( structArrayPrefix() + "CELL_TS", structArrayPrefix() + "CELL_TS_TABLE", oraRows); switch (config.overflowMigrationState()) { case UNSTARTED: return ImmutableList.of(getOldOverflowQuery(arg)); case IN_PROGRESS: return ImmutableList.of(getOldOverflowQuery(arg), getNewOverflowQuery(conns, tableRef, arg)); case FINISHING: case FINISHED: return ImmutableList.of(getNewOverflowQuery(conns, tableRef, arg)); default: throw new EnumConstantNotPresentException( OverflowMigrationState.class, config.overflowMigrationState().name()); } }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("close")) { //$NON-NLS-1$ for (BlobHandler cleanup : toCleanup) { try { cleanup.freeTemporary(); } catch (Exception e) { SqlLoggers.LOGGER.error("failed to free temp blob", e); //$NON-NLS-1$ } } } try { return method.invoke(ps, args); } catch (InvocationTargetException e) { throw e.getCause(); } } }
private ArrayHandler rowsToOracleArray(Iterable<byte[]> rows) { List<Object[]> oraRows = Lists.newArrayListWithCapacity(Iterables.size(rows)); for (byte[] row : rows) { oraRows.add(new Object[] { row, null, null }); } return config.jdbcHandler().createStructArray( structArrayPrefix() + "CELL_TS", "" + structArrayPrefix() + "CELL_TS_TABLE", oraRows); }
/** Encapsulates the logic for creating a prepared statement with the arguments set*/ private PreparedStatement createPreparedStatement(Connection c, String sql, Object[] vs) throws PalantirSqlException { PreparedStatement ps; ps = Connections.prepareStatement(c, sql); List<BlobHandler> toClean = Lists.newArrayList(); if (vs != null) { try { for (int i=0; i < vs.length; i++) { BlobHandler cleanup = setObject(c, ps, i+1, vs[i]); if (cleanup != null) { toClean.add(cleanup); } } } catch (Exception e) { // if we throw, we need to clean up any blobs we have already made for (BlobHandler cleanupBlob : toClean) { try { cleanupBlob.freeTemporary(); } catch (Exception e1) { SqlLoggers.LOGGER.error("failed to free temp blob", e1); //$NON-NLS-1$ } } BasicSQLUtils.throwUncheckedIfSQLException(e); throw Throwables.throwUncheckedException(e); } } return BlobCleanupPreparedStatement.create(ps, toClean); }
private ArrayHandler rowsAndTimestampsToOracleArray(Collection<Map.Entry<byte[], Long>> rows) { List<Object[]> oraRows = Lists.newArrayListWithCapacity(rows.size()); for (Entry<byte[], Long> entry : rows) { oraRows.add(new Object[] { entry.getKey(), null, entry.getValue() }); } return config.jdbcHandler().createStructArray( structArrayPrefix() + "CELL_TS", "" + structArrayPrefix() + "CELL_TS_TABLE", oraRows); }
private ArrayHandler cellsAndTimestampsToOracleArray(Collection<Map.Entry<Cell, Long>> cells) { List<Object[]> oraRows = Lists.newArrayListWithCapacity(cells.size()); for (Entry<Cell, Long> entry : cells) { Cell cell = entry.getKey(); oraRows.add(new Object[] { cell.getRowName(), cell.getColumnName(), entry.getValue() }); } return config.jdbcHandler().createStructArray( structArrayPrefix() + "CELL_TS", "" + structArrayPrefix() + "CELL_TS_TABLE", oraRows); }
private ArrayHandler cellsToOracleArray(Iterable<Cell> cells) { List<Object[]> oraRows = Lists.newArrayListWithCapacity(Iterables.size(cells)); for (Cell cell : cells) { oraRows.add(new Object[] { cell.getRowName(), cell.getColumnName(), null }); } return config.jdbcHandler().createStructArray( structArrayPrefix() + "CELL_TS", "" + structArrayPrefix() + "CELL_TS_TABLE", oraRows); }
private List<FullQuery> getOverflowQueries(ConnectionSupplier conns, TableReference tableRef, Collection<Long> overflowIds) { List<Object[]> oraRows = Lists.newArrayListWithCapacity(overflowIds.size()); for (Long overflowId : overflowIds) { oraRows.add(new Object[] { null, null, overflowId }); } ArrayHandler arg = config.jdbcHandler().createStructArray( structArrayPrefix() + "CELL_TS", structArrayPrefix() + "CELL_TS_TABLE", oraRows); switch (config.overflowMigrationState()) { case UNSTARTED: return ImmutableList.of(getOldOverflowQuery(arg)); case IN_PROGRESS: return ImmutableList.of(getOldOverflowQuery(arg), getNewOverflowQuery(conns, tableRef, arg)); case FINISHING: case FINISHED: return ImmutableList.of(getNewOverflowQuery(conns, tableRef, arg)); default: throw new EnumConstantNotPresentException( OverflowMigrationState.class, config.overflowMigrationState().name()); } }