当前位置: 首页>>代码示例>>Java>>正文


Java SimpleRootExec.getValueVectorById方法代码示例

本文整理汇总了Java中org.apache.drill.exec.physical.impl.SimpleRootExec.getValueVectorById方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleRootExec.getValueVectorById方法的具体用法?Java SimpleRootExec.getValueVectorById怎么用?Java SimpleRootExec.getValueVectorById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.drill.exec.physical.impl.SimpleRootExec的用法示例。


在下文中一共展示了SimpleRootExec.getValueVectorById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: oneKeyAgg

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void oneKeyAgg(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
  final SimpleRootExec exec = doTest(bitContext, connection, "/agg/test1.json");

  while(exec.next()) {
    final BigIntVector cnt = exec.getValueVectorById(SchemaPath.getSimplePath("cnt"), BigIntVector.class);
    final IntVector key = exec.getValueVectorById(SchemaPath.getSimplePath("blue"), IntVector.class);
    final long[] cntArr = {10001, 9999};
    final int[] keyArr = {Integer.MIN_VALUE, Integer.MAX_VALUE};

    for(int i = 0; i < exec.getRecordCount(); i++) {
      assertEquals((Long) cntArr[i], cnt.getAccessor().getObject(i));
      assertEquals((Integer) keyArr[i], key.getAccessor().getObject(i));
    }
  }

  if(exec.getContext().getFailureCause() != null) {
    throw exec.getContext().getFailureCause();
  }
  assertTrue(!exec.getContext().isFailed());

}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:23,代码来源:TestAgg.java

