Package org.apache.avro

Examples of org.apache.avro.AvroRuntimeException


    }

    private FieldAccessor getAccessorFor(String fieldName) {
      FieldAccessor result = byName.get(fieldName);
      if (result == null) {
        throw new AvroRuntimeException(
            "No field named " + fieldName + " in: " + clazz);
      }
      return result;
    }
View Full Code Here


            "org.apache.avro.reflect.FieldAccessReflect", FieldAccess.class);
        if (validate(reflectAccess)) {
          access = reflectAccess;
        }
      } catch (Throwable oops) {
        throw new AvroRuntimeException(
            "Unable to load a functional FieldAccess class!");
      }
    }
    fieldAccess = access;
  }
View Full Code Here

    AvroEncode enc = field.getAnnotation(AvroEncode.class);
    if (enc != null)
      try {
        return new UnsafeCustomEncodedField(field, enc.using().newInstance() );
      } catch (Exception e) {
        throw new AvroRuntimeException("Could not instantiate custom Encoding");
      }
    Class<?> c = field.getType();
    if (c == int.class)
      return new UnsafeIntField(field);
    else if (c == long.class)
View Full Code Here

  public static class Record implements GenericRecord, Comparable<Record> {
    private final Schema schema;
    private final Object[] values;
    public Record(Schema schema) {
      if (schema == null || !Type.RECORD.equals(schema.getType()))
        throw new AvroRuntimeException("Not a record schema: "+schema);
      this.schema = schema;
      this.values = new Object[schema.getFields().size()];
    }
View Full Code Here

    }
    @Override public Schema getSchema() { return schema; }
    @Override public void put(String key, Object value) {
      Schema.Field field = schema.getField(key);
      if (field == null)
        throw new AvroRuntimeException("Not a valid schema field: "+key);

      values[field.pos()] = value;
    }
View Full Code Here

    private final Schema schema;
    private int size;
    private Object[] elements = EMPTY;
    public Array(int capacity, Schema schema) {
      if (schema == null || !Type.ARRAY.equals(schema.getType()))
        throw new AvroRuntimeException("Not an array schema: "+schema);
      this.schema = schema;
      if (capacity != 0)
        elements = new Object[capacity];
    }
View Full Code Here

      if (capacity != 0)
        elements = new Object[capacity];
    }
    public Array(Schema schema, Collection<T> c) {
      if (schema == null || !Type.ARRAY.equals(schema.getType()))
        throw new AvroRuntimeException("Not an array schema: "+schema);
      this.schema = schema;
      if (c != null) {
        elements = new Object[c.size()];
        addAll(c);
      }
View Full Code Here

    AvroEncode enc = field.getAnnotation(AvroEncode.class);
    if (enc != null)
      try {
        return new ReflectionBasesAccessorCustomEncoded(field, enc.using().newInstance());
      } catch (Exception e) {
        throw new AvroRuntimeException("Could not instantiate custom Encoding");
      }
    return new ReflectionBasedAccessor(field);
  }
View Full Code Here

    @Override
    protected void read(Object object, Decoder in) throws IOException {
      try {
        field.set(object, encoding.read(in));
      } catch (IllegalAccessException e) {
        throw new AvroRuntimeException(e);
}
    }
View Full Code Here

    @Override
    protected void write(Object object, Encoder out) throws IOException {
      try {
        encoding.write(field.get(object), out);
      } catch (IllegalAccessException e) {
        throw new AvroRuntimeException(e);
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.avro.AvroRuntimeException

Copyright © 2018 www.massapicom. 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.