public static String[] getAllOperators() { return new String[] { ColumnFilter.ComparisonType.EQUAL.toString(), ColumnFilter.ComparisonType.NOT_EQUAL.toString(), ColumnFilter.ComparisonType.GREATER_THAN.toString(), ColumnFilter.ComparisonType.GREATER_THAN_OR_EQUAL.toString(), ColumnFilter.ComparisonType.LESS_THAN.toString(), ColumnFilter.ComparisonType.LESS_THAN_OR_EQUAL.toString(), ColumnFilter.ComparisonType.SUBSTRING.toString(), ColumnFilter.ComparisonType.PREFIX.toString(), ColumnFilter.ComparisonType.REGEX.toString() }; }
@Override public ColumnFilter.ComparisonType string2enum( Class<?> enumClass, String value ) throws KettleValueException { return ColumnFilter.ComparisonType.stringToOpp( value ); } }
public String getFieldString() { return field.toString(); }
@Override public void addColumnFilterToScan( ColumnFilter cf, HBaseValueMetaInterface columnMeta, final VariableSpace vars, final boolean matchAny ) throws IOException { final org.pentaho.hbase.shim.api.ColumnFilter columnFilter = new org.pentaho.hbase.shim.api.ColumnFilter( cf.getFieldAlias() ); columnFilter.setFormat( cf.getFormat() ); columnFilter.setConstant( cf.getConstant() ); columnFilter.setSignedComparison( cf.getSignedComparison() ); columnFilter.setFieldType( cf.getFieldType() ); columnFilter.setComparisonOperator( org.pentaho.hbase.shim.api.ColumnFilter.ComparisonType.valueOf( cf.getComparisonOperator().name() ) ); final HBaseValueMetaInterfaceImpl hBaseValueMetaInterface = hBaseValueMetaInterfaceFactory.copy( columnMeta ); batchHBaseConnectionOperation.addOperation( new HBaseConnectionOperation() { @Override public void perform( HBaseConnectionWrapper hBaseConnectionWrapper ) throws IOException { try { hBaseConnectionWrapper .addColumnFilterToScan( columnFilter, hBaseValueMetaInterface, vars, matchAny ); } catch ( Exception e ) { throw new IOException( e ); } } } ); }
static List<ColumnFilter> createColumnFiltersFromDefinition( List<FilterDefinition> filtersDefinition, ColumnFilterFactory columnFilterFactory ) { List<ColumnFilter> filters = new ArrayList<>(); for ( FilterDefinition filterDefinition : filtersDefinition ) { ColumnFilter columnFilter = columnFilterFactory.createFilter( filterDefinition.getAlias() ); columnFilter.setFieldType( filterDefinition.getFieldType() ); columnFilter.setComparisonOperator( filterDefinition.getComparisonType() ); columnFilter.setConstant( filterDefinition.getConstant() ); columnFilter.setSignedComparison( filterDefinition.isSignedComparison() ); columnFilter.setFormat( filterDefinition.getFormat() ); filters.add( columnFilter ); } return filters; }
Mapping testMapping = mappingFactory.createMapping( tableName, mappingName, keyName, keyType ); testMapping.setTupleMapping( true ); String family = ""; String colName = ""; testMapping.addMappedColumn( vm, true ); vm = valueMetaInterfaceFactory .createHBaseValueMetaInterface( family, colName, "Column", ValueMetaInterface.TYPE_STRING, -1, -1 ); testMapping.addMappedColumn( vm, true ); vm = valueMetaInterfaceFactory .createHBaseValueMetaInterface( family, colName, "Value", ValueMetaInterface.TYPE_STRING, -1, -1 ); testMapping.addMappedColumn( vm, true ); vm = valueMetaInterfaceFactory .createHBaseValueMetaInterface( family, colName, "Timestamp", ValueMetaInterface.TYPE_INTEGER, -1, -1 ); vm.setIsLongOrDouble( true ); testMapping.addMappedColumn( vm, true );
/** * Delete a mapping from the mapping table * * @param theMapping the mapping to delete * @return true if the mapping was deleted successfully; false if the mapping table does not exist or the suppied * mapping does not exist in the mapping table * @throws Exception if a problem occurs during deletion */ public boolean deleteMapping( Mapping theMapping ) throws Exception { String tableName = theMapping.getTableName(); String mappingName = theMapping.getMappingName(); return deleteMapping( tableName, mappingName ); }
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { m_incomingKeyField = XMLHandler.getTagValue( stepnode, "incoming_key_field" ); m_incomingResultField = XMLHandler.getTagValue( stepnode, "incoming_result_field" ); this.namedCluster = namedClusterLoadSaveUtil.loadClusterConfig( namedClusterService, null, repository, metaStore, stepnode, log ); try { m_mapping = namedClusterServiceLocator.getService( this.namedCluster, HBaseService.class ).getMappingFactory() .createMapping(); } catch ( ClusterInitializationException e ) { throw new KettleXMLException( e ); } m_mapping.loadXML( stepnode ); }
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { m_incomingKeyField = rep.getStepAttributeString( id_step, 0, "incoming_key_field" ); m_incomingResultField = rep.getStepAttributeString( id_step, 0, "incoming_result_field" ); this.namedCluster = namedClusterLoadSaveUtil.loadClusterConfig( namedClusterService, id_step, rep, metaStore, null, log ); try { m_mapping = namedClusterServiceLocator.getService( this.namedCluster, HBaseService.class ).getMappingFactory() .createMapping(); } catch ( ClusterInitializationException e ) { throw new KettleXMLException( e ); } m_mapping.readRep( rep, id_step ); }
@Override public byte[] encodeKeyValue( Object keyValue, Mapping.KeyType keyType ) throws KettleException { return HBaseValueMeta .encodeKeyValue( keyValue, org.pentaho.hbase.shim.api.Mapping.KeyType.valueOf( keyType.name() ), hBaseBytesUtilShim ); }
@Override public KeyType getKeyType() { org.pentaho.hbase.shim.api.Mapping.KeyType keyType = delegate.getKeyType(); if ( keyType == null ) { return null; } return KeyType.valueOf( keyType.name() ); }
@Override public ComparisonType getComparisonOperator() { org.pentaho.hbase.shim.api.ColumnFilter.ComparisonType comparisonOperator = delegate.getComparisonOperator(); if ( comparisonOperator == null ) { return null; } return ComparisonType.valueOf( comparisonOperator.name() ); }
@Override public void setComparisonOperator( ComparisonType c ) { if ( c == null ) { delegate.setComparisonOperator( null ); } else { delegate.setComparisonOperator( org.pentaho.hbase.shim.api.ColumnFilter.ComparisonType.valueOf( c.name() ) ); } }
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException { if ( !Const.isEmpty( m_incomingKeyField ) ) { rep.saveStepAttribute( id_transformation, id_step, 0, "incoming_key_field", m_incomingKeyField ); } if ( !Const.isEmpty( m_incomingResultField ) ) { rep.saveStepAttribute( id_transformation, id_step, 0, "incoming_result_field", m_incomingResultField ); } namedClusterLoadSaveUtil.saveRep( rep, metaStore, id_transformation, id_step, namedClusterService, namedCluster, log ); if ( m_mapping != null ) { m_mapping.saveRep( rep, id_transformation, id_step ); } }
@Override public byte[] encodeKeyValue( Object o, ValueMetaInterface valueMetaInterface, Mapping.KeyType keyType ) throws KettleException { return HBaseValueMeta .encodeKeyValue( o, valueMetaInterface, org.pentaho.hbase.shim.api.Mapping.KeyType.valueOf( keyType.name() ), hBaseBytesUtilShim ); }
public static String[] getNumericOperators() { return new String[] { ColumnFilter.ComparisonType.EQUAL.toString(), ColumnFilter.ComparisonType.NOT_EQUAL.toString(), ColumnFilter.ComparisonType.GREATER_THAN.toString(), ColumnFilter.ComparisonType.GREATER_THAN_OR_EQUAL.toString(), ColumnFilter.ComparisonType.LESS_THAN.toString(), ColumnFilter.ComparisonType.LESS_THAN_OR_EQUAL.toString() }; }
@Override public void setKeyType( KeyType type ) { if ( type == null ) { delegate.setKeyType( null ); } else { delegate.setKeyType( org.pentaho.hbase.shim.api.Mapping.KeyType.valueOf( type.name() ) ); } }
@Override public Mapping createMapping( String tableName, String mappingName, String keyName, Mapping.KeyType keyType ) { org.pentaho.hbase.shim.api.Mapping.KeyType type = null; if ( keyType != null ) { type = org.pentaho.hbase.shim.api.Mapping.KeyType.valueOf( keyType.name() ); } return new MappingImpl( new org.pentaho.hbase.shim.api.Mapping( tableName, mappingName, keyName, type ), hBaseBytesUtilShim, hBaseValueMetaInterfaceFactory ); } }