示例2: testBasicMathFunctions

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void testBasicMathFunctions(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable
{
  new NonStrictExpectations() {{
    bitContext.getMetrics(); result = new MetricRegistry();
    bitContext.getAllocator(); result = RootAllocatorFactory.newRoot(c);
    bitContext.getConfig(); result = c;
    bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c);
    bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
  }};

  final PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
  final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/functions/simple_math_functions.json"), Charsets.UTF_8));
  final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
  final FragmentContext context = new FragmentContext(bitContext, BitControl.PlanFragment.getDefaultInstance(), connection, registry);
  final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

  while(exec.next()) {
    final IntVector intMulVector = exec.getValueVectorById(new SchemaPath("INTMUL", ExpressionPosition.UNKNOWN), IntVector.class);
    final Float8Vector floatMulVector = exec.getValueVectorById(new SchemaPath("FLOATMUL", ExpressionPosition.UNKNOWN), Float8Vector.class);
    final IntVector intAddVector = exec.getValueVectorById(new SchemaPath("INTADD", ExpressionPosition.UNKNOWN), IntVector.class);
    final Float8Vector floatAddVector = exec.getValueVectorById(new SchemaPath("FLOATADD", ExpressionPosition.UNKNOWN), Float8Vector.class);
    assertEquals(exec.getRecordCount(), 1);
    assertEquals(intMulVector.getAccessor().get(0), 2);
    assertEquals(floatMulVector.getAccessor().get(0), (1.1 * 2.2), 0);
    assertEquals(intAddVector.getAccessor().get(0), 3);
    assertEquals(floatAddVector.getAccessor().get(0), (1.1 + 2.2), 0);
  }

  if(context.getFailureCause() != null) {
    throw context.getFailureCause();
  }
  assertTrue(!context.isFailed());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:35,代码来源:TestMathFunctions.java

示例3: project

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void project(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
  new NonStrictExpectations() {{
    bitContext.getMetrics(); result = new MetricRegistry();
    bitContext.getAllocator(); result = RootAllocatorFactory.newRoot(c);
    bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
    bitContext.getConfig(); result = c;
    bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c);
  }};

  final PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
  final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/project/test1.json"), Charsets.UTF_8));
  final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
  final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
  final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

  while (exec.next()) {
    VectorUtil.showVectorAccessibleContent(exec.getIncoming(), "\t");
    final NullableBigIntVector c1 = exec.getValueVectorById(new SchemaPath("col1", ExpressionPosition.UNKNOWN), NullableBigIntVector.class);
    final NullableBigIntVector c2 = exec.getValueVectorById(new SchemaPath("col2", ExpressionPosition.UNKNOWN), NullableBigIntVector.class);
    int x = 0;
    final NullableBigIntVector.Accessor a1 = c1.getAccessor();
    final NullableBigIntVector.Accessor a2 = c2.getAccessor();

    for (int i =0; i < c1.getAccessor().getValueCount(); i++) {
      if (!a1.isNull(i)) {
        assertEquals(a1.get(i)+1, a2.get(i));
      }
      x += a1.isNull(i) ? 0 : a1.get(i);
    }
  }

  if (context.getFailureCause() != null) {
    throw context.getFailureCause();
  }
  assertTrue(!context.isFailed());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:38,代码来源:TestSimpleProjection.java

示例4: twoKeyAgg

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
  public void twoKeyAgg(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
    SimpleRootExec exec = doTest(bitContext, connection, "/agg/twokey.json");

    while(exec.next()) {
      final IntVector key1 = exec.getValueVectorById(SchemaPath.getSimplePath("key1"), IntVector.class);
      final BigIntVector key2 = exec.getValueVectorById(SchemaPath.getSimplePath("key2"), BigIntVector.class);
      final BigIntVector cnt = exec.getValueVectorById(SchemaPath.getSimplePath("cnt"), BigIntVector.class);
      final NullableBigIntVector total = exec.getValueVectorById(SchemaPath.getSimplePath("total"), NullableBigIntVector.class);
      final Integer[] keyArr1 = {Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE};
      final long[] keyArr2 = {0,1,2,0,1,2};
      final long[] cntArr = {34,34,34,34,34,34};
      final long[] totalArr = {0,34,68,0,34,68};

      for(int i = 0; i < exec.getRecordCount(); i++) {
//        System.out.print(key1.getAccessor().getObject(i));
//        System.out.print("\t");
//        System.out.print(key2.getAccessor().getObject(i));
//        System.out.print("\t");
//        System.out.print(cnt.getAccessor().getObject(i));
//        System.out.print("\t");
//        System.out.print(total.getAccessor().getObject(i));
//        System.out.println();
        assertEquals((Long) cntArr[i], cnt.getAccessor().getObject(i));
        assertEquals(keyArr1[i], key1.getAccessor().getObject(i));
        assertEquals((Long) keyArr2[i], key2.getAccessor().getObject(i));
        assertEquals((Long) totalArr[i], total.getAccessor().getObject(i));
      }
    }

    if(exec.getContext().getFailureCause() != null){
      throw exec.getContext().getFailureCause();
    }
    assertTrue(!exec.getContext().isFailed());

  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:37,代码来源:TestAgg.java

示例5: testBasicMathFunctions

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void testBasicMathFunctions(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable
{
  mockDrillbitContext(bitContext);

  final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c);
  final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile("/functions/simple_math_functions.json"), Charsets.UTF_8));
  final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
  final FragmentContext context = new FragmentContext(bitContext, BitControl.PlanFragment.getDefaultInstance(), connection, registry);
  final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

  while(exec.next()) {
    final IntVector intMulVector = exec.getValueVectorById(new SchemaPath("INTMUL", ExpressionPosition.UNKNOWN), IntVector.class);
    final Float8Vector floatMulVector = exec.getValueVectorById(new SchemaPath("FLOATMUL", ExpressionPosition.UNKNOWN), Float8Vector.class);
    final IntVector intAddVector = exec.getValueVectorById(new SchemaPath("INTADD", ExpressionPosition.UNKNOWN), IntVector.class);
    final Float8Vector floatAddVector = exec.getValueVectorById(new SchemaPath("FLOATADD", ExpressionPosition.UNKNOWN), Float8Vector.class);
    assertEquals(exec.getRecordCount(), 1);
    assertEquals(intMulVector.getAccessor().get(0), 2);
    assertEquals(floatMulVector.getAccessor().get(0), (1.1 * 2.2), 0);
    assertEquals(intAddVector.getAccessor().get(0), 3);
    assertEquals(floatAddVector.getAccessor().get(0), (1.1 + 2.2), 0);
  }

  if(context.getFailureCause() != null) {
    throw context.getFailureCause();
  }
  assertTrue(!context.isFailed());
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:29,代码来源:TestMathFunctions.java

示例6: project

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void project(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
  mockDrillbitContext(bitContext);

  final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c);
  final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile("/project/test1.json"), Charsets.UTF_8));
  final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
  final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
  final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

  while (exec.next()) {
    VectorUtil.showVectorAccessibleContent(exec.getIncoming(), "\t");
    final NullableBigIntVector c1 = exec.getValueVectorById(new SchemaPath("col1", ExpressionPosition.UNKNOWN), NullableBigIntVector.class);
    final NullableBigIntVector c2 = exec.getValueVectorById(new SchemaPath("col2", ExpressionPosition.UNKNOWN), NullableBigIntVector.class);
    int x = 0;
    final NullableBigIntVector.Accessor a1 = c1.getAccessor();
    final NullableBigIntVector.Accessor a2 = c2.getAccessor();

    for (int i =0; i < c1.getAccessor().getValueCount(); i++) {
      if (!a1.isNull(i)) {
        assertEquals(a1.get(i)+1, a2.get(i));
      }
      x += a1.isNull(i) ? 0 : a1.get(i);
    }
  }

  if (context.getFailureCause() != null) {
    throw context.getFailureCause();
  }
  assertTrue(!context.isFailed());
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:32,代码来源:TestSimpleProjection.java

