Search in sources :

Example 1 with CompiledDeleteStatement

use of org.apache.asterix.translator.CompiledStatements.CompiledDeleteStatement in project asterixdb by apache.

the class QueryTranslator method handleDeleteStatement.

public JobSpecification handleDeleteStatement(MetadataProvider metadataProvider, Statement stmt, IHyracksClientConnection hcc, boolean compileOnly) throws Exception {
    DeleteStatement stmtDelete = (DeleteStatement) stmt;
    String dataverseName = getActiveDataverse(stmtDelete.getDataverseName());
    MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
    boolean bActiveTxn = true;
    metadataProvider.setMetadataTxnContext(mdTxnCtx);
    MetadataLockManager.INSTANCE.insertDeleteUpsertBegin(metadataProvider.getLocks(), dataverseName + "." + stmtDelete.getDatasetName());
    try {
        metadataProvider.setWriteTransaction(true);
        CompiledDeleteStatement clfrqs = new CompiledDeleteStatement(stmtDelete.getVariableExpr(), dataverseName, stmtDelete.getDatasetName().getValue(), stmtDelete.getCondition(), stmtDelete.getVarCounter(), stmtDelete.getQuery());
        JobSpecification jobSpec = rewriteCompileQuery(hcc, metadataProvider, clfrqs.getQuery(), clfrqs);
        MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
        bActiveTxn = false;
        if (jobSpec != null && !compileOnly) {
            JobUtils.runJob(hcc, jobSpec, true);
        }
        return jobSpec;
    } catch (Exception e) {
        if (bActiveTxn) {
            abort(e, e, mdTxnCtx);
        }
        throw e;
    } finally {
        metadataProvider.getLocks().unlock();
    }
}
Also used : CompiledDeleteStatement(org.apache.asterix.translator.CompiledStatements.CompiledDeleteStatement) MetadataTransactionContext(org.apache.asterix.metadata.MetadataTransactionContext) JobSpecification(org.apache.hyracks.api.job.JobSpecification) CompiledDeleteStatement(org.apache.asterix.translator.CompiledStatements.CompiledDeleteStatement) DeleteStatement(org.apache.asterix.lang.common.statement.DeleteStatement) ACIDException(org.apache.asterix.common.exceptions.ACIDException) MetadataException(org.apache.asterix.metadata.MetadataException) AlgebricksException(org.apache.hyracks.algebricks.common.exceptions.AlgebricksException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) CompilationException(org.apache.asterix.common.exceptions.CompilationException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) AsterixException(org.apache.asterix.common.exceptions.AsterixException)

Aggregations

IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 ACIDException (org.apache.asterix.common.exceptions.ACIDException)1 AsterixException (org.apache.asterix.common.exceptions.AsterixException)1 CompilationException (org.apache.asterix.common.exceptions.CompilationException)1 DeleteStatement (org.apache.asterix.lang.common.statement.DeleteStatement)1 MetadataException (org.apache.asterix.metadata.MetadataException)1 MetadataTransactionContext (org.apache.asterix.metadata.MetadataTransactionContext)1 CompiledDeleteStatement (org.apache.asterix.translator.CompiledStatements.CompiledDeleteStatement)1 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1 JobSpecification (org.apache.hyracks.api.job.JobSpecification)1