/** * Sets {@link #REQUIRED_FIELD_INDICES_CONF} to list of indices if requiredFieldList is not null. */ public static void setRequiredFieldConf(Configuration conf, RequiredFieldList requiredFieldList) { // set required fields conf for RCFile[Protobuf|Thrift] input format if (requiredFieldList != null) { List<Integer> indices = Lists.newArrayList(); for (RequiredField f : requiredFieldList.getFields()) { indices.add(f.getIndex()); } conf.set(RCFileUtil.REQUIRED_FIELD_INDICES_CONF, Joiner.on(",").join(indices)); } }
private static RequiredFieldList evenFields(List<FieldDescriptor> protoFields) { RequiredFieldList reqList = new RequiredFieldList(); int i = 0; for (FieldDescriptor fd : protoFields) { if (i % 2 == 0) { RequiredField field = new RequiredField(); field.setAlias(fd.getName()); field.setIndex(i); // field.setType() type is not used reqList.add(field); } i++; } return reqList; }