flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmetzger <...@git.apache.org>
Subject [GitHub] incubator-flink pull request: [FLINK-1032] Rework support for POJO...
Date Mon, 06 Oct 2014 12:49:21 GMT
Github user rmetzger commented on a diff in the pull request:

    https://github.com/apache/incubator-flink/pull/141#discussion_r18454177
  
    --- Diff: flink-java/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java
---
    @@ -105,73 +114,124 @@ public String toString() {
     				+ ", fields = [" + Joiner.on(", ").join(fieldStrings) + "]"
     				+ ">";
     	}
    -
    -	public int getLogicalPosition(String fieldExpression) {
    -		for (int i = 0; i < fields.length; i++) {
    -			if (fields[i].field.getName().equals(fieldExpression)) {
    -				return i;
    +	
    +	@Override
    +	public void getKey(String fieldExpression, int offset, List<FlatFieldDescriptor>
result) {
    +		// handle 'select all' first
    +		if(fieldExpression.equals(ExpressionKeys.SELECT_ALL_CHAR)) {
    +			int keyPosition = 0;
    +			for(PojoField field : fields) {
    +				if(field.type instanceof AtomicType) {
    +					result.add(new FlatFieldDescriptor(offset + keyPosition, field.type));
    +				} else if(field.type instanceof CompositeType) {
    +					CompositeType<?> cType = (CompositeType<?>)field.type;
    +					cType.getKey(String.valueOf(ExpressionKeys.SELECT_ALL_CHAR), offset + keyPosition,
result);
    +					keyPosition += cType.getTotalFields()-1;
    +				} else {
    +					throw new RuntimeException("Unexpected key type: "+field.type);
    +				}
    +				keyPosition++;
     			}
    +			return;
    +		}
    +		Validate.notEmpty(fieldExpression, "Field expression must not be empty.");
    +		// if there is a dot try getting the field from that sub field
    +		int firstDot = fieldExpression.indexOf('.');
    +		if (firstDot == -1) {
    +			// this is the last field (or only field) in the field expression
    +			int fieldId = 0;
    +			for (int i = 0; i < fields.length; i++) {
    +				if(fields[i].type instanceof CompositeType) {
    +					fieldId += fields[i].type.getTotalFields()-1;
    +				}
    --- End diff --
    
    Thank you. I've fixed this


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message