Package org.apache.hadoop.hive.ql.io.sarg

Examples of org.apache.hadoop.hive.ql.io.sarg.SearchArgument$Factory


        "expr = (and (not leaf-0) (not leaf-1) (not leaf-2) (not leaf-3))", sarg.toString());
  }

  @Test
  public void testBuilderComplexTypes() throws Exception {
    SearchArgument sarg =
        SearchArgumentFactory.newBuilder()
            .startAnd()
              .lessThan("x", new DateWritable(10))
              .lessThanEquals("y", new HiveChar("hi", 10))
              .equals("z", HiveDecimal.create("1.0"))
            .end()
            .build();
    assertEquals("leaf-0 = (LESS_THAN x 1970-01-11)\n" +
        "leaf-1 = (LESS_THAN_EQUALS y hi)\n" +
        "leaf-2 = (EQUALS z 1)\n" +
        "expr = (and leaf-0 leaf-1 leaf-2)", sarg.toString());

    sarg = SearchArgumentFactory.newBuilder()
        .startNot()
           .startOr()
             .isNull("x")
             .between("y", HiveDecimal.create(10), 20.0)
             .in("z", (byte)1, (short)2, (int)3)
             .nullSafeEquals("a", new HiveVarchar("stinger", 100))
           .end()
        .end()
        .build();
    assertEquals("leaf-0 = (IS_NULL x)\n" +
        "leaf-1 = (BETWEEN y 10 20.0)\n" +
        "leaf-2 = (IN z 1 2 3)\n" +
        "leaf-3 = (NULL_SAFE_EQUALS a stinger)\n" +
        "expr = (and (not leaf-0) (not leaf-1) (not leaf-2) (not leaf-3))", sarg.toString());
  }
View Full Code Here


        "expr = (and (not leaf-0) (not leaf-1) (not leaf-2) (not leaf-3))", sarg.toString());
  }

  @Test
  public void testBuilderComplexTypes2() throws Exception {
    SearchArgument sarg =
        SearchArgumentFactory.newBuilder()
            .startAnd()
            .lessThan("x", new DateWritable(10))
            .lessThanEquals("y", new HiveChar("hi", 10))
            .equals("z", new BigDecimal("1.0"))
            .end()
            .build();
    assertEquals("leaf-0 = (LESS_THAN x 1970-01-11)\n" +
        "leaf-1 = (LESS_THAN_EQUALS y hi)\n" +
        "leaf-2 = (EQUALS z 1.0)\n" +
        "expr = (and leaf-0 leaf-1 leaf-2)", sarg.toString());

    sarg = SearchArgumentFactory.newBuilder()
        .startNot()
        .startOr()
        .isNull("x")
        .between("y", new BigDecimal(10), 20.0)
        .in("z", (byte)1, (short)2, (int)3)
        .nullSafeEquals("a", new HiveVarchar("stinger", 100))
        .end()
        .end()
        .build();
    assertEquals("leaf-0 = (IS_NULL x)\n" +
        "leaf-1 = (BETWEEN y 10 20.0)\n" +
        "leaf-2 = (IN z 1 2 3)\n" +
        "leaf-3 = (NULL_SAFE_EQUALS a stinger)\n" +
        "expr = (and (not leaf-0) (not leaf-1) (not leaf-2) (not leaf-3))", sarg.toString());
  }
View Full Code Here

        "expr = (and (not leaf-0) (not leaf-1) (not leaf-2) (not leaf-3))", sarg.toString());
  }

  @Test
  public void testBuilderFloat() throws Exception {
    SearchArgument sarg =
        SearchArgumentFactory.newBuilder()
            .startAnd()
            .lessThan("x", new Short((short) 22))
            .lessThan("x1", new Integer(22))
            .lessThanEquals("y", new HiveChar("hi", 10))
            .equals("z", new Float("0.22"))
            .equals("z1", new Double(0.22))
            .end()
            .build();
    assertEquals("leaf-0 = (LESS_THAN x 22)\n" +
        "leaf-1 = (LESS_THAN x1 22)\n" +
        "leaf-2 = (LESS_THAN_EQUALS y hi)\n" +
        "leaf-3 = (EQUALS z 0.22)\n" +
        "leaf-4 = (EQUALS z1 0.22)\n" +
        "expr = (and leaf-0 leaf-1 leaf-2 leaf-3 leaf-4)", sarg.toString());
  }
