Package org.apache.avro

Examples of org.apache.avro.AvroRuntimeException


    public Object respond (Protocol.Message message, Object request) {
      String msgName = message.getName();
      if (msgName == "xyz") {
        return new Utf8("The java responder greets you.");
      } else {
        throw new AvroRuntimeException("unexcepcted message: " + msgName);
      }
    }
View Full Code Here


      if (msgName == "delete") {
        storage.remove(record.get("key"));
        return null;
      }

      throw new AvroRuntimeException("unexcepcted message: " + msgName);
    }
View Full Code Here

        throw (Exception) e.getTargetException();
      } else {
        throw new Exception(e.getTargetException());
      }
    } catch (NoSuchMethodException e) {
      throw new AvroRuntimeException(e);
    } catch (IllegalAccessException e) {
      throw new AvroRuntimeException(e);
    }
  }
View Full Code Here

      String avroCodec = HADOOP_AVRO_NAME_MAP.get(hadoopCodecClass);
      if (avroCodec != null) {
        o = CodecFactory.fromString(avroCodec);
      }
    } catch (Exception e) {
      throw new AvroRuntimeException("Unrecognized hadoop codec: " + hadoopCodecClass, e);
    }
    return o;
  }
View Full Code Here

      return Type.FLOAT.getName();
    if (datum instanceof Double)
      return Type.DOUBLE.getName();
    if (datum instanceof Boolean)
      return Type.BOOLEAN.getName();
    throw new AvroRuntimeException("Unknown datum type: "+datum);
}
View Full Code Here

    case LONG:    return datum instanceof Long;
    case FLOAT:   return datum instanceof Float;
    case DOUBLE:  return datum instanceof Double;
    case BOOLEAN: return datum instanceof Boolean;
    case NULL:    return datum == null;
    default: throw new AvroRuntimeException("Unexpected type: " +schema);
    }
  }
View Full Code Here

      }
      return e1.hasNext() ? 1 : (e2.hasNext() ? -1 : 0);
    case MAP:
      if (equals)
        return ((Map)o1).equals(o2) ? 0 : 1;
      throw new AvroRuntimeException("Can't compare maps!");
    case UNION:
      int i1 = resolveUnion(s, o1);
      int i2 = resolveUnion(s, o2);
      return (i1 == i2)
        ? compare(o1, o2, s.getTypes().get(i1), equals)
View Full Code Here

        return new Utf8(value.toString());
      case UNION:
        return deepCopy(
            schema.getTypes().get(resolveUnion(schema, value)), value);
      default:
        throw new AvroRuntimeException(
            "Deep copy failed for schema \"" + schema + "\" and value \"" +
            value + "\"");
    }
  }
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

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.