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


Java RepeatedIntHolder类代码示例

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


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

示例1: writeInt

import org.apache.drill.exec.expr.holders.RepeatedIntHolder; //导入依赖的package包/类
public void writeInt(BaseWriter.ComplexWriter writer, RepeatedIntHolder ... in) {
    int n = -1;
    for (RepeatedIntHolder input : in) {
        if (n != -1 && n != input.end - input.start) {
            throw new IllegalArgumentException("Arguments to zip must all be same length");
        }
        n = input.end - input.start;
    }
    if (n == -1) {
        throw new IllegalArgumentException("Must have at least one argument to zip");
    }

    IntVector.Accessor[] v = new IntVector.Accessor[in.length];
    for (int i = 0; i < in.length; i++) {
        v[i] = in[i].vector.getAccessor();
    }

    writer.setValueCount(n);
    BaseWriter.ListWriter outer = writer.rootAsList();
    outer.startList(); // [ outer list

    for (int i = 0; i < n; i++) {
        BaseWriter.ListWriter inner = outer.list();
        inner.startList();
        for (IntVector.Accessor accessor : v) {
            inner.integer().writeInt(accessor.get(i));
        }
        inner.endList();   // ] inner list
    }

    outer.endList(); // ] outer list
}
 
开发者ID:mapr-demos,项目名称:simple-drill-functions,代码行数:33,代码来源:ZipWriter.java

示例2: testRepeatedIntVector

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

    // Create a new value vector.
    @SuppressWarnings("resource")
    final RepeatedIntVector vector1 = new RepeatedIntVector(field, allocator);

    // Populate the vector.
    final int[] values = {2, 3, 5, 7, 11, 13, 17, 19, 23, 27}; // some tricksy primes
    final int nRecords = 7;
    final int nElements = values.length;
    vector1.allocateNew(nRecords, nRecords * nElements);
    final RepeatedIntVector.Mutator mutator = vector1.getMutator();
    for(int recordIndex = 0; recordIndex < nRecords; ++recordIndex) {
      mutator.startNewValue(recordIndex);
      for(int elementIndex = 0; elementIndex < nElements; ++elementIndex) {
        mutator.add(recordIndex, recordIndex * values[elementIndex]);
      }
    }
    mutator.setValueCount(nRecords);

    // Verify the contents.
    final RepeatedIntVector.Accessor accessor1 = vector1.getAccessor();
    assertEquals(nRecords, accessor1.getValueCount());
    for(int recordIndex = 0; recordIndex < nRecords; ++recordIndex) {
      for(int elementIndex = 0; elementIndex < nElements; ++elementIndex) {
        final int value = accessor1.get(recordIndex, elementIndex);
        assertEquals(recordIndex * values[elementIndex], value);
      }
    }

/* TODO(cwestin)
the interface to load has changed
    // Serialize, reify, and verify.
    final DrillBuf[] buffers1 = vector1.getBuffers(false);
    final DrillBuf buffer1 = combineBuffers(allocator, buffers1);
    final RepeatedIntVector vector2 = new RepeatedIntVector(field, allocator);
    vector2.load(nRecords, nRecords * nElements, buffer1);

    final RepeatedIntVector.Accessor accessor2 = vector2.getAccessor();
    for(int recordIndex = 0; recordIndex < nRecords; ++recordIndex) {
      for(int elementIndex = 0; elementIndex < nElements; ++elementIndex) {
        final int value = accessor2.get(recordIndex, elementIndex);
        assertEquals(accessor1.get(recordIndex,  elementIndex), value);
      }
    }
*/

    vector1.close();
/* TODO(cwestin)
    vector2.close();
    buffer1.release();
*/
  }
 
开发者ID:axbaretto,项目名称:drill,代码行数:56,代码来源:TestValueVector.java


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