Package com.odiago.flumebase.testutil

Examples of com.odiago.flumebase.testutil.MemStreamBuilder


  }

  // The next few tests are for comparison of BINARY fields.
  @Test
  public void testBinaryComparison1() throws IOException, InterruptedException {
    MemStreamBuilder streamBuilder = new MemStreamBuilder("s");

    streamBuilder.addField(new TypedField("a", Type.getNullable(Type.TypeName.BINARY)));
    streamBuilder.addField(new TypedField("b", Type.getNullable(Type.TypeName.BINARY)));
    Event e = new EventImpl("abc,abc".getBytes());
    streamBuilder.addEvent(e);
    StreamSymbol stream = streamBuilder.build();

    runFreeSelectTest(stream, "SELECT a = b AS v FROM s",
        Collections.singletonList(new Pair<String, Object>(
        "v", Boolean.TRUE)));
  }
View Full Code Here


        "v", Boolean.TRUE)));
  }

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

    streamBuilder.addField(new TypedField("a", Type.getNullable(Type.TypeName.BINARY)));
    streamBuilder.addField(new TypedField("b", Type.getNullable(Type.TypeName.BINARY)));
    Event e = new EventImpl("abc,abc".getBytes());
    streamBuilder.addEvent(e);
    StreamSymbol stream = streamBuilder.build();

    runFreeSelectTest(stream, "SELECT a < b AS v FROM s",
        Collections.singletonList(new Pair<String, Object>(
        "v", Boolean.FALSE)));
  }
View Full Code Here

        "v", Boolean.FALSE)));
  }

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

    streamBuilder.addField(new TypedField("a", Type.getNullable(Type.TypeName.BINARY)));
    streamBuilder.addField(new TypedField("b", Type.getNullable(Type.TypeName.BINARY)));
    Event e = new EventImpl("abc,azz".getBytes());
    streamBuilder.addEvent(e);
    StreamSymbol stream = streamBuilder.build();

    runFreeSelectTest(stream, "SELECT a < b AS v FROM s",
        Collections.singletonList(new Pair<String, Object>(
        "v", Boolean.TRUE)));
  }
View Full Code Here

        "v", Boolean.TRUE)));
  }

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

    streamBuilder.addField(new TypedField("a", Type.getNullable(Type.TypeName.BINARY)));
    streamBuilder.addField(new TypedField("b", Type.getNullable(Type.TypeName.BINARY)));
    Event e = new EventImpl("abc,azz".getBytes());
    streamBuilder.addEvent(e);
    StreamSymbol stream = streamBuilder.build();

    runFreeSelectTest(stream, "SELECT a > b AS v FROM s",
        Collections.singletonList(new Pair<String, Object>(
        "v", Boolean.FALSE)));
  }
View Full Code Here

        "v", Boolean.FALSE)));
  }

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

    streamBuilder.addField(new TypedField("a",
        new NullableType(new ListType(Type.getPrimitive(Type.TypeName.INT)))));
    streamBuilder.addField(new TypedField("b", Type.getNullable(Type.TypeName.INT)));
    Event e = new EventImpl("1|2|3,4".getBytes());
    streamBuilder.addEvent(e);
    StreamSymbol stream = streamBuilder.build();

    List<Pair<String, Object>> checks = new ArrayList<Pair<String, Object>>();
    List<Object> innerList = new ArrayList<Object>();
    innerList.add(Integer.valueOf(1));
    innerList.add(Integer.valueOf(2));
View Full Code Here

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

    streamBuilder.addField(new TypedField("a", Type.getPrimitive(Type.TypeName.INT)));
    streamBuilder.addField(new TypedField("b", Type.getNullable(Type.TypeName.INT)));
    streamBuilder.addEvent("1,2");
    streamBuilder.addEvent("3,4");
    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

   * Create a stream with two columns which have configurable names. The first column
   * is of type "INT NOT NULL," the second column is of type "INT".
   */
  private StreamSymbol makeStream(String streamName, String leftColName,
      String rightColName, String [] eventTexts, long [] eventTimestamps) {
    MemStreamBuilder streamBuilder = new MemStreamBuilder(streamName);
    streamBuilder.addField(new TypedField(leftColName, Type.getPrimitive(Type.TypeName.INT)));
    streamBuilder.addField(new TypedField(rightColName, Type.getNullable(Type.TypeName.INT)));

    for (int i = 0; i < eventTexts.length; i++) {
      streamBuilder.addEvent(eventTexts[i], eventTimestamps[i]);
    }

    return streamBuilder.build();
  }
View Full Code Here

   * Create a stream with two columns which have configurable names. The first column
   * is of type "INT NOT NULL," the second column is of type "INT".
   */
  private StreamSymbol makeStream(String streamName, String leftColName,
      String rightColName, String [] eventTexts, long [] eventTimestamps) {
    MemStreamBuilder streamBuilder = new MemStreamBuilder(streamName);
    streamBuilder.addField(new TypedField(leftColName, Type.getPrimitive(Type.TypeName.INT)));
    streamBuilder.addField(new TypedField(rightColName, Type.getNullable(Type.TypeName.INT)));

    for (int i = 0; i < eventTexts.length; i++) {
      streamBuilder.addEvent(eventTexts[i], eventTimestamps[i]);
    }

    return streamBuilder.build();
  }
View Full Code Here

  private void runThroughputTest(String query, int stringSize, int expectedRecordCount)
      throws IOException, InterruptedException {

    long initTimestamp = System.currentTimeMillis();

    MemStreamBuilder streamBuilder = new MemStreamBuilder(STREAM_NAME);
    long bytesSent = 0;

    StringBuilder sbStringCol = new StringBuilder();
    for (int i = 0; i < stringSize; i++) {
      sbStringCol.append("a");
    }

    String stringCol = sbStringCol.toString();

    streamBuilder.addField(new TypedField("a", Type.getPrimitive(Type.TypeName.INT)));
    streamBuilder.addField(new TypedField("b", Type.getNullable(Type.TypeName.INT)));
    streamBuilder.addField(new TypedField("c", Type.getNullable(Type.TypeName.STRING)));
    for (int i = 0; i < NUM_RECORDS; i++) {
      StringBuilder sb = new StringBuilder();
      sb.append(i);
      sb.append(",");
      int j = 10 * i;
      sb.append(j);
      sb.append(",");
      sb.append(stringCol);
      String eventText = sb.toString();
      streamBuilder.addEvent(eventText);
      bytesSent += eventText.length();
    }
    StreamSymbol stream = streamBuilder.build();
    getSymbolTable().addSymbol(stream);

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

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

   * its value to verify.
   */
  private void runFnTest(String query, List<Pair<String, Object>> checkFields)
      throws IOException, InterruptedException {
    LOG.info("Running function test: " + query);
    MemStreamBuilder streamBuilder = new MemStreamBuilder("memstream");

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

    // Register the 'max2' function we use in some tests.
    ScalarFunc max2Func = new max2();
    getSymbolTable().addSymbol(new FnSymbol("max2", max2Func, max2Func.getReturnType(),
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.