Package org.apache.drill.exec.record

Examples of org.apache.drill.exec.record.RecordBatchLoader


    int batchCount = 0;

    for (QueryResultBatch b : results) {
      if (b.getHeader().getRowCount() == 0) break;
      batchCount++;
      RecordBatchLoader loader = new RecordBatchLoader(allocator);
      loader.load(b.getHeader().getDef(),b.getData());
      BigIntVector c1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class,
              loader.getValueVectorId(new SchemaPath("blue", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();


      BigIntVector.Accessor a1 = c1.getAccessor();

      for(int i =0; i < c1.getAccessor().getValueCount(); i++){
        recordCount++;
        assertTrue(String.format("%d > %d", previousBigInt, a1.get(i)), previousBigInt >= a1.get(i));
        previousBigInt = a1.get(i);
      }
      loader.clear();
      b.release();
    }

    System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount));
  }
View Full Code Here


    int batchCount = 0;

    for (QueryResultBatch b : results) {
      if (b.getHeader().getRowCount() == 0) break;
      batchCount++;
      RecordBatchLoader loader = new RecordBatchLoader(allocator);
      loader.load(b.getHeader().getDef(),b.getData());
      BigIntVector c1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class, loader.getValueVectorId(new SchemaPath("blue", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();


      BigIntVector.Accessor a1 = c1.getAccessor();

      for(int i =0; i < c1.getAccessor().getValueCount(); i++){
        recordCount++;
        assertTrue(String.format("%d > %d", previousBigInt, a1.get(i)), previousBigInt >= a1.get(i));
        previousBigInt = a1.get(i);
      }
      loader.clear();
      b.release();
    }

    System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount));
  }
View Full Code Here

      int batchCount = 0;

      for (QueryResultBatch b : results) {
        if (b.getHeader().getRowCount() == 0) break;
        batchCount++;
        RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
        loader.load(b.getHeader().getDef(),b.getData());
        BigIntVector c1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class, loader.getValueVectorId(new SchemaPath("blue", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();


        BigIntVector.Accessor a1 = c1.getAccessor();

        for(int i =0; i < c1.getAccessor().getValueCount(); i++){
          recordCount++;
          assertTrue(String.format("%d < %d", previousBigInt, a1.get(i)), previousBigInt >= a1.get(i));
          previousBigInt = a1.get(i);
        }
        loader.clear();
        b.release();
      }

      System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount));
View Full Code Here

      int batchCount = 0;

      for (QueryResultBatch b : results) {
        if (b.getHeader().getRowCount() == 0) break;
        batchCount++;
        RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
        loader.load(b.getHeader().getDef(),b.getData());
        BigIntVector c1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class, loader.getValueVectorId(new SchemaPath("blue", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();


        BigIntVector.Accessor a1 = c1.getAccessor();

        for(int i =0; i < c1.getAccessor().getValueCount(); i++){
          recordCount++;
          assertTrue(String.format("%d < %d", previousBigInt, a1.get(i)), previousBigInt >= a1.get(i));
          previousBigInt = a1.get(i);
        }
        assertTrue(String.format("%d == %d", a1.get(0), a1.get(a1.getValueCount() - 1)), a1.get(0) != a1.get(a1.getValueCount() - 1));
        loader.clear();
        b.release();
      }

      System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount));
