@Override public void upsertDone(long upsertCount) { totalUpserts = upsertCount; if (upsertCount % upsertBatchSize == 0) { if (upsertCount % 1000 == 0) { LOG.info("Processed upsert #{}", upsertCount); } try { LOG.info("Committing after {} records", upsertCount); conn.commit(); } catch (SQLException e) { throw new RuntimeException(e); } } }
try { stmt.execute(); conn.commit(); } catch (SQLException e) { throw new IOException(e);
@Override public Void run() throws Exception { final RpcCall rpcContext = RpcUtil.getRpcContext(); // setting RPC context as null so that user can be reset try { RpcUtil.setRpcContext(null); stmt.execute(); conn.commit(); } catch (SQLException e) { throw new IOException(e); } finally { // setting RPC context back to original context of the RPC RpcUtil.setRpcContext(rpcContext); } return null; } });
/** * Move child links form SYSTEM.CATALOG to SYSTEM.CHILD_LINK * @param oldMetaConnection caller should take care of closing the passed connection appropriately * @throws SQLException */ public static void moveChildLinks(PhoenixConnection oldMetaConnection) throws SQLException { PhoenixConnection metaConnection = null; try { // Need to use own connection with max time stamp to be able to read all data from SYSTEM.CATALOG metaConnection = new PhoenixConnection(oldMetaConnection, HConstants.LATEST_TIMESTAMP); logger.info("Upgrading metadata to add parent to child links for views"); metaConnection.commit(); String createChildLink = "UPSERT INTO SYSTEM.CHILD_LINK(TENANT_ID, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, COLUMN_FAMILY, LINK_TYPE) " + "SELECT TENANT_ID, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, COLUMN_FAMILY, LINK_TYPE " + "FROM SYSTEM.CATALOG " + "WHERE LINK_TYPE = 4"; metaConnection.createStatement().execute(createChildLink); metaConnection.commit(); String deleteChildLink = "DELETE FROM SYSTEM.CATALOG WHERE LINK_TYPE = 4 "; metaConnection.createStatement().execute(deleteChildLink); metaConnection.commit(); metaConnection.getQueryServices().clearCache(); } finally { if (metaConnection != null) { metaConnection.close(); } } }
@Override public MutationState updateData(MutationPlan plan) throws SQLException { MutationState state = plan.execute(); plan.getContext().getConnection().commit(); return state; }
stmt.setInt(4, ResultSetMetaData.columnNullable); stmt.executeUpdate(); metaConnection.commit(); } catch (NewerTableAlreadyExistsException e) { logger.warn("Table already modified at this timestamp, so assuming column already nullable: " + columnName);
metaConnection.commit(); " WHERE LINK_TYPE = 3 )"; metaConnection.createStatement().execute(createChildLink); metaConnection.commit(); "WHERE LINK_TYPE = 3 "; metaConnection.createStatement().execute(createGrandChildLink); metaConnection.commit(); metaConnection.getQueryServices().clearCache(); } finally {
prepareStatement.setByte(5, LinkType.VIEW_INDEX_PARENT_TABLE.getSerializedValue()); prepareStatement.execute(); upsertConn.commit();
@Override public void run() { try { Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); int nRowsToUpsert = 1000; for (int i = 0; i < nRowsToUpsert; i++) { synchronized(lock) { PhoenixConnection conn = null; try { conn = DriverManager.getConnection(getUrl(), props).unwrap(PhoenixConnection.class); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES (" + (i % 10) + ", 0, 1)"); if ((i % 20) == 0 || i == nRowsToUpsert-1 ) { conn.commit(); } } finally { if (conn != null) conn.close(); } } } } catch (SQLException e) { throw new RuntimeException(e); } finally { doneSignal.countDown(); } }
private void forcefullyDropView(PhoenixConnection phoenixConnection, Key key) throws Exception { String deleteRowsFromCatalog = "DELETE FROM " + SYSTEM_CATALOG_NAME + " WHERE " + TENANT_ID + (key.getTenantId() == null ? " IS NULL" : " = '" + key.getTenantId() + "'") + " AND " + TABLE_SCHEM + (key.getSchemaName() == null ? " IS NULL " : " = '" + key.getSchemaName() + "'") + " AND " + TABLE_NAME + " = '" + key.getTableName() + "'"; String deleteRowsFromChildLink = "DELETE FROM " + SYSTEM_CHILD_LINK_NAME + " WHERE " + COLUMN_NAME + (key.getTenantId() == null ? " IS NULL" : " = '" + key.getTenantId() + "'") + " AND " + COLUMN_FAMILY + " = '" + (key.getSchemaName() == null ? key.getTableName() : key.getSchemaName() + "." + key.getTableName()) + "'"; try { phoenixConnection.createStatement().execute(deleteRowsFromCatalog); phoenixConnection.createStatement().execute(deleteRowsFromChildLink); phoenixConnection.commit(); } catch (SQLException e) { throw new IOException(e); } }
csvUpsertExecutor.close(); conn.commit(); double elapsedDuration = ((System.currentTimeMillis() - start) / 1000.0); System.out.println("CSV Upsert complete. " + upsertListener.getTotalUpsertCount()
private void removeLink(PhoenixConnection phoenixConnection, Key src, Key dst, PTable.LinkType linkType) throws Exception { String deleteQuery = "DELETE FROM " + ((linkType == PTable.LinkType.PHYSICAL_TABLE || linkType == PTable.LinkType.PARENT_TABLE) ? SYSTEM_CATALOG_NAME : SYSTEM_CHILD_LINK_NAME) + " WHERE " + TENANT_ID + (src.getTenantId() == null ? " IS NULL" : " = '" + src.getTenantId() + "'") + " AND " + TABLE_SCHEM + (src.getSchemaName() == null ? " IS NULL " : " = '" + src.getSchemaName() + "'") + " AND " + TABLE_NAME + " = '" + src.getTableName() + "' AND " + COLUMN_NAME + (dst.getTenantId() == null ? " IS NULL" : " = '" + dst.getTenantId() + "'") + " AND " + COLUMN_FAMILY + " = '" + (dst.getSchemaName() == null ? dst.getTableName() : dst.getSchemaName() + "." + dst.getTableName()) + "'"; phoenixConnection.createStatement().execute(deleteQuery); phoenixConnection.commit(); }
statement.execute("upsert into " + tableName + " values(" + i + ",'fn" + i + "','ln" + i + "')"); conn.commit(); ResultSet rs = statement.executeQuery("SELECT COUNT(*) FROM " + indexName); assertTrue(rs.next());
phxConn.createStatement().execute( "UPSERT INTO " + tableName + " VALUES ('PK1', 'PK2', 'KV1', 'KV2')" ); phxConn.commit(); try (ResultSet rs = phxConn.createStatement().executeQuery("SELECT * FROM " + tableName)) { assertTrue(rs.next());
conn.commit();
conn.commit();
conn.commit(); assertEquals("Mutation state size should be zero after commit", 0, state.getEstimatedSize());
newConn.commit();
ps.execute(); pconn.commit(); String query = "SELECT count(1) FROM " + tableName; ResultSet rs = pconn.createStatement().executeQuery(query);