new HashMap<String, FieldSchema>(size()); for (FieldSchema fs : mFields) { FieldSchema copy = fs.clone(); s.mFields.add(copy); fsMap.put(fs, copy);
if(! schema2colsAdded.contains(fs2)){ try { mergedSchema.add(fs2.clone()); } catch (CloneNotSupportedException e) { throw new SchemaMergeException(
public Schema outputSchema(Schema input) { try { // Column $0 is a bag of tuples that represent the left dataset Schema leftSchema = input.getField(0).schema.getField(0).schema; // Column $1 is a bag of tuples that represent the right dataset Schema rightSchema = input.getField(1).schema.getField(0).schema; Schema tupleSchema = new Schema(); for (FieldSchema leftAttr : leftSchema.getFields()) { leftAttr = leftAttr.clone(); leftAttr.alias = "left::"+leftAttr.alias; tupleSchema.add(leftAttr); } for (FieldSchema rightAttr : rightSchema.getFields()) { rightAttr = rightAttr.clone(); rightAttr.alias = "right::"+rightAttr.alias; tupleSchema.add(rightAttr); } FieldSchema outSchema = new Schema.FieldSchema("result", tupleSchema); outSchema.type = DataType.BAG; return new Schema(outSchema); } catch (Exception e) { return null; } }
private Schema getSchemaFromRequiredFieldList(Schema schema, List<RequiredField> fieldList) throws FrontendException { Schema s = new Schema(); for (RequiredField rf : fieldList) { FieldSchema f; try { f = schema.getField(rf.getAlias()).clone(); } catch (CloneNotSupportedException e) { throw new FrontendException("Clone not supported for the fieldschema", e); } if (rf.getSubFields() == null) { s.add(f); } else { Schema innerSchema = getSchemaFromRequiredFieldList(f.schema, rf.getSubFields()); if (innerSchema == null) { return null; } else { f.schema = innerSchema; s.add(f); } } } return s; }