View Full Code Here

    types.add(builder.build());
    builder.clear().setKind(OrcProto.Type.Kind.INT);
    types.add(builder.build());
    types.add(builder.build());
    types.add(builder.build());
    SearchArgument isNull = SearchArgumentFactory.newBuilder()
        .startAnd().isNull("cost").end().build();
    conf.set(OrcInputFormat.SARG_PUSHDOWN, isNull.toKryo());
    conf.set(ColumnProjectionUtils.READ_COLUMN_NAMES_CONF_STR,
        "url,cost");
    options.include(new boolean[]{true, true, false, true, false});
    OrcInputFormat.setSearchArgument(options, types, conf, false);
    String[] colNames = options.getColumnNames();
    assertEquals(null, colNames[0]);
    assertEquals("url", colNames[1]);
    assertEquals(null, colNames[2]);
    assertEquals("cost", colNames[3]);
    assertEquals(null, colNames[4]);
    SearchArgument arg = options.getSearchArgument();
    List<PredicateLeaf> leaves = arg.getLeaves();
    assertEquals("cost", leaves.get(0).getColumnName());
    assertEquals(PredicateLeaf.Operator.IS_NULL, leaves.get(0).getOperator());
  }
View Full Code Here

        serde.serialize(new NestedRow(4,5,6), inspector));
    writer.write(NullWritable.get(),
        serde.serialize(new NestedRow(7,8,9), inspector));
    writer.close(Reporter.NULL);
    serde = new OrcSerde();
    SearchArgument sarg =
        SearchArgumentFactory.newBuilder()
            .startAnd()
            .lessThan("z", new Integer(0))
            .end()
            .build();
    conf.set("sarg.pushdown", sarg.toKryo());
    conf.set("hive.io.file.readcolumn.names", "z,r");
    properties.setProperty("columns", "z,r");
    properties.setProperty("columns.types", "int:struct<x:int,y:int>");
    SerDeUtils.initializeSerDe(serde, conf, properties, null);
    inspector = (StructObjectInspector) serde.getObjectInspector();
View Full Code Here

        serde.serialize(new SimpleRow(null), inspector));
    writer.write(NullWritable.get(),
        serde.serialize(new SimpleRow(null), inspector));
    writer.close(Reporter.NULL);
    serde = new OrcSerde();
    SearchArgument sarg =
        SearchArgumentFactory.newBuilder()
            .startAnd()
            .lessThan("z", new String("foo"))
            .end()
            .build();
    conf.set("sarg.pushdown", sarg.toKryo());
    conf.set("hive.io.file.readcolumn.names", "z");
    properties.setProperty("columns", "z");
    properties.setProperty("columns.types", "string");
    SerDeUtils.initializeSerDe(serde, conf, properties, null);
    inspector = (StructObjectInspector) serde.getObjectInspector();
View Full Code Here

    writer.close();
    Reader reader = OrcFile.createReader(testFilePath,
        OrcFile.readerOptions(conf).filesystem(fs));
    assertEquals(3500, reader.getNumberOfRows());

    SearchArgument sarg = SearchArgumentFactory.newBuilder()
        .startAnd()
          .startNot()
             .lessThan("int1", 300000)
          .end()
          .lessThan("int1", 600000)
View Full Code Here

    if ((sargPushdown == null && serializedPushdown == null)
        || columnNamesString == null) {
      LOG.debug("No ORC pushdown predicate");
      options.searchArgument(null, null);
    } else {
      SearchArgument sarg;
      if (serializedPushdown != null) {
        sarg = SearchArgument.FACTORY.create
            (Utilities.deserializeExpression(serializedPushdown));
      } else {
        sarg = SearchArgument.FACTORY.create(sargPushdown);
View Full Code Here

        if (deltas.isEmpty()) {
          Reader.Options options = new Reader.Options();
          setIncludedColumns(options, types, context.conf, isOriginal);
          setSearchArgument(options, types, context.conf, isOriginal);
          if (options.getSearchArgument() != null) {
            SearchArgument sarg = options.getSearchArgument();
            List<PredicateLeaf> sargLeaves = sarg.getLeaves();
            List<StripeStatistics> stripeStats = metadata.getStripeStatistics();
            int[] filterColumns = RecordReaderImpl.mapSargColumns(sargLeaves,
                options.getColumnNames(), getRootColumn(isOriginal));

            if (stripeStats != null) {
View Full Code Here

                    long offset, long length) throws IOException {
      String serializedPushdown = conf.get(TableScanDesc.FILTER_EXPR_CONF_STR);
      String columnNamesString =
          conf.get(ColumnProjectionUtils.READ_COLUMN_NAMES_CONF_STR);
      String[] columnNames = null;
      SearchArgument sarg = null;
      List<OrcProto.Type> types = file.getTypes();
      if (types.size() == 0) {
        numColumns = 0;
      } else {
        numColumns = types.get(0).getSubtypesCount();
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.io.sarg.SearchArgument$Factory

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.