Package org.apache.avro.Schema

Examples of org.apache.avro.Schema.Type


    for (int i = 0; i < fields.size(); i++) {
      if (!stateManager.isDirty(obj, i)) {
        continue;
      }
      Field field = fields.get(i);
      Type type = field.schema().getType();
      Object o = obj.get(i);
      CassandraColumn col = columnMap.get(field.name());

      switch(type) {
      case MAP:
View Full Code Here


    for (int i = 0; iter.hasNext(); i++) {
      Field field = iter.next();
      if (!stateManager.isDirty(persistent, i)) {
        continue;
      }
      Type type = field.schema().getType();
      Object o = persistent.get(i);
      HBaseColumn hcol = mapping.getColumn(field.name());
      switch(type) {
        case MAP:
          if(o instanceof StatefulMap) {
View Full Code Here

  private static final SpecificDatumReader reader =
    new SpecificDatumReader();

  @SuppressWarnings({ "unchecked", "deprecation" })
  public static Object fromBytes(Schema schema, byte[] val) throws IOException {
    Type type = schema.getType();
    switch (type) {
    case ENUM:    return AvroUtils.getEnumValue(schema, val[0]);
    case STRING:  return new Utf8(Bytes.toString(val));
    case BYTES:   return ByteBuffer.wrap(val);
    case INT:     return Bytes.toInt(val);
View Full Code Here

    throw new RuntimeException("Can't parse data as class: " + clazz);
  }

  @SuppressWarnings("unchecked")
  public static byte[] toBytes(Object o, Schema schema) throws IOException {
    Type type = schema.getType();
    switch (type) {
    case STRING:  return Bytes.toBytes(((Utf8)o).toString()); // TODO: maybe ((Utf8)o).getBytes(); ?
    case BYTES:   return ((ByteBuffer)o).array();
    case INT:     return Bytes.toBytes((Integer)o);
    case LONG:    return Bytes.toBytes((Long)o);
View Full Code Here

    for(int i=0; i<requestFields.length; i++) {
      String f = requestFields[i];
      Field field = fieldMap.get(f);
      Schema fieldSchema = field.schema();
      Type type = fieldSchema.getType();
      Column column = mapping.getColumn(field.name());
      String columnName = column.getName();
      int columnIndex = rs.findColumn(columnName);

      if (rs.getObject(columnIndex) == null) {
View Full Code Here

   * Sets the object to the preparedStatement by it's schema
   */
  public void setObject(PreparedStatement statement, int index, Object object
      , Schema schema, Column column) throws SQLException, IOException {

    Type type = schema.getType();

    switch(type) {
      case MAP:
        setField(statement, column, schema, index, object);
        break;
View Full Code Here

    if (value != null) {
      return true;
    }
   
    Schema schema = f.schema();
    Type type = schema.getType();
   
    // If the type is null, any value is valid
    if (type == Type.NULL) {
      return true;
    }
View Full Code Here

        init(null, schema, false);
    }

    private boolean isNamedSchema(Schema schema) {
        Type type = schema.getType();
        return type.equals(Type.RECORD) || type.equals(Type.ENUM) || type.equals(Type.FIXED);
    }
View Full Code Here

  }

  @SuppressWarnings({ "rawtypes", "unchecked" })
  public static <T> Serializer<T> getSerializer(Schema schema) {
    Serializer serializer = null;
    Type type = schema.getType();
    if (type == Type.STRING) {
      serializer = Utf8Serializer.get();
    } else if (type == Type.BOOLEAN) {
      serializer = BooleanSerializer.get();
    } else if (type == Type.BYTES) {
View Full Code Here

    }
    return serializer;
  }

  public static GenericArraySerializer get(Schema elementSchema) {
    Type type = elementSchema.getType();
    if (type == Type.FIXED) {
      return get(Type.FIXED, TypeUtils.getClass(elementSchema));
    } else {
      return get(type);
    }
View Full Code Here

TOP

Related Classes of org.apache.avro.Schema.Type

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.