Package org.apache.avro

Examples of org.apache.avro.Schema


  }

  void configure(TaskType taskType, CharSequence inSchemaText, CharSequence outSchemaText) {
    this.taskType = taskType;
    try {
      Schema inSchema = Schema.parse(inSchemaText.toString());
      Schema outSchema = Schema.parse(outSchemaText.toString());
      switch (taskType) {
      case MAP:
        this.inReader = new SpecificDatumReader<IN>(inSchema);
        this.midCollector = new Collector<MID>(outSchema);
        break;
View Full Code Here


    JobConf job = new JobConf();
    Path output = new Path(System.getProperty("test.dir",".")+"/seq-out");

    output.getFileSystem(job).delete(output);
   
    Schema schema = Pair.getPairSchema(Schema.create(Schema.Type.LONG),
                                       Schema.create(Schema.Type.STRING));

    AvroJob.setInputSequenceFile(job);

    AvroJob.setInputSchema(job, schema);
View Full Code Here

      String jsonReaderSchema,
      String readerCalls,
      Encoding encoding,
      int skipLevel) throws IOException {
    Object[] values = TestValidatingIO.randomValues(writerCalls);
    Schema writerSchema = Schema.parse(jsonWriterSchema);
    byte[] bytes = TestValidatingIO.make(writerSchema, writerCalls,
        values, encoding);
    Schema readerSchema = Schema.parse(jsonReaderSchema);
    check(writerSchema, readerSchema, bytes, readerCalls,
        values,
        encoding, skipLevel);
  }
View Full Code Here

    new BlockingBinaryEncoder(out).init(new ByteArrayOutputStream());
  }

  @Test
  public void testJsonEncoderInit() throws IOException {
    Schema s = Schema.parse("\"int\"");
    OutputStream out = null;
    new JsonEncoder(s, out).init(new ByteArrayOutputStream());
  }
View Full Code Here

    new JsonEncoder(s, out).init(new ByteArrayOutputStream());
  }

  @Test
  public void testValidatingEncoderInit() throws IOException {
    Schema s = Schema.parse("\"int\"");
    OutputStream out = null;
    Encoder e = new BinaryEncoder(out);
    new ValidatingEncoder(s, e).init(new ByteArrayOutputStream());
  }
View Full Code Here

  }

  @Test
  public void testResolving()
    throws IOException {
    Schema writerSchema = Schema.parse(sJsWrtSchm);
    byte[] bytes = TestValidatingIO.make(writerSchema, sWrtCls,
        oaWrtVals, TestValidatingIO.Encoding.BINARY);
    Schema readerSchema = Schema.parse(sJsRdrSchm);
    TestResolvingIO.check(writerSchema, readerSchema, bytes, sRdrCls,
        oaRdrVals,
        TestValidatingIO.Encoding.BINARY, iSkipL);
  }
View Full Code Here

/*
* Declaration syntax follows.
*/
  final public Schema NamedSchemaDeclaration() throws ParseException {
  Schema s;
  Map<String, JsonNode> props = new LinkedHashMap<String, JsonNode>();
  String savedSpace = this.namespace;
    label_1:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case AT:
        ;
        break;
      default:
        jj_la1[2] = jj_gen;
        break label_1;
      }
      SchemaProperty(props);
    }
    if (props.containsKey("namespace"))
      this.namespace = getTextProp("namespace", props, token);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case FIXED:
      s = FixedDeclaration();
      break;
    case ENUM:
      s = EnumDeclaration();
      break;
    case ERROR:
    case RECORD:
      s = RecordDeclaration();
      break;
    default:
      jj_la1[3] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
   this.namespace = savedSpace;

   for (String key : props.keySet())
     if ("namespace".equals(key)) {               // already handled: ignore
     } else if ("aliases".equals(key)) {          // aliases
       for (String alias : getTextProps("aliases", props, token))
         s.addAlias(alias);
     } else if (props.get(key).isTextual()) {     // ignore other non-textual
       s.addProp(key, getTextProp(key, props, token));
     }

   {if (true) return s;}
    throw new Error("Missing return statement in function");
  }
View Full Code Here

   {if (true) return s;}
    throw new Error("Missing return statement in function");
  }

  final public Schema UnionDefinition() throws ParseException {
  Schema s;
  List<Schema> schemata = new ArrayList<Schema>();
    jj_consume_token(UNION);
    jj_consume_token(LBRACE);
    s = Type();
    schemata.add(s);
View Full Code Here

  String name;
  List<String> symbols;
    jj_consume_token(ENUM);
    name = Identifier();
    symbols = EnumBody();
    Schema s = Schema.createEnum(name, getDoc(), this.namespace, symbols);
    names.put(s.getFullName(), s);
    {if (true) return s;}
    throw new Error("Missing return statement in function");
  }
View Full Code Here

    sym = Identifier();
                       symbols.add(sym);
  }

  final public void ProtocolBody(Protocol p) throws ParseException {
  Schema schema;
  Message message;
  Protocol importProtocol;
    jj_consume_token(LBRACE);
    label_5:
    while (true) {
View Full Code Here

TOP

Related Classes of org.apache.avro.Schema

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.