View Full Code Here

  }

  public List<Map<String, Object>> run(DrillConfig config, ClusterCoordinator coordinator, BufferAllocator allocator)
    throws Exception {
    DrillClient client = new DrillClient(config, coordinator, allocator);
    Listener listener = new Listener(new RecordBatchLoader(allocator));

    client.connect();
    client.runQuery(getType(), query, listener);

    List<Map<String, Object>> result = listener.waitForCompletion();
View Full Code Here

      List<Integer> partitionRecordCounts = Lists.newArrayList();
      for(QueryResultBatch b : results) {
        if (b.getData() != null) {
          int rows = b.getHeader().getRowCount();
          count += rows;
          RecordBatchLoader loader = new RecordBatchLoader(new BootStrapContext(DrillConfig.create()).getAllocator());
          loader.load(b.getHeader().getDef(), b.getData());
          BigIntVector vv1 = (BigIntVector)loader.getValueAccessorById(BigIntVector.class, loader.getValueVectorId(
                  new SchemaPath("col1", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();
          Float8Vector vv2 = (Float8Vector)loader.getValueAccessorById(Float8Vector.class, loader.getValueVectorId(
                  new SchemaPath("col2", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();
          IntVector pVector = (IntVector)loader.getValueAccessorById(IntVector.class, loader.getValueVectorId(
                  new SchemaPath("partition", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();
          long previous1 = Long.MIN_VALUE;
          double previous2 = Double.MIN_VALUE;
          int partPrevious = -1;
          long current1 = Long.MIN_VALUE;
          double current2 = Double.MIN_VALUE;
          int partCurrent = -1;
          int partitionRecordCount = 0;
          for (int i = 0; i < rows; i++) {
            previous1 = current1;
            previous2 = current2;
            partPrevious = partCurrent;
            current1 = vv1.getAccessor().get(i);
            current2 = vv2.getAccessor().get(i);
            partCurrent = pVector.getAccessor().get(i);
            Assert.assertTrue(current1 >= previous1);
            if (current1 == previous1) {
              Assert.assertTrue(current2 <= previous2);
            }
            if (partCurrent == partPrevious || partPrevious == -1) {
              partitionRecordCount++;
            } else {
              partitionRecordCounts.add(partitionRecordCount);
              partitionRecordCount = 0;
            }
          }
          partitionRecordCounts.add(partitionRecordCount);
          loader.clear();
        }

        b.release();
      }
      double[] values = new double[partitionRecordCounts.size()];
View Full Code Here

      int batchCount = 0;

      for (QueryResultBatch b : results) {
        if (b.getHeader().getRowCount() == 0) break;
        batchCount++;
        RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
        loader.load(b.getHeader().getDef(),b.getData());
        BigIntVector c1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class, loader.getValueVectorId(new SchemaPath("blue", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();


        BigIntVector.Accessor a1 = c1.getAccessor();
//        IntVector.Accessor a2 = c2.getAccessor();

        for(int i =0; i < c1.getAccessor().getValueCount(); i++){
          recordCount++;
          assertTrue(previousBigInt <= a1.get(i));
          previousBigInt = a1.get(i);
        }
        loader.clear();
        b.release();
      }

      System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount));
View Full Code Here

  volatile Exception exception;
  QueryId queryId;

  public PrintingResultsListener(DrillConfig config, Format format, int columnWidth) {
    this.allocator = new TopLevelAllocator(config);
    loader = new RecordBatchLoader(allocator);
    this.format = format;
    this.columnWidth = columnWidth;
  }
View Full Code Here

          QueryType.PHYSICAL,
          Files.toString(FileUtils.getResourceAsFile(physicalPlan),
              Charsets.UTF_8).replace("#{TEST_FILE}",
              inputDataFile));

      RecordBatchLoader batchLoader = new RecordBatchLoader(bit
          .getContext().getAllocator());

      QueryResultBatch batch = results.get(0);
      assertTrue(batchLoader.load(batch.getHeader().getDef(),
          batch.getData()));

      int i = 0;
      for (VectorWrapper<?> v : batchLoader) {
        ValueVector.Accessor accessor = v.getValueVector().getAccessor();
        System.out.println((accessor.getObject(0)));
        assertEquals(expected[i++], (accessor.getObject(0)));
      }

      batchLoader.clear();
      for (QueryResultBatch b : results) {
        b.release();
      }
    }
  }
View Full Code Here

            client.connect();
            List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL,
                    Files.toString(FileUtils.getResourceAsFile(physicalPlan), Charsets.UTF_8)
                            .replace("#{TEST_FILE}", resourceFile));

            RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());

            QueryResultBatch batch = results.get(0);
            assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));


            int i = 0;
            for (VectorWrapper<?> v : batchLoader) {

                ValueVector.Accessor accessor = v.getValueVector().getAccessor();
                System.out.println(accessor.getObject(0));
                assertEquals( expectedResults[i++], accessor.getObject(0).toString());
            }

            batchLoader.clear();
            for(QueryResultBatch b : results){
                b.release();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.record.RecordBatchLoader

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.