Package org.apache.avro.Schema

Examples of org.apache.avro.Schema.Field


      _log.info(_eventSchema.getFullName() + ": using primary key override:" + keyColumnName);
    }

    // Examine the event schema to determine the proper type of "key". The key must be a
    // String, int, or long data type.
    Field keyField = _eventSchema.getField(keyColumnName);

    // work around for bizfollow for now, chekc if it is id
    if (keyField == null)
    {
      keyField = _eventSchema.getField("id");
View Full Code Here


  {
    String pkStr = "anetId";
    ArrayList<String> pkStrList =  new ArrayList<String>();
    pkStrList.add("anetId");

    Field sf = new Field("anetId", null, null, null);
    Assert.assertEquals(sf.name(), "anetId");

    Field sf2 = new Field("settings", null, null, null);
    Assert.assertEquals(sf2.name(), "settings");

    PrimaryKey pk = new PrimaryKey(pkStr);
    Assert.assertFalse(pk.isCompositeKey());
    Assert.assertEquals(pk.getNumKeys(), 1);
    Assert.assertEquals(pk.getPKeyList(), pkStrList);
View Full Code Here

    String pkStr = "anetId,settingId";
    ArrayList<String> pkStrList =  new ArrayList<String>();
    pkStrList.add("anetId");
    pkStrList.add("settingId");

    Field sf = new Field("anetId", null, null, null);
    Assert.assertEquals(sf.name(), "anetId");

    Field sf2 = new Field("settingId", null, null, null);
    Assert.assertEquals(sf2.name(), "settingId");

    Field sf3 = new Field("junkId", null, null, null);
    Assert.assertEquals(sf3.name(), "junkId");

    PrimaryKey pk = new PrimaryKey(pkStr);
    Assert.assertTrue(pk.isCompositeKey());
    Assert.assertEquals(pk.getNumKeys(), 2);
    Assert.assertEquals(pk.getPKeyList(), pkStrList);
View Full Code Here

    String pkStr = " anetId, settingId   ";
    ArrayList<String> pkStrList =  new ArrayList<String>();
    pkStrList.add("anetId");
    pkStrList.add("settingId");

    Field sf = new Field("anetId  ", null, null, null);
    Assert.assertEquals(sf.name(), "anetId  ");

    Field sf2 = new Field(" settingId ", null, null, null);
    Assert.assertEquals(sf2.name(), " settingId ");

    PrimaryKey pk = new PrimaryKey(pkStr);
    Assert.assertTrue(pk.isCompositeKey());
    Assert.assertEquals(pk.getNumKeys(), 2);
    Assert.assertEquals(pk.getPKeyList(), pkStrList);
View Full Code Here

    assertEquals(Schema.Type.UNION, response.getType());
    assertEquals(Schema.Type.NULL, response.getTypes().get(0).getType());
    assertEquals(Schema.Type.STRING, response.getTypes().get(1).getType());
    // check request schema is union
    Schema request = message.getRequest();
    Field field = request.getField("s");
    assertNotNull("field 's' should not be null", field);
    Schema param = field.schema();
    assertEquals(Schema.Type.UNION, param.getType());
    assertEquals(Schema.Type.NULL, param.getTypes().get(0).getType());
    assertEquals(Schema.Type.STRING, param.getTypes().get(1).getType());
    // check union erasure
    assertEquals(String.class, ReflectData.get().getClass(response));
View Full Code Here

  }
 
  @Test public void testR11() throws Exception {
    Schema r11Record = ReflectData.get().getSchema(R11.class);
    assertEquals(Schema.Type.RECORD, r11Record.getType());
    Field r11Field = r11Record.getField("text");
    assertEquals(NullNode.getInstance(), r11Field.defaultValue());
    Schema r11FieldSchema = r11Field.schema();
    assertEquals(Schema.Type.UNION, r11FieldSchema.getType());
    assertEquals(Schema.Type.NULL, r11FieldSchema.getTypes().get(0).getType());
    Schema r11String = r11FieldSchema.getTypes().get(1);
    assertEquals(Schema.Type.STRING, r11String.getType());
    R11 r11 = new R11();
View Full Code Here

    assertEquals(Schema.Type.UNION, response.getType());
    assertEquals(Schema.Type.NULL, response.getTypes().get(0).getType());
    assertEquals(Schema.Type.STRING, response.getTypes().get(1).getType());
    // check request schema is union
    Schema request = message.getRequest();
    Field field = request.getField("s");
    assertNotNull("field 's' should not be null", field);
    Schema param = field.schema();
    assertEquals(Schema.Type.UNION, param.getType());
    assertEquals(Schema.Type.NULL, param.getTypes().get(0).getType());
    assertEquals(Schema.Type.STRING, param.getTypes().get(1).getType());
    // check union erasure
    assertEquals(String.class, ReflectData.get().getClass(response));
View Full Code Here

  @Test public void testP4() throws Exception {
    Protocol p = ReflectData.get().getProtocol(P4.class);
    Protocol.Message message = p.getMessages().get("foo");
    assertEquals(Schema.Type.INT, message.getResponse().getType());
    Field field = message.getRequest().getField("x");
    assertEquals(Schema.Type.INT, field.schema().getType());
  }
View Full Code Here

  @Test public void testP2() throws Exception {
    Schema e1 = ReflectData.get().getSchema(E1.class);
    assertEquals(Schema.Type.RECORD, e1.getType());
    assertTrue(e1.isError());
    Field message = e1.getField("detailMessage");
    assertNotNull("field 'detailMessage' should not be null", message);
    Schema messageSchema = message.schema();
    assertEquals(Schema.Type.UNION, messageSchema.getType());
    assertEquals(Schema.Type.NULL, messageSchema.getTypes().get(0).getType());
    assertEquals(Schema.Type.STRING, messageSchema.getTypes().get(1).getType());

    Protocol p2 = ReflectData.get().getProtocol(P2.class);
View Full Code Here

      List<Schema> recs = new ArrayList<Schema>();
      for (int j = 0; j < i; j++)
        recs.add(Schema.createRecord(""+(char)('A'+j), null, null, false));
      for (Schema s : recs) {
        Schema union = Schema.createUnion(recs);
        Field f = new Field("x", union, null, null);
        List<Field> fields = new ArrayList<Field>();
        fields.add(f);
        s.setFields(fields);
      }
      // check that equals and hashcode are correct and complete in a
View Full Code Here

TOP

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

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.