Exemplo n.º 1
0
Arquivo: Row.java Projeto: cdma/presto
  public static Row extractRow(Page page, int position, List<Type> types) {
    checkArgument(page.getChannelCount() == types.size(), "channelCount does not match");
    checkArgument(
        position < page.getPositionCount(),
        "Requested position %s from a page with positionCount %s ",
        position,
        page.getPositionCount());

    RowBuilder rowBuilder = new RowBuilder();
    for (int channel = 0; channel < page.getChannelCount(); channel++) {
      Block block = page.getBlock(channel);
      Type type = types.get(channel);
      int size;
      Object value = getNativeContainerValue(type, block, position);
      if (value == null) {
        size = SIZE_OF_BYTE;
      } else if (type.getJavaType() == boolean.class) {
        size = SIZE_OF_BYTE;
      } else if (type.getJavaType() == long.class) {
        size = SIZE_OF_LONG;
      } else if (type.getJavaType() == double.class) {
        size = SIZE_OF_DOUBLE;
      } else if (type.getJavaType() == Slice.class) {
        size = ((Slice) value).length();
      } else if (type.getJavaType() == Block.class) {
        size = ((Block) value).getSizeInBytes();
      } else {
        throw new AssertionError("Unimplemented type: " + type);
      }
      rowBuilder.add(nativeContainerToOrcValue(type, value), size);
    }
    Row row = rowBuilder.build();
    verify(
        row.getColumns().size() == types.size(),
        "Column count in row: %s Expected column count: %s",
        row.getColumns().size(),
        types.size());
    return row;
  }
 public FileCursor(String displayName, File file) {
   super(sColumns, 1);
   RowBuilder row = newRow();
   row.add(displayName);
   row.add(file.length());
 }