Package com.odiago.flumebase.testutil

Examples of com.odiago.flumebase.testutil.MemStreamBuilder


  public void testSelectOneCol() throws IOException, InterruptedException {
    // Given three input records with a single column, select the column
    // and get the same result back.

    // Create the stream, and put some records in it.
    MemStreamBuilder streamBuilder = new MemStreamBuilder("memstream");

    streamBuilder.addField(new TypedField("fieldname", Type.getPrimitive(Type.TypeName.INT)));
    streamBuilder.addEvent("1");
    streamBuilder.addEvent("2");
    streamBuilder.addEvent("3");
    StreamSymbol stream = streamBuilder.build();
    getSymbolTable().addSymbol(stream);

    getConf().set(SelectStmt.CLIENT_SELECT_TARGET_KEY, "testSelect");

    // With all configuration complete, connect to the environment.
View Full Code Here


  public void testSelectNoRecords() throws IOException, InterruptedException {
    // Populate a stream with no records, make sure a SELECT statement on
    // this empty data set is okay.

    // Create the stream, and put some records in it.
    MemStreamBuilder streamBuilder = new MemStreamBuilder("memstream");

    streamBuilder.addField(new TypedField("fieldname", Type.getPrimitive(Type.TypeName.INT)));
    StreamSymbol stream = streamBuilder.build();
    getSymbolTable().addSymbol(stream);

    getConf().set(SelectStmt.CLIENT_SELECT_TARGET_KEY, "testSelect");

    // With all configuration complete, connect to the environment.
View Full Code Here

   * output dataset.
   */
  private void runTwoFieldTest(String streamName, String leftFieldName, String rightFieldName,
      String query, boolean checkLeft, boolean checkRight)
      throws IOException, InterruptedException {
    MemStreamBuilder streamBuilder = new MemStreamBuilder(streamName);

    streamBuilder.addField(new TypedField(leftFieldName, Type.getPrimitive(Type.TypeName.INT)));
    streamBuilder.addField(new TypedField(rightFieldName, Type.getPrimitive(Type.TypeName.INT)));
    streamBuilder.addEvent("1,-1");
    streamBuilder.addEvent("2,-2");
    streamBuilder.addEvent("3,-3");
    StreamSymbol stream = streamBuilder.build();
    getSymbolTable().addSymbol(stream);

    getConf().set(SelectStmt.CLIENT_SELECT_TARGET_KEY, "testSelect");

    // With all configuration complete, connect to the environment.
View Full Code Here

   * its value to verify.
   */
  private void runFreeSelectTest(String streamName, String leftFieldName, String rightFieldName,
      String query, List<Pair<String, Object>> checkFields)
      throws IOException, InterruptedException {
    MemStreamBuilder streamBuilder = new MemStreamBuilder(streamName);

    streamBuilder.addField(new TypedField(leftFieldName, Type.getPrimitive(Type.TypeName.INT)));
    streamBuilder.addField(new TypedField(rightFieldName, Type.getNullable(Type.TypeName.INT)));
    streamBuilder.addEvent("1,2");
    StreamSymbol stream = streamBuilder.build();

    runFreeSelectTest(stream, query, checkFields);
  }
View Full Code Here

   */
  private void runDelimiterTest(Type leftType, Type rightType, String delimStr,
      String nullStr, List<String> inputs, String query, List<Pair<String, Object>> checks)
      throws IOException, InterruptedException {

    MemStreamBuilder streamBuilder = new MemStreamBuilder("memstream");
    streamBuilder.addField(new TypedField("a", leftType));
    streamBuilder.addField(new TypedField("b", rightType));
    for (String input : inputs) {
      streamBuilder.addEvent(input);
    }
    FormatSpec formatSpec = new FormatSpec();
    formatSpec.setFormat(FormatSpec.DEFAULT_FORMAT_NAME);
    formatSpec.setParam(DelimitedEventParser.DELIMITER_PARAM, delimStr);
    formatSpec.setParam(DelimitedEventParser.NULL_STR_PARAM, nullStr);
    streamBuilder.setFormat(formatSpec);
    StreamSymbol stream = streamBuilder.build();

    getSymbolTable().addSymbol(stream);
    getConf().set(SelectStmt.CLIENT_SELECT_TARGET_KEY, "testSelect");

    // Connect to the environment and run it.
View Full Code Here

   * Run a test for PRECISE(1) types.
   * This runs a test on a stream named 'f' with one column 'x', of type PRECISE(1).
   */
  private void runPreciseTest(List<String> eventStrings, String query, String outColName,
      List<String> outStrings) throws IOException, InterruptedException {
    MemStreamBuilder streamBuilder = new MemStreamBuilder("f");

    streamBuilder.addField(new TypedField("x", new PreciseType(1)));
    for (String eventStr : eventStrings) {
      streamBuilder.addEvent(eventStr);
    }
    StreamSymbol stream = streamBuilder.build();
    getSymbolTable().addSymbol(stream);

    getConf().set(SelectStmt.CLIENT_SELECT_TARGET_KEY, "testSelect");

    // With all configuration complete, connect to the environment.
View Full Code Here

  @Test
  public void testPriorityAttr() throws IOException, InterruptedException {
    // Test that the priority() function to access event priority works.

    MemStreamBuilder streamBuilder = new MemStreamBuilder("s");

    streamBuilder.addField(new TypedField("a", Type.getNullable(Type.TypeName.INT)));
    streamBuilder.addEvent("1");
    StreamSymbol stream = streamBuilder.build();

    runFreeSelectTest(stream, "SELECT priority() AS p FROM s",
        Collections.singletonList(new Pair<String, Object>("p", new Utf8("INFO"))));
  }
View Full Code Here

        Collections.singletonList(new Pair<String, Object>("p", new Utf8("INFO"))));
  }

  @Test
  public void testUserAttr() throws IOException, InterruptedException {
    MemStreamBuilder streamBuilder = new MemStreamBuilder("s");

    // Select a user-attached "attribute" of the stream.

    streamBuilder.addField(new TypedField("a", Type.getNullable(Type.TypeName.INT)));
    Event e = new EventImpl("1".getBytes());
    e.set("attr", "val".getBytes());
    streamBuilder.addEvent(e);
    StreamSymbol stream = streamBuilder.build();

    runFreeSelectTest(stream, "SELECT #attr AS a  FROM s",
        Collections.singletonList(new Pair<String, Object>(
        "a", ByteBuffer.wrap("val".getBytes()))));
  }
View Full Code Here

        "a", ByteBuffer.wrap("val".getBytes()))));
  }

  @Test
  public void testUserAttrToStr() throws IOException, InterruptedException {
    MemStreamBuilder streamBuilder = new MemStreamBuilder("s");

    // Select a user-attached "attribute" of the stream and convert it to
    // a string.

    streamBuilder.addField(new TypedField("f", Type.getNullable(Type.TypeName.INT)));
    Event e = new EventImpl("1".getBytes());
    e.set("attr", "val".getBytes());
    streamBuilder.addEvent(e);
    StreamSymbol stream = streamBuilder.build();

    runFreeSelectTest(stream, "SELECT bin2str(#attr) AS a  FROM s",
        Collections.singletonList(new Pair<String, Object>(
        "a", new Utf8("val"))));
  }
View Full Code Here

        "a", new Utf8("val"))));
  }

  @Test
  public void testMissingUserAttr() throws IOException, InterruptedException {
    MemStreamBuilder streamBuilder = new MemStreamBuilder("s");

    // Select a (missing) user-attached "attribute" of the stream, verify
    // we get null back.

    streamBuilder.addField(new TypedField("a", Type.getNullable(Type.TypeName.INT)));
    Event e = new EventImpl("1".getBytes());
    e.set("attr", "val".getBytes());
    streamBuilder.addEvent(e);
    StreamSymbol stream = streamBuilder.build();

    runFreeSelectTest(stream, "SELECT #attr2 AS a  FROM s",
        Collections.singletonList(new Pair<String, Object>(
        "a", null)));
  }
View Full Code Here

TOP

Related Classes of com.odiago.flumebase.testutil.MemStreamBuilder

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.