• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NullableVarCharHolder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.drill.exec.expr.holders.NullableVarCharHolder的典型用法代码示例。如果您正苦于以下问题:Java NullableVarCharHolder类的具体用法?Java NullableVarCharHolder怎么用?Java NullableVarCharHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NullableVarCharHolder类属于org.apache.drill.exec.expr.holders包,在下文中一共展示了NullableVarCharHolder类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testNullableVarLen2

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
@Test
public void testNullableVarLen2() {
  MaterializedField field = MaterializedField.create(EMPTY_SCHEMA_PATH, NullableVarCharHolder.TYPE);

  // Create a new value vector for 1024 integers
  try (NullableVarCharVector vector = new NullableVarCharVector(field, allocator)) {
    NullableVarCharVector.Mutator m = vector.getMutator();
    vector.allocateNew(1024 * 10, 1024);

    m.set(0, STR1);
    m.set(1, STR2);
    m.set(2, STR3);

    // Check the sample strings
    assertArrayEquals(STR1, vector.getAccessor().get(0));
    assertArrayEquals(STR2, vector.getAccessor().get(1));
    assertArrayEquals(STR3, vector.getAccessor().get(2));

    // Ensure null value throws
    boolean b = false;
    try {
      vector.getAccessor().get(3);
    } catch (IllegalStateException e) {
      b = true;
    } finally {
      assertTrue(b);
    }
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:30,代码来源:TestValueVector.java


示例2: testReAllocNullableVariableWidthVector

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
@Test
public void testReAllocNullableVariableWidthVector() throws Exception {
  MaterializedField field = MaterializedField.create(EMPTY_SCHEMA_PATH, NullableVarCharHolder.TYPE);

  // Create a new value vector for 1024 integers
  try (NullableVarCharVector vector = (NullableVarCharVector) TypeHelper.getNewVector(field, allocator)) {
    NullableVarCharVector.Mutator m = vector.getMutator();
    vector.allocateNew();

    int initialCapacity = vector.getValueCapacity();

    // Put values in indexes that fall within the initial allocation
    m.setSafe(0, STR1, 0, STR1.length);
    m.setSafe(initialCapacity - 1, STR2, 0, STR2.length);

    // Now try to put values in space that falls beyond the initial allocation
    m.setSafe(initialCapacity + 200, STR3, 0, STR3.length);

    // Check valueCapacity is more than initial allocation
    assertEquals((initialCapacity + 1) * 2 - 1, vector.getValueCapacity());

    assertArrayEquals(STR1, vector.getAccessor().get(0));
    assertArrayEquals(STR2, vector.getAccessor().get(initialCapacity - 1));
    assertArrayEquals(STR3, vector.getAccessor().get(initialCapacity + 200));

    // Set the valueCount to be more than valueCapacity of current allocation. This is possible for NullableValueVectors
    // as we don't call setSafe for null values, but we do call setValueCount when the current batch is processed.
    m.setValueCount(vector.getValueCapacity() + 200);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:31,代码来源:TestValueVector.java


示例3: testVectors

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
/**
 * Convenience method that allows running tests on various {@link ValueVector vector} instances.
 *
 * @param test test function to execute
 */
private void testVectors(VectorVerifier test) throws Exception {
  final MaterializedField[] fields = {
      MaterializedField.create(EMPTY_SCHEMA_PATH, UInt4Holder.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, BitHolder.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, VarCharHolder.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, NullableVarCharHolder.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, RepeatedListVector.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, MapVector.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, RepeatedMapVector.TYPE)
  };

  final ValueVector[] vectors = {
      new UInt4Vector(fields[0], allocator),
      new BitVector(fields[1], allocator),
      new VarCharVector(fields[2], allocator),
      new NullableVarCharVector(fields[3], allocator),
      new RepeatedListVector(fields[4], allocator, null),
      new MapVector(fields[5], allocator, null),
      new RepeatedMapVector(fields[6], allocator, null)
  };

  try {
    for (final ValueVector vector : vectors) {
      test.verify(vector);
    }
  } finally {
    AutoCloseables.close(vectors);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:35,代码来源:TestValueVector.java


示例4: testSubstring

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
@Test
public void testSubstring(@Injectable final DrillbitContext bitContext,
                          @Injectable UserServer.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("/functions/testSubstring.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()) {
    final NullableVarCharVector c1 = exec.getValueVectorById(new SchemaPath("col3", ExpressionPosition.UNKNOWN), NullableVarCharVector.class);
    final NullableVarCharVector.Accessor a1 = c1.getAccessor();

    int count = 0;
    for(int i = 0; i < c1.getAccessor().getValueCount(); i++) {
      if (!a1.isNull(i)) {
        final NullableVarCharHolder holder = new NullableVarCharHolder();
        a1.get(i, holder);
        assertEquals("aaaa", StringFunctionHelpers.toStringFromUTF8(holder.start,  holder.end,  holder.buffer));
        ++count;
      }
    }
    assertEquals(50, count);
  }

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


示例5: testSubstringNegative

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
@Test
public void testSubstringNegative(@Injectable final DrillbitContext bitContext,
                                  @Injectable UserServer.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("/functions/testSubstringNegative.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()) {
    final NullableVarCharVector c1 = exec.getValueVectorById(new SchemaPath("col3", ExpressionPosition.UNKNOWN), NullableVarCharVector.class);
    final NullableVarCharVector.Accessor a1 = c1.getAccessor();

    int count = 0;
    for(int i = 0; i < c1.getAccessor().getValueCount(); i++) {
      if (!a1.isNull(i)) {
        final NullableVarCharHolder holder = new NullableVarCharHolder();
        a1.get(i, holder);
        //when offset is negative, substring return empty string.
        assertEquals("", StringFunctionHelpers.toStringFromUTF8(holder.start,  holder.end,  holder.buffer));
        ++count;
      }
    }
    assertEquals(50, count);
  }

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


示例6: testNullableVarLen2

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
@Test
public void testNullableVarLen2() {
  final MaterializedField field = MaterializedField.create(EMPTY_SCHEMA_PATH, NullableVarCharHolder.TYPE);

  // Create a new value vector for 1024 integers.
  try (final NullableVarCharVector vector = new NullableVarCharVector(field, allocator)) {
    final NullableVarCharVector.Mutator m = vector.getMutator();
    vector.allocateNew(1024 * 10, 1024);

    m.set(0, STR1);
    m.set(1, STR2);
    m.set(2, STR3);

    // Check the sample strings.
    final NullableVarCharVector.Accessor accessor = vector.getAccessor();
    assertArrayEquals(STR1, accessor.get(0));
    assertArrayEquals(STR2, accessor.get(1));
    assertArrayEquals(STR3, accessor.get(2));

    // Ensure null value throws.
    boolean b = false;
    try {
      vector.getAccessor().get(3);
    } catch (IllegalStateException e) {
      b = true;
    } finally {
      assertTrue(b);
    }
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:31,代码来源:TestValueVector.java


示例7: testReAllocNullableVariableWidthVector

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
@Test
public void testReAllocNullableVariableWidthVector() {
  final MaterializedField field = MaterializedField.create(EMPTY_SCHEMA_PATH, NullableVarCharHolder.TYPE);

  // Create a new value vector for 1024 integers
  try (final NullableVarCharVector vector = (NullableVarCharVector) TypeHelper.getNewVector(field, allocator)) {
    final NullableVarCharVector.Mutator m = vector.getMutator();
    vector.allocateNew();

    int initialCapacity = vector.getValueCapacity();

    // Put values in indexes that fall within the initial allocation
    m.setSafe(0, STR1, 0, STR1.length);
    m.setSafe(initialCapacity - 1, STR2, 0, STR2.length);

    // Now try to put values in space that falls beyond the initial allocation
    m.setSafe(initialCapacity + 200, STR3, 0, STR3.length);

    // Check valueCapacity is more than initial allocation
    assertEquals((initialCapacity + 1) * 2 - 1, vector.getValueCapacity());

    final NullableVarCharVector.Accessor accessor = vector.getAccessor();
    assertArrayEquals(STR1, accessor.get(0));
    assertArrayEquals(STR2, accessor.get(initialCapacity - 1));
    assertArrayEquals(STR3, accessor.get(initialCapacity + 200));

    // Set the valueCount to be more than valueCapacity of current allocation. This is possible for NullableValueVectors
    // as we don't call setSafe for null values, but we do call setValueCount when the current batch is processed.
    m.setValueCount(vector.getValueCapacity() + 200);
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:32,代码来源:TestValueVector.java


示例8: testVectors

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
/**
 * Convenience method that allows running tests on various {@link ValueVector vector} instances.
 *
 * @param test test function to execute
 */
@SuppressWarnings("resource")
private void testVectors(VectorVerifier test) throws Exception {
  final MaterializedField[] fields = {
      MaterializedField.create(EMPTY_SCHEMA_PATH, UInt4Holder.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, BitHolder.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, VarCharHolder.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, NullableVarCharHolder.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, RepeatedListVector.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, MapVector.TYPE),
      MaterializedField.create(EMPTY_SCHEMA_PATH, RepeatedMapVector.TYPE)
  };

  final ValueVector[] vectors = {
      new UInt4Vector(fields[0], allocator),
      new BitVector(fields[1], allocator),
      new VarCharVector(fields[2], allocator),
      new NullableVarCharVector(fields[3], allocator),
      new RepeatedListVector(fields[4], allocator, null),
      new MapVector(fields[5], allocator, null),
      new RepeatedMapVector(fields[6], allocator, null)
  };

  try {
    for (final ValueVector vector : vectors) {
      test.verify(vector);
    }
  } finally {
    AutoCloseables.close(vectors);
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:36,代码来源:TestValueVector.java


示例9: testSubstring

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
@Test
public void testSubstring(@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/testSubstring.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()) {
    final NullableVarCharVector c1 = exec.getValueVectorById(new SchemaPath("col3", ExpressionPosition.UNKNOWN), NullableVarCharVector.class);
    final NullableVarCharVector.Accessor a1 = c1.getAccessor();

    int count = 0;
    for(int i = 0; i < c1.getAccessor().getValueCount(); i++) {
      if (!a1.isNull(i)) {
        final NullableVarCharHolder holder = new NullableVarCharHolder();
        a1.get(i, holder);
        assertEquals("aaaa", StringFunctionHelpers.toStringFromUTF8(holder.start,  holder.end,  holder.buffer));
        ++count;
      }
    }
    assertEquals(50, count);
  }

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


示例10: testSubstringNegative

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
@Test
public void testSubstringNegative(@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/testSubstringNegative.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()) {
    final NullableVarCharVector c1 = exec.getValueVectorById(new SchemaPath("col3", ExpressionPosition.UNKNOWN), NullableVarCharVector.class);
    final NullableVarCharVector.Accessor a1 = c1.getAccessor();

    int count = 0;
    for(int i = 0; i < c1.getAccessor().getValueCount(); i++) {
      if (!a1.isNull(i)) {
        final NullableVarCharHolder holder = new NullableVarCharHolder();
        a1.get(i, holder);
        //when offset is negative, substring return empty string.
        assertEquals("", StringFunctionHelpers.toStringFromUTF8(holder.start,  holder.end,  holder.buffer));
        ++count;
      }
    }
    assertEquals(50, count);
  }

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


示例11: getStringFromVarCharHolder

import org.apache.drill.exec.expr.holders.NullableVarCharHolder; //导入依赖的package包/类
/**
 * Convert a NullableVarCharHolder to a String.
 */
public static String getStringFromVarCharHolder(NullableVarCharHolder varCharHolder) {
  return toStringFromUTF8(varCharHolder.start, varCharHolder.end, varCharHolder.buffer);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:7,代码来源:StringFunctionHelpers.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IINC类代码示例发布时间:2022-05-23
下一篇:
Java ThreadPoolRejectedPolicy类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap