Package org.apache.avro

Examples of org.apache.avro.Schema$Name


      Schema.Field columnField = getColumnField(column);
      logger.debug("Schema for field " + column + " "
          + columnField.toString());
      fields.add(columnField);
    }
    Schema recordSchema = Schema.createRecord("hihoValue", null, null,
        false);
    recordSchema.setFields(fields);
    return recordSchema;
  }
View Full Code Here


    recordSchema.setFields(fields);
    return recordSchema;
  }

  public static Schema getPairSchema(ArrayList<ColumnInfo> columnInfo) {
    Schema pair = Schema.createRecord(Pair.class.getName(), null, null,
        false);
    List<Field> fields = new ArrayList<Field>();
    fields.add(new Field("key", getLongWritableSchema(), "", null));
    fields.add(new Field("value", getSchema(columnInfo), "", null,
        Field.Order.IGNORE));
    pair.setFields(fields);
    return pair;
  }
View Full Code Here

    pair.setFields(fields);
    return pair;
  }

  public static Schema getLongWritableSchema() {
    Schema recordSchema = Schema.createRecord("hihoKey", null, null, false);
    Schema.Field columnField = new Schema.Field("offset",
        Schema.create(Schema.Type.LONG), null, null);
    ArrayList<Schema.Field> fields = new ArrayList<Schema.Field>();
    fields.add(columnField);
    recordSchema.setFields(fields);
    return recordSchema;
  }
View Full Code Here

    recordSchema.setFields(fields);
    return recordSchema;
  }

  public static Schema.Field getColumnField(ColumnInfo column) {
    Schema fieldSchema = getSchema(column.getType());
    Schema.Field field = new Schema.Field(column.getName(), fieldSchema,
        null, null);
    return field;
  }
View Full Code Here

      break;
    default:
      returnType = null;
      break;
    }
    Schema returnSchema = Schema.create(returnType);
    return returnSchema;
  }
View Full Code Here

    values.add(new Time(new Date().getTime()));

    GenericDBWritable val = new GenericDBWritable(columns, values);
    LongWritable key = new LongWritable(1);

    Schema pairSchema = DBMapper.getPairSchema(val.getColumns());
    Schema keySchema = Pair.getKeySchema(pairSchema);
    Schema valueSchema = Pair.getValueSchema(pairSchema);
    Pair pair = new Pair<GenericRecord, GenericRecord>(pairSchema);

    GenericRecord keyRecord = new GenericData.Record(keySchema);
    keyRecord.put(0, key.get());
    GenericRecord valueRecord = new GenericData.Record(valueSchema);
    List<Schema.Field> fieldSchemas = valueSchema.getFields();
    for (int i = 0; i < val.getValues().size(); ++i) {
      Schema.Type type = fieldSchemas.get(i).schema().getType();
      if (type.equals(Schema.Type.STRING)) {
        Utf8 utf8 = new Utf8((String) val.getValues().get(i).toString());
        valueRecord.put(i, utf8);
View Full Code Here

    values.add(new Time(new Date().getTime()));

    GenericDBWritable val = new GenericDBWritable(columns, values);
    LongWritable key = new LongWritable(1);

    Schema pairSchema = DBMapper.getPairSchema(val.getColumns());
    Schema keySchema = Pair.getKeySchema(pairSchema);

    GenericRecord keyRecord = new GenericData.Record(keySchema);
    keyRecord.put(0, key.get());
    assertEquals(keyRecord,mapper.getKeyRecord(keySchema, key));
  }
View Full Code Here

    values.add(new Time(new Date().getTime()));

    GenericDBWritable val = new GenericDBWritable(columns, values);
    LongWritable key = new LongWritable(1);

    Schema pairSchema = DBMapper.getPairSchema(val.getColumns());
    Schema keySchema = Pair.getKeySchema(pairSchema);
    Schema valueSchema = Pair.getValueSchema(pairSchema);
   
    GenericRecord valueRecord = new GenericData.Record(valueSchema);
    List<Schema.Field> fieldSchemas = valueSchema.getFields();
    for (int i = 0; i < val.getValues().size(); ++i) {
      Schema.Type type = fieldSchemas.get(i).schema().getType();
      if (type.equals(Schema.Type.STRING)) {
        Utf8 utf8 = new Utf8((String) val.getValues().get(i).toString());
        valueRecord.put(i, utf8);
View Full Code Here

    columns.add(timeColumn);
    columns.add(timeStampColumn);
    columns.add(floatColumn);

    DBMapper dBMapper = new DBMapper();
    Schema schema = dBMapper.getSchema(columns);

    // Computing actual values.
    Schema.Field intColumnField = new Schema.Field("intColumn",
        Schema.create(Schema.Type.INT), null, null);
    Schema.Field stringColumnField = new Schema.Field("stringColumn",
        Schema.create(Schema.Type.STRING), null, null);
    Schema.Field dateColumnField = new Schema.Field("dateColumn",
        Schema.create(Schema.Type.STRING), null, null);
    Schema.Field longColumnField = new Schema.Field("longColumn",
        Schema.create(Schema.Type.LONG), null, null);
    Schema.Field booleanColumnField = new Schema.Field("booleanColumn",
        Schema.create(Schema.Type.BOOLEAN), null, null);
    Schema.Field doubleColumnField = new Schema.Field("doubleColumn",
        Schema.create(Schema.Type.DOUBLE), null, null);
    Schema.Field charColumnField = new Schema.Field("charColumn",
        Schema.create(Schema.Type.STRING), null, null);
    Schema.Field timeColumnField = new Schema.Field("timeColumn",
        Schema.create(Schema.Type.STRING), null, null);
    Schema.Field timeStampColumnField = new Schema.Field("timeStampColumn",
        Schema.create(Schema.Type.STRING), null, null);
    Schema.Field floatColumnField = new Schema.Field("floatColumn",
        Schema.create(Schema.Type.DOUBLE), null, null);

    ArrayList<Schema.Field> fields = new ArrayList<Schema.Field>();
    fields.add(intColumnField);
    fields.add(stringColumnField);
    fields.add(dateColumnField);
    fields.add(longColumnField);
    fields.add(booleanColumnField);
    fields.add(doubleColumnField);
    fields.add(charColumnField);
    fields.add(timeColumnField);
    fields.add(timeStampColumnField);
    fields.add(floatColumnField);

    Schema recordSchema = Schema.createRecord("hihoValue", null, null,
        false);
    recordSchema.setFields(fields);

    assertEquals(recordSchema, schema);
  }
View Full Code Here

    ColumnInfo intColumn = new ColumnInfo(0, Types.INTEGER, "intColumn");
    ArrayList<ColumnInfo> columns = new ArrayList<ColumnInfo>();
    columns.add(intColumn);

    DBMapper dBMapper = new DBMapper();
    Schema schema = dBMapper.getPairSchema(columns);

    // Computing actual values.
    Schema longWritableSchema = Schema.createRecord("hihoKey", null, null,
        false);
    Schema.Field columnField = new Schema.Field("offset",
        Schema.create(Schema.Type.LONG), null, null);
    ArrayList<Schema.Field> fields = new ArrayList<Schema.Field>();
    fields.add(columnField);
    longWritableSchema.setFields(fields);

    Schema pair = Schema.createRecord(Pair.class.getName(), null, null,
        false);
    List<Field> pairFields = new ArrayList<Field>();
    pairFields.add(new Field("key", longWritableSchema, "", null));
    pairFields.add(new Field("value", dBMapper.getSchema(columns), "",
        null, Field.Order.IGNORE));
    pair.setFields(pairFields);

    assertEquals(pair, schema);
  }
View Full Code Here

TOP

Related Classes of org.apache.avro.Schema$Name

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.