public int getDefaultSelectedMethodIndex() { for ( int i = 0; i < codes.length; i++ ) { if ( codes[ i ].equals( stepMeta.getStepPartitioningMeta().getMethod() ) ) { return i; } } return 0; }
public void updateMethod( String method ) throws KettlePluginException { stepMeta.getStepPartitioningMeta().setMethod( method ); }
public void updateMethodType( int methodType ) { stepMeta.getStepPartitioningMeta().setMethodType( methodType ); }
public void updateSchema( PartitionSchema schema ) { if ( schema != null && schema.getName() != null ) { stepMeta.getStepPartitioningMeta().setPartitionSchema( schema ); } }
public void rollback( StepMeta before ) throws KettlePluginException { updateMethod( before.getStepPartitioningMeta().getMethod() ); updateMethodType( before.getStepPartitioningMeta().getMethodType() ); updateSchema( before.getStepPartitioningMeta().getPartitionSchema() ); }
/** * Checks whether or not the steps have changed. * * @return true if the steps have been changed, false otherwise */ public boolean haveStepsChanged() { if ( changed_steps ) { return true; } for ( int i = 0; i < nrSteps(); i++ ) { StepMeta stepMeta = getStep( i ); if ( stepMeta.hasChanged() ) { return true; } if ( stepMeta.getStepPartitioningMeta() != null && stepMeta.getStepPartitioningMeta().hasChanged() ) { return true; } } return false; }
public int getDefaultSelectedSchemaIndex() { List<String> schemaNames; try { schemaNames = schemasProvider.getPartitionSchemasNames( transMeta ); } catch ( KettleException e ) { schemaNames = Collections.emptyList(); } PartitionSchema partitioningSchema = stepMeta.getStepPartitioningMeta().getPartitionSchema(); int defaultSelectedSchemaIndex = 0; if ( partitioningSchema != null && partitioningSchema.getName() != null && !schemaNames.isEmpty() ) { defaultSelectedSchemaIndex = Const.indexOfString( partitioningSchema.getName(), schemaNames ); } return defaultSelectedSchemaIndex != -1 ? defaultSelectedSchemaIndex : 0; }
/** * Get the number of copies to start of a step. This takes into account the partitioning logic. * * @return the number of step copies to start. */ public int getCopies() { // If the step is partitioned, that's going to determine the number of copies, nothing else... // if ( isPartitioned() && getStepPartitioningMeta().getPartitionSchema() != null ) { List<String> partitionIDs = getStepPartitioningMeta().getPartitionSchema().getPartitionIDs(); if ( partitionIDs != null && partitionIDs.size() > 0 ) { // these are the partitions the step can "reach" return partitionIDs.size(); } } if ( copiesCache != null ) { return copiesCache.intValue(); } if ( parentTransMeta != null ) { // Return -1 to indicate that the variable or string value couldn't be converted to number // copiesCache = Const.toInt( parentTransMeta.environmentSubstitute( copiesString ), -1 ); } else { copiesCache = Const.toInt( copiesString, 1 ); } return copiesCache; }
StepPartitioningMeta partitioningMeta = stepMeta.getStepPartitioningMeta(); if ( partitioningMeta != null && partitioningMeta.getMethodType() != StepPartitioningMeta.PARTITIONING_METHOD_NONE
/** * Checks if the transformation is using the specified partition schema. * * @param partitionSchema * the partition schema * @return true if the transformation is using the partition schema, false otherwise */ public boolean isUsingPartitionSchema( PartitionSchema partitionSchema ) { // Loop over all steps and see if the partition schema is used. for ( int i = 0; i < nrSteps(); i++ ) { StepPartitioningMeta stepPartitioningMeta = getStep( i ).getStepPartitioningMeta(); if ( stepPartitioningMeta != null ) { PartitionSchema check = stepPartitioningMeta.getPartitionSchema(); if ( check != null && check.equals( partitionSchema ) ) { return true; } } } return false; }
/** * Clears the different changed flags of the transformation. * */ @Override public void clearChanged() { changed_steps = false; changed_hops = false; for ( int i = 0; i < nrSteps(); i++ ) { getStep( i ).setChanged( false ); if ( getStep( i ).getStepPartitioningMeta() != null ) { getStep( i ).getStepPartitioningMeta().hasChanged( false ); } } for ( int i = 0; i < nrTransHops(); i++ ) { getTransHop( i ).setChanged( false ); } for ( int i = 0; i < partitionSchemas.size(); i++ ) { partitionSchemas.get( i ).setChanged( false ); } for ( int i = 0; i < clusterSchemas.size(); i++ ) { clusterSchemas.get( i ).setChanged( false ); } super.clearChanged(); }
StepPartitioningMeta stepPartitioningMeta = stepMeta.getStepPartitioningMeta();
StepPartitioningMeta stepPartitioningMeta = step.getStepPartitioningMeta(); PartitionSchema partitionSchema = stepPartitioningMeta.getPartitionSchema();
private void askForField( PartitionSettings settings, SpoonDelegates delegates ) throws KettleException { StepDialogInterface partitionDialog = delegates.steps.getPartitionerDialog( settings.getStepMeta(), settings.getStepMeta().getStepPartitioningMeta(), settings.getTransMeta() ); String fieldName = partitionDialog.open(); if ( StringUtil.isEmpty( fieldName ) ) { settings.rollback( settings.getBefore() ); } }
when( mockHelper.trans.isRunning() ).thenReturn( true ); when( mockHelper.transMeta.findNextSteps( any( StepMeta.class ) ) ).thenReturn( stepMetas ); when( mockHelper.stepMeta.getStepPartitioningMeta() ).thenReturn( stepPartitioningMeta ); when( stepPartitioningMeta.getPartitioner() ).thenReturn( partitioner ); when( partitioner.getNrPartitions() ).thenReturn( 2 );
/** * Create a copy of a step from the original transformation for use in the a slave transformation. If the step is * partitioned, the partitioning will be changed to "schemaName (slave)" * * @param stepMeta * The step to copy / clone. * @return a copy of the specified step for use in a slave transformation. */ private StepMeta addSlaveCopy( TransMeta transMeta, StepMeta stepMeta, SlaveServer slaveServer ) { StepMeta copy = (StepMeta) stepMeta.clone(); if ( copy.isPartitioned() ) { StepPartitioningMeta stepPartitioningMeta = copy.getStepPartitioningMeta(); PartitionSchema partitionSchema = stepPartitioningMeta.getPartitionSchema(); String slavePartitionSchemaName = createSlavePartitionSchemaName( partitionSchema.getName() ); PartitionSchema slaveSchema = transMeta.findPartitionSchema( slavePartitionSchemaName ); if ( slaveSchema != null ) { stepPartitioningMeta.setPartitionSchema( slaveSchema ); } // Always just start a single copy on the slave server... // Otherwise the confusion w.r.t. to partitioning & re-partitioning would be complete. // copy.setCopies( 1 ); } // Remove the clustering information on the slave transformation step // We don't need it anymore, it only confuses. // copy.setClusterSchema( null ); transMeta.addStep( copy ); return copy; }
nextStepPartitioningMeta = nextSteps.get( 0 ).getStepPartitioningMeta();
stepMeta.getStepPartitioningMeta(), transformationId, stepMeta.getObjectId() );
stepMeta.getStepPartitioningMeta().setPartitionSchemaAfterLoading( partitionSchemas );
StepPartitioningMeta partitioningMeta = step.getStepPartitioningMeta(); if ( partitioningMeta != null && partitioningMeta.getPartitionSchema() != null && partitioningMeta.isPartitioned() ) {