/** * Given an alias, find the associated position of the field schema. * * @param alias * alias of the FieldSchema. * @return position of the FieldSchema. */ public int getPosition(String alias) throws FrontendException{ return getPosition(alias, false); }
/** * Given an alias, find the associated position of the field schema. * It uses getFieldSubNameMatch to look for subName matches as well. * @param alias * alias of the FieldSchema. * @return position of the FieldSchema. */ public int getPositionSubName(String alias) throws FrontendException{ return getPosition(alias, true); }
/** * Given a field name, this will return the index of it in the schema. * * @param context the context the method is being executed in * @param arg a field name to look for * @return the index for that field name */ @JRubyMethod public RubyFixnum index(ThreadContext context, IRubyObject arg) { if (arg instanceof RubyString) { try { return new RubyFixnum(context.getRuntime(), internalSchema.getPosition(arg.toString())); } catch (FrontendException e) { throw new RuntimeException("Unable to find position for argument: " + arg); } } else { throw new RuntimeException("Invalid arguement passed to index: " + arg); } }
this.aliasMap = new HashMap<String,Integer>(); for (String alias : this.inputTupleSchema.getAliases()) { this.aliasMap.put(alias,this.inputTupleSchema.getPosition(alias)); // something to cleanup
return tupleFS.schema.getPosition(alias); } else { FieldSchema fs = isSubNameMatch ? getFieldSubNameMatch(alias) : getField(alias);
for (int n=0; n< inputArray.length; n++) { if (this.dataBagSchema.getField(this.colName).type == DataType.DOUBLE) { inputArray[n] = (Double) tupleList.get(n).get(this.dataBagSchema.getPosition(this.colName)); } else if (this.dataBagSchema.getField(this.colName).type == DataType.FLOAT) { inputArray[n] = (Float) tupleList.get(n).get(this.dataBagSchema.getPosition(this.colName)); } else if (this.dataBagSchema.getField(this.colName).type == DataType.LONG ) { inputArray[n] = (Long) tupleList.get(n).get(this.dataBagSchema.getPosition(this.colName)); } else if (this.dataBagSchema.getField(this.colName).type == DataType.INTEGER ) { inputArray[n] = (Integer) tupleList.get(n).get(this.dataBagSchema.getPosition(this.colName)); } else { throw new RuntimeException(String.format("Data type of %s (%s) is not supported,",this.colName,