示例7: twoKeyAgg

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
  public void twoKeyAgg(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
    SimpleRootExec exec = doTest(bitContext, connection, "/agg/twokey.json");

    while(exec.next()) {
      final IntVector key1 = exec.getValueVectorById(SchemaPath.getSimplePath("key1"), IntVector.class);
      final BigIntVector key2 = exec.getValueVectorById(SchemaPath.getSimplePath("key2"), BigIntVector.class);
      final BigIntVector cnt = exec.getValueVectorById(SchemaPath.getSimplePath("cnt"), BigIntVector.class);
      final NullableBigIntVector total = exec.getValueVectorById(SchemaPath.getSimplePath("total"), NullableBigIntVector.class);
      final Integer[] keyArr1 = {Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE};
      final long[] keyArr2 = {0,1,2,0,1,2};
      final long[] cntArr = {34,34,34,34,34,34};
      final long[] totalArr = {0,34,68,0,34,68};

      for(int i = 0; i < exec.getRecordCount(); i++) {
//        System.out.print(key1.getAccessor().getObject(i));
//        System.out.print("\t");
//        System.out.print(key2.getAccessor().getObject(i));
//        System.out.print("\t");
//        System.out.print(cnt.getAccessor().getObject(i));
//        System.out.print("\t");
//        System.out.print(total.getAccessor().getObject(i));
//        System.out.println();
        assertEquals((Long) cntArr[i], cnt.getAccessor().getObject(i));
        assertEquals(keyArr1[i], key1.getAccessor().getObject(i));
        assertEquals((Long) keyArr2[i], key2.getAccessor().getObject(i));
        assertEquals((Long) totalArr[i], total.getAccessor().getObject(i));
      }
    }

    if(exec.getContext().getFailureCause() != null){
      throw exec.getContext().getFailureCause();
    }
    assertTrue(!exec.getContext().isFailed());
  }
 
开发者ID:axbaretto,项目名称:drill,代码行数:36,代码来源:TestAgg.java

