Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PDI-16661] - HBaseOutput Tuple Write and Row Delete #1159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class MappingUtils {

private static final Set<String> TUPLE_COLUMNS = new HashSet<String>();

public static final String TUPLE_MAPPING_VISIBILITY = "Visibility";

static {
TUPLE_COLUMNS.add( Mapping.TupleMapping.KEY.toString() );
TUPLE_COLUMNS.add( Mapping.TupleMapping.FAMILY.toString() );
Expand All @@ -70,8 +72,8 @@ public static MappingAdmin getMappingAdmin( ConfigurationProducer cProducer ) th
}
}

public static MappingAdmin getMappingAdmin( HBaseService hBaseService, VariableSpace variableSpace,
String siteConfig, String defaultConfig ) throws IOException {
public static MappingAdmin getMappingAdmin( HBaseService hBaseService, VariableSpace variableSpace, String siteConfig,
String defaultConfig ) throws IOException {
HBaseConnection hBaseConnection = hBaseService.getHBaseConnection( variableSpace, siteConfig, defaultConfig, null );
return new MappingAdmin( hBaseConnection );
}
Expand All @@ -88,7 +90,8 @@ public static Mapping getMapping( MappingDefinition mappingDefinition, HBaseServ
throw new KettleException( Messages.getString( "MappingDialog.Error.Message.NoFieldsDefined" ) );
}

Mapping theMapping = hBaseService.getMappingFactory().createMapping( tableName, mappingDefinition.getMappingName() );
Mapping theMapping =
hBaseService.getMappingFactory().createMapping( tableName, mappingDefinition.getMappingName() );
// is the mapping a tuple mapping?
final boolean isTupleMapping = isTupleMapping( mappingDefinition );
if ( isTupleMapping ) {
Expand Down Expand Up @@ -128,7 +131,8 @@ public static Mapping getMapping( MappingDefinition mappingDefinition, HBaseServ
if ( !Const.isEmpty( column.getType() ) ) {
type = column.getType();
} else {
throw new KettleException( Messages.getString( "MappingDialog.Error.Message.TypeIssue" ) + ": " + columnNumber );
throw new KettleException( Messages.getString( "MappingDialog.Error.Message.TypeIssue" ) + ": "
+ columnNumber );
}

HBaseValueMetaInterfaceFactory valueMetaInterfaceFactory = hBaseService.getHBaseValueMetaInterfaceFactory();
Expand Down Expand Up @@ -160,8 +164,8 @@ public static Mapping getMapping( MappingDefinition mappingDefinition, HBaseServ
theMapping.addMappedColumn( valueMeta, isTupleMapping );
} catch ( Exception ex ) {
String message =
Messages.getString( "MappingDialog.Error.Message1.DuplicateColumn" ) + family + "," + colName
+ Messages.getString( "MappingDialog.Error.Message2.DuplicateColumn" );
Messages.getString( "MappingDialog.Error.Message1.DuplicateColumn" ) + family + "," + colName + Messages
.getString( "MappingDialog.Error.Message2.DuplicateColumn" );
throw new KettleException( message );
}
}
Expand Down Expand Up @@ -196,7 +200,7 @@ public static HBaseValueMetaInterface buildNonKeyValueMeta( String alias, String
public static boolean isTupleMapping( MappingDefinition mappingDefinition ) {
List<MappingColumn> mappingColumns = mappingDefinition.getMappingColumns();
int mappingSize = mappingColumns.size();
if ( mappingSize != TUPLE_COLUMNS_COUNT ) {
if ( !( mappingSize == TUPLE_COLUMNS_COUNT || mappingSize == TUPLE_COLUMNS_COUNT + 1 ) ) {
return false;
}
int tupleIdCount = 0;
Expand All @@ -205,11 +209,11 @@ public static boolean isTupleMapping( MappingDefinition mappingDefinition ) {
tupleIdCount++;
}
}
return tupleIdCount == TUPLE_COLUMNS_COUNT;
return tupleIdCount == TUPLE_COLUMNS_COUNT || tupleIdCount == TUPLE_COLUMNS_COUNT + 1;
}

public static boolean isTupleMappingColumn( String columnName ) {
return TUPLE_COLUMNS.contains( columnName );
return TUPLE_COLUMNS.contains( columnName ) || columnName.equals( TUPLE_MAPPING_VISIBILITY );
}

}
Loading