Package org.apache.avro.util

Examples of org.apache.avro.util.Utf8


    }
    HandshakeRequest handshake = new HandshakeRequest();
    handshake.clientHash = localHash;
    handshake.serverHash = remoteHash;
    if (sendLocalText)
      handshake.clientProtocol = new Utf8(local.toString());
   
    RPCContext context = new RPCContext();
    context.setHandshakeRequest(handshake);
    for (RPCPlugin plugin : rpcMetaPlugins) {
      plugin.clientStartConnect(context);
View Full Code Here


    }

    public Object respond (Protocol.Message message, Object request) {
      String msgName = message.getName();
      if (msgName == "xyz") {
        return new Utf8("The java responder greets you.");
      } else {
        throw new AvroRuntimeException("unexcepcted message: " + msgName);
      }
    }
View Full Code Here

    HttpTransceiver transceiver = new HttpTransceiver(new URL("http://localhost:8080"));
    GenericRequestor requestor = new GenericRequestor(protocol, transceiver);

    GenericData.Record message = new GenericData.Record(protocol.getType("Message"));
    message.put("data", new Utf8("Hello from Client"));

    Schema schema = protocol.getMessages().get("xyz").getRequest();
    GenericData.Record request = new GenericData.Record(schema);
    request.put("message", message);
View Full Code Here

  }

  @Override
  public Object eval(EventWrapper event, Object... args) {
    Event e = event.getEvent();
    return new Utf8(e.getPriority().toString());
  }
View Full Code Here

    EventParser parser = new RegexEventParser(properties);
    parser.reset(event);

    CharSequence field1 = (CharSequence) parser.getColumn(0,
        Type.getPrimitive(Type.TypeName.STRING));
    assertEquals(new Utf8("foo"), field1);

    Integer field2 = (Integer) parser.getColumn(1, Type.getPrimitive(Type.TypeName.INT));
    assertEquals(Integer.valueOf(42), field2);

    CharSequence field3 = (CharSequence) parser.getColumn(2,
        Type.getPrimitive(Type.TypeName.STRING));
    assertEquals(new Utf8("this is a lovely record"), field3);
  }
View Full Code Here

    int result2 = (Integer) ep.getColumn(0, Type.getPrimitive(Type.TypeName.INT));
    assertEquals(42, result2);

    // Reset this onto another instance.
    ep.reset(makeEvent("meep"));
    Utf8 strResult = (Utf8) ep.getColumn(0, Type.getPrimitive(Type.TypeName.STRING));
    assertEquals(new Utf8("meep"), strResult);

    try {
      Object unexpectedResult = ep.getColumn(1, Type.getPrimitive(Type.TypeName.STRING));
      LOG.info("Got unexpected result: " + unexpectedResult);
      fail("Expected error retrieving missing column");
View Full Code Here

      int result = (Integer) ep.getColumn(col, Type.getPrimitive(Type.TypeName.INT));
      LOG.info("Column col=" + col + "; result=" + result);
      assertEquals(8 - i, result);
    }

    Utf8 s;

    // In-order parsing with strings.
    ep.reset(makeEvent("bar,quux"));
    s = (Utf8) ep.getColumn(0, Type.getPrimitive(Type.TypeName.STRING));
    assertEquals(new Utf8("bar"), s);
    s = (Utf8) ep.getColumn(1, Type.getPrimitive(Type.TypeName.STRING));
    assertEquals(new Utf8("quux"), s);

    // Go backward with strings.
    ep.reset(makeEvent("meep,foo"));
    s = (Utf8) ep.getColumn(1, Type.getPrimitive(Type.TypeName.STRING));
    assertEquals(new Utf8("foo"), s);
    s = (Utf8) ep.getColumn(0, Type.getPrimitive(Type.TypeName.STRING));
    assertEquals(new Utf8("meep"), s);

    // Ask for a column that does not exist; then go back and ask for one that does.
    ep.reset(makeEvent("1,2,3"));
    try {
      ep.getColumn(4, Type.getPrimitive(Type.TypeName.STRING));
View Full Code Here

  }

  @Override
  public Object eval(EventWrapper event, Object... args) {
    Event e = event.getEvent();
    return new Utf8(e.getHost());
  }
View Full Code Here

    Object arg0 = args[0];
    if (null == arg0) {
      return null;
    } else {
      ByteBuffer bytes = (ByteBuffer) arg0;
      return new Utf8(new String(bytes.array(), bytes.position(), bytes.remaining(),
            UTF8_CHARSET));
    }
  }
View Full Code Here

      for(GenericData.Record r : outRecords) {
        LOG.debug("gotgot " + r.get("x"));
      }

      this.assertRecordExists(outRecords, "x", new Utf8("line1"));
      this.assertRecordExists(outRecords, "x", new Utf8("line2"));
      this.assertRecordExists(outRecords, "x", new Utf8("line3"));
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.avro.util.Utf8

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.