示例8: sortOneKeyAscending

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void sortOneKeyAscending(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
  mockDrillbitContext(bitContext);

  final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c);
  final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile("/sort/one_key_sort.json"), Charsets.UTF_8));
  final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
  final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
  final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

  int previousInt = Integer.MIN_VALUE;
  int recordCount = 0;
  int batchCount = 0;

  while(exec.next()) {
    batchCount++;
    final IntVector c1 = exec.getValueVectorById(new SchemaPath("blue", ExpressionPosition.UNKNOWN), IntVector.class);
    final IntVector c2 = exec.getValueVectorById(new SchemaPath("green", ExpressionPosition.UNKNOWN), IntVector.class);

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

    for(int i =0; i < c1.getAccessor().getValueCount(); i++) {
      recordCount++;
      assertTrue(previousInt <= a1.get(i));
      previousInt = a1.get(i);
      assertEquals(previousInt, a2.get(i));
    }
  }

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

  if(context.getFailureCause() != null) {
    throw context.getFailureCause();
  }
  assertTrue(!context.isFailed());
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:38,代码来源:TestSimpleSort.java

示例9: testSin

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void testSin(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable{
  final DrillConfig c = DrillConfig.create();

  // setup mocks
  new NonStrictExpectations(){{
    bitContext.getMetrics(); result = new MetricRegistry("test");
    bitContext.getAllocator(); result = BufferAllocator.getAllocator(c);
  }};
  
  // internal drill setup.
  PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
  PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/compile/test2.json"), Charsets.UTF_8));
  FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
  FragmentContext context = new FragmentContext(bitContext, FragmentHandle.getDefaultInstance(), connection, null, registry);
  SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

  int recordCount = 0;
  
  // look at the result sets.  We should receive a total of 
  while(exec.next()){
    Float8Vector c1 = exec.getValueVectorById(new SchemaPath("col1", ExpressionPosition.UNKNOWN), Float8Vector.class);
    Float8Vector.Accessor a1;
    a1 = c1.getAccessor();
    
    for(int i =0; i < c1.getAccessor().getValueCount(); i++){
      assertEquals(a1.get(i), Math.sin(90), 0);
      recordCount++;
    }
    
  }

  // capture failure info.
  if(context.getFailureCause() != null) throw context.getFailureCause();
  assertTrue(!context.isFailed());
  assertEquals(10, recordCount);
}
 
开发者ID:jacques-n,项目名称:oscon-drill,代码行数:38,代码来源:E5SinTest.java

示例10: testAbs

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void testAbs(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable{
  final DrillConfig c = DrillConfig.create();

  // setup mocks
  new NonStrictExpectations(){{
    bitContext.getMetrics(); result = new MetricRegistry("test");
    bitContext.getAllocator(); result = BufferAllocator.getAllocator(c);
  }};
  
  // internal drill setup.
  PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
  PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/compile/test1.json"), Charsets.UTF_8));
  FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
  FragmentContext context = new FragmentContext(bitContext, FragmentHandle.getDefaultInstance(), connection, null, registry);
  SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

  int recordCount = 0;
  
  // look at the result sets.  We should receive a total of 
  while(exec.next()){
    BigIntVector c1 = exec.getValueVectorById(new SchemaPath("col1", ExpressionPosition.UNKNOWN), BigIntVector.class);
    BigIntVector c2 = exec.getValueVectorById(new SchemaPath("col2", ExpressionPosition.UNKNOWN), BigIntVector.class);
    BigIntVector.Accessor a1, a2;
    a1 = c1.getAccessor();
    a2 = c2.getAccessor();
    
    for(int i =0; i < c1.getAccessor().getValueCount(); i++){
      assertEquals(a1.get(i), a2.get(i));
      recordCount++;
    }
    
  }

  // capture failure info.
  if(context.getFailureCause() != null) throw context.getFailureCause();
  assertTrue(!context.isFailed());
  assertEquals(10, recordCount);
}
 
开发者ID:jacques-n,项目名称:oscon-drill,代码行数:40,代码来源:E4AbsTest.java

示例11: testRepeated

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
  public void testRepeated(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
//    System.out.println(System.getProperty("java.class.path"));
    new NonStrictExpectations() {{
      bitContext.getMetrics(); result = new MetricRegistry();
      bitContext.getAllocator(); result = RootAllocatorFactory.newRoot(c);
      bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
      bitContext.getConfig(); result = c;
      bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c);
    }};

    final PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
    final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/physical_repeated_1.json"), Charsets.UTF_8));
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
    final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

    boolean oneIsOne = false;
    int size = 0;
    final int[] sizes = {1, 2, 0, 6};

    while(exec.next()) {
      final IntVector c1 = exec.getValueVectorById(new SchemaPath("cnt", ExpressionPosition.UNKNOWN), IntVector.class);
      final BitVector c2 = exec.getValueVectorById(new SchemaPath("has_min", ExpressionPosition.UNKNOWN), BitVector.class);

      for(int i = 0; i < exec.getRecordCount(); i++) {
        final int curSize = sizes[size % sizes.length];
        assertEquals(curSize, c1.getAccessor().get(i));
        switch(curSize) {
        case 1:
          assertEquals(oneIsOne, 1 == c2.getAccessor().get(i));
          oneIsOne = !oneIsOne;
          break;
        case 2:
          assertEquals(1, c2.getAccessor().get(i));
          break;
        case 0:
          assertEquals(0, c2.getAccessor().get(i));
          break;
        case 6:
          assertEquals(1, c2.getAccessor().get(i));
          break;
        }
        size++;
      }
    }

    if(context.getFailureCause() != null) {
      throw context.getFailureCause();
    }
    assertTrue(!context.isFailed());
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:53,代码来源:TestRepeatedFunction.java

示例12: sortOneKeyAscending

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void sortOneKeyAscending(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
  new NonStrictExpectations() {{
    bitContext.getMetrics(); result = new MetricRegistry();
    bitContext.getAllocator(); result = RootAllocatorFactory.newRoot(c);
    bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
    bitContext.getConfig(); result = c;
    bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c);
  }};

  final PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
  final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/sort/one_key_sort.json"), Charsets.UTF_8));
  final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
  final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
  final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

  int previousInt = Integer.MIN_VALUE;
  int recordCount = 0;
  int batchCount = 0;

  while(exec.next()) {
    batchCount++;
    final IntVector c1 = exec.getValueVectorById(new SchemaPath("blue", ExpressionPosition.UNKNOWN), IntVector.class);
    final IntVector c2 = exec.getValueVectorById(new SchemaPath("green", ExpressionPosition.UNKNOWN), IntVector.class);

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

    for(int i =0; i < c1.getAccessor().getValueCount(); i++) {
      recordCount++;
      assertTrue(previousInt <= a1.get(i));
      previousInt = a1.get(i);
      assertEquals(previousInt, a2.get(i));
    }
  }

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

  if(context.getFailureCause() != null) {
    throw context.getFailureCause();
  }
  assertTrue(!context.isFailed());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:44,代码来源:TestSimpleSort.java

示例13: sortTwoKeysOneAscendingOneDescending

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void sortTwoKeysOneAscendingOneDescending(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
  new NonStrictExpectations(){{
    bitContext.getMetrics(); result = new MetricRegistry();
    bitContext.getAllocator(); result = RootAllocatorFactory.newRoot(c);
    bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
    bitContext.getConfig(); result = c;
    bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c);
  }};

  final PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
  final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/sort/two_key_sort.json"), Charsets.UTF_8));
  final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
  final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
  final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

  int previousInt = Integer.MIN_VALUE;
  long previousLong = Long.MAX_VALUE;

  int recordCount = 0;
  int batchCount = 0;

  while(exec.next()) {
    batchCount++;
    final IntVector c1 = exec.getValueVectorById(new SchemaPath("blue", ExpressionPosition.UNKNOWN), IntVector.class);
    final BigIntVector c2 = exec.getValueVectorById(new SchemaPath("alt", ExpressionPosition.UNKNOWN), BigIntVector.class);

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

    for(int i =0; i < c1.getAccessor().getValueCount(); i++) {
      recordCount++;
      assertTrue(previousInt <= a1.get(i));

      if(previousInt != a1.get(i)) {
        previousLong = Long.MAX_VALUE;
        previousInt = a1.get(i);
      }

      assertTrue(previousLong >= a2.get(i));
      //System.out.println(previousInt + "\t" + a2.get(i));
    }
  }

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

  if(context.getFailureCause() != null) {
    throw context.getFailureCause();
  }
  assertTrue(!context.isFailed());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:52,代码来源:TestSimpleSort.java

示例14: testRepeated

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
  public void testRepeated(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
//    System.out.println(System.getProperty("java.class.path"));
    mockDrillbitContext(bitContext);

    final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c);
    final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile("/physical_repeated_1.json"), Charsets.UTF_8));
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
    final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

    boolean oneIsOne = false;
    int size = 0;
    final int[] sizes = {1, 2, 0, 6};

    while(exec.next()) {
      final IntVector c1 = exec.getValueVectorById(new SchemaPath("cnt", ExpressionPosition.UNKNOWN), IntVector.class);
      final BitVector c2 = exec.getValueVectorById(new SchemaPath("has_min", ExpressionPosition.UNKNOWN), BitVector.class);

      for(int i = 0; i < exec.getRecordCount(); i++) {
        final int curSize = sizes[size % sizes.length];
        assertEquals(curSize, c1.getAccessor().get(i));
        switch(curSize) {
        case 1:
          assertEquals(oneIsOne, 1 == c2.getAccessor().get(i));
          oneIsOne = !oneIsOne;
          break;
        case 2:
          assertEquals(1, c2.getAccessor().get(i));
          break;
        case 0:
          assertEquals(0, c2.getAccessor().get(i));
          break;
        case 6:
          assertEquals(1, c2.getAccessor().get(i));
          break;
        }
        size++;
      }
    }

    if(context.getFailureCause() != null) {
      throw context.getFailureCause();
    }
    assertTrue(!context.isFailed());
  }
 
