首页 > 解决方案 > 为什么 Apache Orc RecordReader.searchArgument() 没有成功?

问题描述

读的时候设置的谓词下推了,但是从打印结果看好像不行,全部打印出来了,不是我想要的

我参考了下面的解决方案,但是没有解决办法 在这里输入链接描述为什么?

谢谢你!

public class parseOrcFile {

    public static void main(String[] args) {
        Configuration conf = new Configuration();
        try {
            String file_path = "/apps/hive/warehouse/orc_stu/test.orc";
            ReaderOptions readerOptions = OrcFile.readerOptions(conf);
            Path path = new Path(file_path);
            Reader reader = OrcFile.createReader(path, readerOptions);
            List<StripeInformation> sis = reader.getStripes();
            TypeDescription schema = reader.getSchema();
            SearchArgument sarg = SearchArgumentFactory.newBuilder()
                        .startNot()
                        .lessThan("id", PredicateLeaf.Type.LONG, 100L)
                        .end()
                        .startAnd()
                        .lessThan("id", PredicateLeaf.Type.LONG, 200L)
                        .end()
                        .build();

            Reader.Options opt = reader.options()
                        .schema(schema)
                        .include(new boolean[]{true, true, true, true, true})
                        .searchArgument(sarg, new String[]{null, "id", "name", "age", "sex"});

            RecordReader read_row_opt = reader.rows(opt);
            VectorizedRowBatch rowBatch = schema.createRowBatch();
            while (read_row_opt.nextBatch(rowBatch)) {
                System.out.println(rowBatch.toString());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

标签: java

解决方案


SearchArgument仅过滤文件、条带、行组。它不会过滤行组中的行。


推荐阅读