Package org.apache.drill.exec.memory

Examples of org.apache.drill.exec.memory.TopLevelAllocator


    }
  }

  @BeforeClass
  public static void setupCache() throws Exception {
    ALLOCATOR = new TopLevelAllocator();
    ICACHE = new ICache(CONFIG, ALLOCATOR, true);
    ICACHE.run();
  }
View Full Code Here


  }

  @BeforeClass
  public static void openClient() throws Exception{
    config = DrillConfig.create(TEST_CONFIGURATIONS);
    allocator = new TopLevelAllocator(config);
    if(config.hasPath(ENABLE_FULL_CACHE) && config.getBoolean(ENABLE_FULL_CACHE)){
      serviceSet = RemoteServiceSet.getServiceSetWithFullCache(config, allocator);
    }else{
      serviceSet = RemoteServiceSet.getLocalServiceSet();
    }
View Full Code Here

    public void runTest(@Injectable final DrillbitContext bitContext,
                        @Injectable UserServer.UserClientConnection connection, Object[] expectedResults, String planPath) throws Throwable {

      new NonStrictExpectations(){{
        bitContext.getMetrics(); result = new MetricRegistry();
        bitContext.getAllocator(); result = new TopLevelAllocator();
        bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
        bitContext.getConfig(); result = c;
      }};

      String planString = Resources.toString(Resources.getResource(planPath), Charsets.UTF_8);
View Full Code Here

    public void testBasicMathFunctions(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable
    {

        new NonStrictExpectations(){{
            bitContext.getMetrics(); result = new MetricRegistry();
            bitContext.getAllocator(); result = new TopLevelAllocator();
            bitContext.getConfig(); result = c;
            bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
        }};

        PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
View Full Code Here

  public void testSubstring(@Injectable final DrillbitContext bitContext,
                            @Injectable UserServer.UserClientConnection connection) throws Throwable{

    new NonStrictExpectations(){{
      bitContext.getMetrics(); result = new MetricRegistry();
      bitContext.getAllocator(); result = new TopLevelAllocator();
      bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
      bitContext.getConfig(); result = c;
    }};

    PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
View Full Code Here

  public void testSubstringNegative(@Injectable final DrillbitContext bitContext,
                                    @Injectable UserServer.UserClientConnection connection) throws Throwable{

    new NonStrictExpectations(){{
      bitContext.getMetrics(); result = new MetricRegistry();
      bitContext.getAllocator(); result = new TopLevelAllocator();
      bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
      bitContext.getConfig(); result = c;
    }};

    PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
View Full Code Here

  public void testByteSubstring(@Injectable final DrillbitContext bitContext,
                                  @Injectable UserServer.UserClientConnection connection) throws Throwable{

    new NonStrictExpectations(){{
      bitContext.getMetrics(); result = new MetricRegistry();
      bitContext.getAllocator(); result = new TopLevelAllocator();
      bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
      bitContext.getConfig(); result = c;
    }};

    PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
View Full Code Here

public class TestSplitAndTransfer {

  @Test
  public void test() throws Exception {
    BufferAllocator allocator = new TopLevelAllocator();
    MaterializedField field = MaterializedField.create("field", Types.optional(MinorType.VARCHAR));
    NullableVarCharVector varCharVector = new NullableVarCharVector(field, allocator);
    varCharVector.allocateNew(10000, 1000);

    String[] compareArray = new String[500];

    for (int i = 0; i < 500; i += 3) {
      String s = String.format("%010d", i);
      varCharVector.getMutator().set(i, s.getBytes());
      compareArray[i] = s;
    }
    varCharVector.getMutator().setValueCount(500);

    TransferPair tp = varCharVector.getTransferPair();
    NullableVarCharVector newVarCharVector = (NullableVarCharVector) tp.getTo();
    Accessor accessor = newVarCharVector.getAccessor();
    int[][] startLengths = {{0, 201}, {201, 200}, {401, 99}};

    for (int[] startLength : startLengths) {
      int start = startLength[0];
      int length = startLength[1];
      tp.splitAndTransfer(start, length);
      newVarCharVector.getMutator().setValueCount(length);
      for (int i = 0; i < length; i++) {
        boolean expectedSet = ((start + i) % 3) == 0;
        if (expectedSet) {
          byte[] expectedValue = compareArray[start + i].getBytes();
          Assert.assertFalse(accessor.isNull(i));
//          System.out.println(new String(accessor.get(i)));
          Assert.assertArrayEquals(expectedValue, accessor.get(i));
        } else {
          Assert.assertTrue(accessor.isNull(i));
        }
      }
      newVarCharVector.clear();
    }

    varCharVector.clear();
    allocator.close();
  }
View Full Code Here

      provider.start();
      final SystemOptionManager opt = new SystemOptionManager(c, provider);
      opt.init();
        new NonStrictExpectations(){{
            bitContext.getMetrics(); result = new MetricRegistry();
            bitContext.getAllocator(); result = new TopLevelAllocator();
            bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
            bitContext.getConfig(); result = c;
            bitContext.getOptionManager(); result = opt;
        }};
View Full Code Here

  @Test
  // cast to bigint.
  public void testCastBigInt(@Injectable final DrillbitContext bitContext,
                            @Injectable UserServer.UserClientConnection connection) throws Throwable{

    final BufferAllocator allocator = new TopLevelAllocator();

    new NonStrictExpectations(){{
      bitContext.getMetrics(); result = new MetricRegistry();
      bitContext.getAllocator(); result = allocator;
      bitContext.getConfig(); result = c;
      bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
    }};

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

    while(exec.next()){
      BigIntVector c0 = exec.getValueVectorById(new SchemaPath("varchar_cast", ExpressionPosition.UNKNOWN), BigIntVector.class);
      BigIntVector.Accessor a0;
      a0 = c0.getAccessor();

      int count = 0;
      for(int i = 0; i < c0.getAccessor().getValueCount(); i++){
          BigIntHolder holder0 = new BigIntHolder();
          a0.get(i, holder0);
          assertEquals(1256, holder0.value);
          ++count;

      }
      assertEquals(5, count);
    }

    exec.stop();

    context.close();
    allocator.close();

    if(context.getFailureCause() != null){
      throw context.getFailureCause();
    }
    assertTrue(!context.isFailed());
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.memory.TopLevelAllocator

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.