Package org.apache.avro.Schema

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


      Iterator<Field> fields = s.getFields().values().iterator();
      for (int i = 0; fields.hasNext(); i++) {
        Field f = fields.next();
        if (f.order() == Field.Order.IGNORE)
          continue;                               // ignore this field
        int compare = compare(r1.get(i), r2.get(i), f.schema());
        if (compare != 0)                         // not equal
          return f.order() == Field.Order.DESCENDING ? -compare : compare;
      }
      return 0;
    case ENUM:
View Full Code Here


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

      // Add default values for fields missing from Writer
      for (Map.Entry<String, Field> rfe : rfields.entrySet()) {
View Full Code Here

        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

          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;
        }
      }
    }
    return result;
View Full Code Here

      for (Map.Entry<String, Field> e : s.getFields().entrySet()) {
        Field f = e.getValue();
        if (f.order() == Field.Order.IGNORE)
          continue;                               // ignore this field
        String name = e.getKey();
        int compare = compare(r1.get(name), r2.get(name), f.schema());
        if (compare != 0)                         // not equal
          return f.order() == Field.Order.DESCENDING ? -compare : compare;
      }
      return 0;
    case ENUM:
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

      }
      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++;
    }
    if (expectedFields.size() > size) {           // not all fields set
      Set<String> actualFields = actual.getFields().keySet();
      for (Map.Entry<String, Field> entry : expectedFields.entrySet()) {
View Full Code Here

        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

        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

    switch (schema.getType()) {
    case RECORD: {
      for (Map.Entry<String, Field> entry : schema.getFields().entrySet()) {
        Field field = entry.getValue();
        if (field.order() == Field.Order.IGNORE) {
          GenericDatumReader.skip(field.schema(), d1);
          GenericDatumReader.skip(field.schema(), d2);
          continue;
        }
        int c = compare(d, field.schema());
        if (c != 0)
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.