private final CompletableFuture < ClientResponse > createAdHocTransaction ( final AdHocPlannedStmtBatch plannedStmtBatch , final boolean isSwapTables ) throws VoltTypeException { ByteBuffer buf = null ; try { buf = plannedStmtBatch . flattenPlanArrayToBuffer ( ) ; } catch ( IOException e ) { VoltDB . crashLocalVoltDB ( e . getMessage ( ) , true , e ) ; } assert ( buf . hasArray ( ) ) ; // create the execution site task String procedureName = null ; Object [ ] params = null ; // pick the sysproc based on the presence of partition info // HSQL (or PostgreSQL) does not specifically implement AdHoc SP // -- instead, use its always-SP implementation of AdHoc boolean isSinglePartition = plannedStmtBatch . isSinglePartitionCompatible ( ) || m_isConfiguredForNonVoltDBBackend ; if ( isSwapTables ) { procedureName = "@SwapTablesCore" ; params = new Object [ ] { buf . array ( ) } ; } else if ( isSinglePartition ) { if ( plannedStmtBatch . isReadOnly ( ) ) { procedureName = "@AdHoc_RO_SP" ; } else { procedureName = "@AdHoc_RW_SP" ; } int type = VoltType . NULL . getValue ( ) ; // replicated table read is single-part without a partitioning param // I copied this from below, but I'm not convinced that the above statement is correct // or that the null behavior here either (a) ever actually happens or (b) has the // desired intent. Object partitionParam = plannedStmtBatch . partitionParam ( ) ; byte [ ] param = null ; if ( partitionParam != null ) { type = VoltType . typeFromClass ( partitionParam . getClass ( ) ) . getValue ( ) ; param = VoltType . valueToBytes ( partitionParam ) ; } // Send the partitioning parameter and its type along so that the site can check if // it's mis-partitioned. Type is needed to re-hashinate for command log re-init. params = new Object [ ] { param , ( byte ) type , buf . array ( ) } ; } else { if ( plannedStmtBatch . isReadOnly ( ) ) { procedureName = "@AdHoc_RO_MP" ; } else { procedureName = "@AdHoc_RW_MP" ; } params = new Object [ ] { buf . array ( ) } ; } return callProcedure ( procedureName , params ) ; }
Take a set of adhoc plans and pass them off to the right transactional adhoc variant .