@Override public void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space ) throws KettleStepException { rowMeta.clear(); // start afresh - eats the input if ( m_mapping != null ) { int kettleType; if ( m_mapping.getKeyType() == Mapping.KeyType.DATE || m_mapping.getKeyType() == Mapping.KeyType.UNSIGNED_DATE ) { kettleType = ValueMetaInterface.TYPE_DATE; } else if ( m_mapping.getKeyType() == Mapping.KeyType.STRING ) { kettleType = ValueMetaInterface.TYPE_STRING; } else if ( m_mapping.getKeyType() == Mapping.KeyType.BINARY ) { kettleType = ValueMetaInterface.TYPE_BINARY; } else { kettleType = ValueMetaInterface.TYPE_INTEGER; } ValueMetaInterface keyMeta = new ValueMeta( m_mapping.getKeyName(), kettleType ); keyMeta.setOrigin( origin ); rowMeta.addValueMeta( keyMeta ); // Add the rest of the fields in the mapping Map<String, HBaseValueMetaInterface> mappedColumnsByAlias = m_mapping.getMappedColumns(); Set<String> aliasSet = mappedColumnsByAlias.keySet(); for ( String alias : aliasSet ) { HBaseValueMetaInterface columnMeta = mappedColumnsByAlias.get( alias ); columnMeta.setOrigin( origin ); rowMeta.addValueMeta( columnMeta ); } } }
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 ); }
String tableName = theMapping.getTableName(); String mappingName = theMapping.getMappingName(); Map<String, HBaseValueMetaInterface> mapping = theMapping.getMappedColumns(); String keyName = theMapping.getKeyName(); Mapping.KeyType keyType = theMapping.getKeyType(); boolean isTupleMapping = theMapping.isTupleMapping(); String tupleFamilies = theMapping.getTupleFamilies();
theMapping.setTupleMapping( true ); theMapping.setKeyName( alias ); theMapping.setTupleFamilies( family ); } else { theMapping.setKeyName( alias ); vm.setKey( true ); try { theMapping.setKeyTypeAsString( type ); vm.setType( HBaseInput.getKettleTypeByKeyType( theMapping.getKeyType() ) ); if ( includeKeyToColumns ) { theMapping.addMappedColumn( vm, isTupleMapping ); theMapping.addMappedColumn( vm, isTupleMapping ); } catch ( Exception ex ) {
.createHBaseValueMetaInterface( null, null, m_tableMapping.getKeyName(), getKettleTypeByKeyType( m_tableMapping.getKeyType() ), -1, -1 ); vm2.setKey( true ); try { m_tableMapping.addMappedColumn( vm2, m_tableMapping.isTupleMapping() ); } catch ( Exception exception ) { exception.printStackTrace(); m_columnsMappedByAlias = m_tableMapping.getMappedColumns(); if ( m_tableMapping.isTupleMapping() ) { m_tupleHandler = new HBaseRowToKettleTuple( m_bytesUtil ); if ( m_columnsMappedByAlias.get( vm.getAlias() ) == null ) { throw new KettleException( BaseMessages.getString( HBaseInputMeta.PKG, "HBaseInput.Error.UnableToFindUserSelectedColumn", vm.getAlias(), m_tableMapping.getFriendlyName() ) ); if ( m_userOutputColumns != null && m_userOutputColumns.size() > 0 && !m_tableMapping.isTupleMapping() ) { HBaseInputData.setScanColumns( scannerBuilder, m_userOutputColumns, m_tableMapping ); if ( m_tableMapping.isTupleMapping() ) { List<Object[]> tupleRows = HBaseInputData.getTupleOutputRows( hBaseService, next, m_userOutputColumns, m_columnsMappedByAlias, m_tableMapping,
m_columnsMappedByAlias = m_tableMapping.getMappedColumns(); if ( !m_meta.m_deleteRowKey && m_tableMapping.isTupleMapping() ) { String inName = vm.getName(); if ( m_tableMapping.getKeyName().equals( inName ) ) { incomingKey = true; m_incomingKeyIndex = i; if ( hvm == null && !m_meta.getDeleteRowKey() ) { throw new KettleException( BaseMessages.getString( HBaseOutputMeta.PKG, "HBaseOutput.Error.CantFindIncomingField", inName, m_tableMapping.getMappingName() ) ); "HBaseOutput.Error.TableKeyNotPresentInIncomingFields", m_tableMapping.getKeyName(), m_tableMapping .getMappingName() ) ); byte[] encodedKeyBytes = m_bytesUtil.encodeKeyValue( r[m_incomingKeyIndex], m_incomingKeyValueMeta, m_tableMapping.getKeyType() ); HBaseDelete hBaseDelete = targetTableWriteOperationManager.createDelete( encodedKeyBytes ); hBaseDelete.execute(); putError( getInputRowMeta(), r, 1, errorDescriptions, m_tableMapping.getKeyName(), "HBaseOutput004" ); BaseMessages.getString( HBaseOutputMeta.PKG, "HBaseOutput.Error.IncomingRowHasNullKeyValue" ); if ( getStepMeta().isDoingErrorHandling() ) { String errorFields = m_tableMapping.getKeyName(); putError( getInputRowMeta(), r, 1, errorDescriptions, errorFields, "HBaseOutput001" );
m_keyIndex = outputRowMeta.indexOfValue( mapping.getKeyName() ); m_familyIndex = outputRowMeta.indexOfValue( Mapping.TupleMapping.FAMILY.toString() ); m_colNameIndex = outputRowMeta.indexOfValue( Mapping.TupleMapping.COLUMN.toString() ); m_timestampIndex = outputRowMeta.indexOfValue( Mapping.TupleMapping.TIMESTAMP.toString() ); if ( !Const.isEmpty( mapping.getTupleFamilies() ) ) { String[] familiesS = mapping.getTupleFamiliesSplit(); m_userSpecifiedFamilies = new ArrayList<byte[]>(); m_userSpecifiedFamiliesHumanReadable = new ArrayList<String>(); throw new KettleException( ex ); Object decodedKey = mapping.decodeKeyValue( rawKey ); if ( !Const.isEmpty( mapping.getTupleFamilies() ) ) { int i = 0; for ( byte[] family : m_userSpecifiedFamilies ) {
resultMapping.setTupleMapping( isTupleMapping ); if ( !Const.isEmpty( tupleFamilies ) ) { resultMapping.setTupleFamilies( tupleFamilies ); if ( resultMapping.getKeyName().equals( alias ) ) { throw new IOException( "Error in mapping. Column \"" + newMeta.getAlias() + "\" has the same name as the table key (" + resultMapping.getKeyName() + ")" ); } else { resultCols.put( newMeta.getAlias(), newMeta ); resultMapping.setMappedColumns( resultCols ); return resultMapping;
if ( m_tableMapping == null || Const.isEmpty( m_tableMapping.getKeyName() ) ) { throw new KettleException( BaseMessages.getString( PKG, "HBaseRowDecoder.Error.NoMappingInfo" ) ); if ( m_tableMapping.isTupleMapping() ) { m_tupleHandler = new HBaseRowToKettleTuple( m_bytesUtil ); m_outputColumns = new HBaseValueMetaInterface[m_tableMapping.getMappedColumns().keySet().size()]; int k = 0; for ( String alias : m_tableMapping.getMappedColumns().keySet() ) { m_outputColumns[k++] = m_tableMapping.getMappedColumns().get( alias ); if ( m_tableMapping.isTupleMapping() ) { List<Object[]> hrowToKettleRow = m_tupleHandler.hbaseRowToKettleTupleMode( hBaseService.getHBaseValueMetaInterfaceFactory(), hRow, m_tableMapping, m_tableMapping .getMappedColumns(), m_data.getOutputRowMeta() ); throw new KettleException( BaseMessages.getString( PKG, "HBaseRowDecoder.Error.UnableToGetRowKey" ), ex ); Object decodedKey = m_tableMapping.decodeKeyValue( rowKey ); outputRowData[0] = decodedKey;
: tableMapping.numMappedColumns() + 1; // + 1 for the key throw new KettleException( e ); Object decodedKey = tableMapping.decodeKeyValue( rawKey ); int keyIndex = outputRowMeta.indexOfValue( currentCol.getAlias() ); outputRowData[keyIndex] = decodedKey; Object decodedKey = tableMapping.decodeKeyValue( rawKey ); int keyIndex = outputRowMeta.indexOfValue( tableMapping.getKeyName() ); outputRowData[keyIndex] = decodedKey;
Map<String, HBaseValueMetaInterface> columnMapping ) throws KettleException { String keyName = tupleMapping.getKeyName(); keyIndex = inputRowMeta.indexOfValue( keyName ); if ( keyIndex < 0 ) { keyType = tupleMapping.getKeyType();
byte[] keyUpperBound = null; org.pentaho.hbase.shim.api.Mapping.KeyType keyType = org.pentaho.hbase.shim.api.Mapping.KeyType.valueOf( tableMapping.getKeyType().name() ); String convM = dateOrNumberConversionMaskForKey; if ( tableMapping.getKeyType() == Mapping.KeyType.BINARY ) { } else if ( tableMapping.getKeyType() != Mapping.KeyType.STRING ) { if ( tableMapping.getKeyType() == Mapping.KeyType.DATE || tableMapping.getKeyType() == Mapping.KeyType.UNSIGNED_DATE ) { SimpleDateFormat sdf = new SimpleDateFormat(); sdf.applyPattern( convM ); convM = dateOrNumberConversionMaskForKey; if ( tableMapping.getKeyType() == Mapping.KeyType.BINARY ) { } else if ( tableMapping.getKeyType() != Mapping.KeyType.STRING ) { if ( tableMapping.getKeyType() == Mapping.KeyType.DATE || tableMapping.getKeyType() == Mapping.KeyType.UNSIGNED_DATE ) { SimpleDateFormat sdf = new SimpleDateFormat(); sdf.applyPattern( convM );
String tableName = theMapping.getTableName(); if ( theMapping.getMappedColumns().size() == 0 ) { MessageDialog.openError( m_shell, "No columns defined", "A HBase table requires at least one column family to be defined." ); Set<String> cols = theMapping.getMappedColumns().keySet(); Set<String> families = new TreeSet<String>(); for ( String col : cols ) { String family = theMapping.getMappedColumns().get( col ).getColumnFamily(); families.add( family );
.createHBaseValueMetaInterface( null, mapping.getKeyName(), "dummy", ValueMetaInterface.TYPE_INTEGER, 0, 0 ); m_tupleColsFromAliasMap.add( keyMeta );
vm.setTableName( tableName ); vm.setMappingName( mappingName ); testMapping.addMappedColumn( vm, false ); vm.setTableName( tableName ); vm.setMappingName( mappingName ); testMapping.addMappedColumn( vm, false ); Object[] vals = { "nomVal1", "nomVal2", "nomVal3" }; vm.setIndex( vals ); testMapping.addMappedColumn( vm, false ); vm.setTableName( tableName ); vm.setMappingName( mappingName ); testMapping.addMappedColumn( vm, false ); vm.setTableName( tableName ); vm.setMappingName( mappingName ); testMapping.addMappedColumn( vm, false ); vm.setTableName( tableName ); vm.setMappingName( mappingName ); testMapping.addMappedColumn( vm, false ); vm.setTableName( tableName ); vm.setMappingName( mappingName ); testMapping.addMappedColumn( vm, false ); vm.setTableName( tableName );
static List<HBaseValueMetaInterface> createOutputFieldsDefinition( List<OutputFieldDefinition> outputFieldsDefinition, Mapping m_mapping, HBaseService hBaseService ) { HBaseValueMetaInterfaceFactory valueMetaInterfaceFactory = hBaseService.getHBaseValueMetaInterfaceFactory(); ByteConversionUtil byteConversionUtil = hBaseService.getByteConversionUtil(); List<HBaseValueMetaInterface> outputFields = new ArrayList<>(); Map<String, HBaseValueMetaInterface> columns = m_mapping.getMappedColumns(); for ( OutputFieldDefinition fieldDefinition : outputFieldsDefinition ) { HBaseValueMetaInterface valueMeta = valueMetaInterfaceFactory.createHBaseValueMetaInterface( fieldDefinition.getFamily(), fieldDefinition .getColumnName(), fieldDefinition.getAlias(), ValueMeta.getType( fieldDefinition.getHbaseType() ), -1, -1 ); valueMeta.setKey( fieldDefinition.isKey() ); valueMeta.setConversionMask( fieldDefinition.getFormat() ); HBaseValueMetaInterface mappedColumn = columns.get( fieldDefinition.getAlias() ); if ( mappedColumn != null && mappedColumn.getIndex() != null ) { Object[] indexVal = mappedColumn.getIndex(); String indexStrign = byteConversionUtil.objectIndexValuesToString( indexVal ); Object[] vals = byteConversionUtil.stringIndexListToObjects( indexStrign ); valueMeta.setIndex( vals ); valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_INDEXED ); } outputFields.add( valueMeta ); } return outputFields; }
return; if ( !Utils.isEmpty( mapping.getTableName() ) ) { m_existingTableNamesCombo.setText( mapping.getTableName() ); if ( !Utils.isEmpty( mapping.getMappingName() ) ) { m_existingMappingNamesCombo.setText( mapping.getMappingName() ); if ( !Utils.isEmpty( mapping.getKeyName() ) ) { keyItem.setText( 1, mapping.getKeyName() ); if ( mapping.getKeyType() != null && !Utils.isEmpty( mapping.getKeyType().toString() ) ) { keyItem.setText( 5, mapping.getKeyType().toString() ); if ( mapping.isTupleMapping() && !Utils.isEmpty( mapping.getTupleFamilies() ) ) { keyItem.setText( 3, mapping.getTupleFamilies() ); Map<String, HBaseValueMetaInterface> mappedFields = mapping.getMappedColumns(); for ( String alias : mappedFields.keySet() ) { HBaseValueMetaInterface vm = mappedFields.get( alias );
theMapping.setTupleMapping( true ); theMapping.setKeyName( alias ); theMapping.setTupleFamilies( family ); } else { theMapping.setKeyName( alias ); valueMeta.setKey( true ); try { theMapping.setKeyTypeAsString( type ); valueMeta.setType( HBaseInput.getKettleTypeByKeyType( theMapping.getKeyType() ) ); } catch ( Exception ex ) { HBaseValueMetaInterface valueMeta = buildNonKeyValueMeta( alias, family, colName, type, column.getIndexedValues(), hBaseService ); theMapping.addMappedColumn( valueMeta, isTupleMapping ); } catch ( Exception ex ) { String message =
byte[] encodedKey = bu.encodeKeyValue( kettleRow[keyIndex], keyvm, tableMapping.getKeyType() );