Package org.apache.avro.Schema

Examples of org.apache.avro.Schema.Type


   * @see org.apache.gora.cassandra.query.CassandraColumn#getValue()
   */
  public Object getValue() {
    Field field = getField();
    Schema fieldSchema = field.schema();
    Type type = fieldSchema.getType();
    ByteBuffer byteBuffer = hColumn.getValue();
    if (byteBuffer == null) {
      return null;
    }

View Full Code Here


              LOG.warn("member name is null or empty.");
              continue;
            }
            Field memberField = fieldSchema.getField(memberName);
            Schema memberSchema = memberField.schema();
            Type memberType = memberSchema.getType();
           
            CassandraSubColumn cassandraColumn = new CassandraSubColumn();
            cassandraColumn.setField(memberField);
            cassandraColumn.setValue(hColumn);
           
            if (memberType.equals(Type.UNION)){
              HColumn<ByteBuffer, ByteBuffer> hc = getUnionTypeColumn(memberField.name()
                  + CassandraStore.UNION_COL_SUFIX, this.hSuperColumn.getColumns().toArray());
              Integer unionIndex = getUnionIndex(memberField.name(),hc);
              cassandraColumn.setUnionType(unionIndex);
            }
           
            record.put(record.getSchema().getField(memberName).pos(), cassandraColumn.getValue());
          }
          }
        }
        break;
      case UNION:
        int schemaPos = this.getUnionType();
        Schema unioSchema = fieldSchema.getTypes().get(schemaPos);
        Type unionType = unioSchema.getType();
        value = getSuperValue(field, unioSchema, unionType);
        break;
      default:
        Object memberValue = null;
        // Using for UnionIndex of Union type field get value. UnionIndex always Integer. 
View Full Code Here

}

  public Object getValue() {
    Field field = getField();
    Schema fieldSchema = field.schema();
    Type type = fieldSchema.getType();
   
    Object value = getSuperValue(field, fieldSchema, type);
   
    return value;
  }
View Full Code Here

      return null;
    }
  }

  public static Schema getSchema(Class<?> clazz) {
    Type type = getType(clazz);
    if (type == null) {
      return null;
    } else if (type == Type.FIXED) {
      int size = getFixedSize(clazz);
      String name = clazz.getName();
View Full Code Here

      return Schema.create(type);
    }
  }

  public static Class<?> getClass(Schema schema) {
    Type type = schema.getType();
    if (type == null) {
      return null;
    } else if (type == Type.FIXED) {
      try {
        return Class.forName( schema.getFullName() );
View Full Code Here

      return -1;
    }
  }

  public static int getFixedSize(Schema schema) {
    Type type = schema.getType();
    if (type == Type.FIXED) {
      return schema.getFixedSize();
    } else {
      return getFixedSize(type);
    }
View Full Code Here

      return getFixedSize(type);
    }
  }

  public static int getFixedSize(Class<?> clazz) {
    Type type = getType(clazz);
    if (type == Type.FIXED) {
      try {
        return ((SpecificFixed)clazz.newInstance()).bytes().length;
      } catch (InstantiationException e) {
        LOG.warn(e.toString());
View Full Code Here

    }
    // Generating UnionFields
    ArrayList<String> unionFields = new ArrayList<String>();
    for (String field: fields){
      Field schemaField =this.fieldMap.get(field);
      Type type = schemaField.schema().getType();
      if (type.getName().equals("UNION".toLowerCase())){
        unionFields.add(field+UNION_COL_SUFIX);
      }
    }
   
    String[] arr = unionFields.toArray(new String[unionFields.size()]);
View Full Code Here

    for (int i = 1; i < fields.size(); i++) {
      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

      for (Field member: fieldSchema.getFields()) {
        if (member.pos() == 0 || !persistent.isDirty()) {
          continue;
        }
        Schema memberSchema = member.schema();
        Type memberType = memberSchema.getType();
        Object memberValue = persistent.get(member.pos());
        newRecord.put(member.pos(), getFieldValue(memberSchema, memberType, memberValue));
      }
      fieldValue = newRecord;
      break;
    case MAP:
      Map<?, ?> map = (Map<?, ?>) fieldValue;
      fieldValue = map;
      break;
    case ARRAY:
      fieldValue = (List<?>) fieldValue;
      break;
    case UNION:
      // storing the union selected schema, the actual value will
      // be stored as soon as we get break out.
      if (fieldValue != null){
        int schemaPos = getUnionSchema(fieldValue,fieldSchema);
        Schema unionSchema = fieldSchema.getTypes().get(schemaPos);
        Type unionType = unionSchema.getType();
        fieldValue = getFieldValue(unionSchema, unionType, fieldValue);
      }
      //p.put( schemaPos, p.getSchema().getField(field.name() + CassandraStore.UNION_COL_SUFIX));
      //p.put(fieldPos, fieldValue);
      break;
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.