Package org.apache.avro.Schema

Examples of org.apache.avro.Schema.Field.pos()


        if (!val.isDirty(i)) {
          continue;
        }
        Field field = fields.get(i);

        Object o = val.get(field.pos());

        Pair<Text,Text> col = mapping.fieldMap.get(field.name());

        if (col == null) {
          throw new GoraException("Please define the gora to accumulo mapping for field " + field.name());
View Full Code Here


      if (!value.isDirty(i)) {
        continue;
      }
      Field field = fields.get(i);
      Type type = field.schema().getType();
      Object fieldValue = value.get(field.pos());
      Schema fieldSchema = field.schema();
      // check if field has a nested structure (array, map, record or union)
      fieldValue = getFieldValue(fieldSchema, type, fieldValue);
      p.put(field.pos(), fieldValue);
    }
View Full Code Here

      Type type = field.schema().getType();
      Object fieldValue = value.get(field.pos());
      Schema fieldSchema = field.schema();
      // check if field has a nested structure (array, map, record or union)
      fieldValue = getFieldValue(fieldSchema, type, fieldValue);
      p.put(field.pos(), fieldValue);
    }
    // this performs a structural modification of the map
    this.buffer.put(key, p);
  }
View Full Code Here

          production[--count] =
            new Symbol.SkipAction(super.generate(wfe.getValue().schema(),
              seen));
        } else {
          production[--count] =
            new Symbol.FieldAdjustAction(rf.pos(), fname);
          production[--count] =
            generate(wfe.getValue().schema(), rf.schema(), seen);
        }
      }
View Full Code Here

      for (Map.Entry<String, Field> rfe : rfields.entrySet()) {
        String fname = rfe.getKey();
        Field wf = wfields.get(fname);
        if (wf == null) {
          Field rf = rfe.getValue();
          production[--count] = new Symbol.FieldAdjustAction(rf.pos(), fname);
          production[--count] = new Symbol.DefaultStartAction(
              new JsonGrammarGenerator().generate(rf.schema()),
              rf.defaultValue());
          production[--count] = super.generate(rf.schema(), seen);
          production[--count] = Symbol.DEFAULT_END_ACTION;
View Full Code Here

   * representations.*/
  protected void writeRecord(Schema schema, Object datum, Encoder out)
    throws IOException {
    for (Entry<String, Field> entry : schema.getFields().entrySet()) {
      Field field = entry.getValue();
      write(field.schema(), getField(datum, entry.getKey(), field.pos()), out);
    }
  }
 
  /** Called by the default implementation of {@link #writeRecord} to retrieve
   * a record field value.  The default implementation is for {@link
View Full Code Here

          expected == actual ? actualField : expectedFields.get(entry.getKey());
      if (expectedField == null) {
        skip(actualField.schema(), in);
        continue;
      }
      int fieldPosition = expectedField.pos();
      Object oldDatum =
          (old != null) ? getField(record, fieldName, fieldPosition) : null;
      addField(record, fieldName, fieldPosition,
               read(oldDatum,actualField.schema(),expectedField.schema(), in));
      size++;
View Full Code Here

        String fieldName = entry.getKey();
        if (!actualFields.contains(fieldName)) {  // an unset field
          Field f = entry.getValue();
          JsonNode json = f.defaultValue();
          if (json != null)                       // has default
            addField(record, fieldName, f.pos()// add default
                     defaultFieldValue(old, f.schema(), json));
          else if (old != null)                   // remove stale value
            removeField(record, fieldName, entry.getValue().pos());
        }
      }
View Full Code Here

        String name = entry.getKey();
        Field f = entry.getValue();
        JsonNode v = json.get(name);
        if (v == null) v = f.defaultValue();
        if (v != null) {
          Object o = old != null ? getField(old, name, f.pos()) : null;
          addField(record, name, f.pos(), defaultFieldValue(o, f.schema(), v));
        } else if (old != null) {
          removeField(record, name, f.pos());
        }
      }
View Full Code Here

        Field f = entry.getValue();
        JsonNode v = json.get(name);
        if (v == null) v = f.defaultValue();
        if (v != null) {
          Object o = old != null ? getField(old, name, f.pos()) : null;
          addField(record, name, f.pos(), defaultFieldValue(o, f.schema(), v));
        } else if (old != null) {
          removeField(record, name, f.pos());
        }
      }
      return record;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.