开发者ID:axbaretto,项目名称:drill,代码行数:47,代码来源:TestRepeatedFunction.java

示例15: sortTwoKeysOneAscendingOneDescending

import org.apache.drill.exec.physical.impl.SimpleRootExec; //导入方法依赖的package包/类
@Test
public void sortTwoKeysOneAscendingOneDescending(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
  mockDrillbitContext(bitContext);

  final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c);
  final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile("/sort/two_key_sort.json"), Charsets.UTF_8));
  final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
  final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
  final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));

  int previousInt = Integer.MIN_VALUE;
  long previousLong = Long.MAX_VALUE;

  int recordCount = 0;
  int batchCount = 0;

  while(exec.next()) {
    batchCount++;
    final IntVector c1 = exec.getValueVectorById(new SchemaPath("blue", ExpressionPosition.UNKNOWN), IntVector.class);
    final BigIntVector c2 = exec.getValueVectorById(new SchemaPath("alt", ExpressionPosition.UNKNOWN), BigIntVector.class);

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

    for(int i =0; i < c1.getAccessor().getValueCount(); i++) {
      recordCount++;
      assertTrue(previousInt <= a1.get(i));

      if(previousInt != a1.get(i)) {
        previousLong = Long.MAX_VALUE;
        previousInt = a1.get(i);
      }

      assertTrue(previousLong >= a2.get(i));
      //System.out.println(previousInt + "\t" + a2.get(i));
    }
  }

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

  if(context.getFailureCause() != null) {
    throw context.getFailureCause();
  }
  assertTrue(!context.isFailed());
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:46,代码来源:TestSimpleSort.java


注:本文中的org.apache.drill.exec.physical.impl.SimpleRootExec.getValueVectorById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。