コード例 #1
0
  public static parquet.schema.Type getParquetType(
      HiveColumnHandle column, MessageType messageType, boolean useParquetColumnNames) {
    if (useParquetColumnNames) {
      return getParquetTypeByName(column.getName(), messageType);
    }

    if (column.getHiveColumnIndex() < messageType.getFieldCount()) {
      return messageType.getType(column.getHiveColumnIndex());
    }
    return null;
  }
コード例 #2
0
  public ParquetPageSource(
      ParquetReader parquetReader,
      ParquetDataSource dataSource,
      MessageType fileSchema,
      MessageType requestedSchema,
      long totalBytes,
      Properties splitSchema,
      List<HiveColumnHandle> columns,
      TupleDomain<HiveColumnHandle> effectivePredicate,
      TypeManager typeManager,
      boolean useParquetColumnNames) {
    checkArgument(totalBytes >= 0, "totalBytes is negative");
    requireNonNull(splitSchema, "splitSchema is null");
    requireNonNull(columns, "columns is null");
    requireNonNull(effectivePredicate, "effectivePredicate is null");

    this.parquetReader = parquetReader;
    this.dataSource = dataSource;
    this.requestedSchema = requestedSchema;
    this.totalBytes = totalBytes;

    int size = columns.size();
    this.constantBlocks = new Block[size];
    this.hiveColumnIndexes = new int[size];

    ImmutableList.Builder<String> namesBuilder = ImmutableList.builder();
    ImmutableList.Builder<Type> typesBuilder = ImmutableList.builder();
    for (int columnIndex = 0; columnIndex < size; columnIndex++) {
      HiveColumnHandle column = columns.get(columnIndex);
      checkState(column.getColumnType() == REGULAR, "column type must be regular");

      String name = column.getName();
      Type type = typeManager.getType(column.getTypeSignature());

      namesBuilder.add(name);
      typesBuilder.add(type);

      hiveColumnIndexes[columnIndex] = column.getHiveColumnIndex();

      if (getParquetType(column, fileSchema, useParquetColumnNames) == null) {
        BlockBuilder blockBuilder =
            type.createBlockBuilder(new BlockBuilderStatus(), MAX_VECTOR_LENGTH);
        for (int i = 0; i < MAX_VECTOR_LENGTH; i++) {
          blockBuilder.appendNull();
        }
        constantBlocks[columnIndex] = blockBuilder.build();
      }
    }
    types = typesBuilder.build();
    columnNames = namesBuilder.build();
  }
コード例 #3
0
 @Override
 public Map<String, ColumnHandle> getColumnHandles(ConnectorTableHandle tableHandle) {
   SchemaTableName tableName = schemaTableName(tableHandle);
   try {
     Table table = metastore.getTable(tableName.getSchemaName(), tableName.getTableName());
     ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();
     for (HiveColumnHandle columnHandle :
         hiveColumnHandles(typeManager, connectorId, table, false)) {
       columnHandles.put(columnHandle.getName(), columnHandle);
     }
     return columnHandles.build();
   } catch (NoSuchObjectException e) {
     throw new TableNotFoundException(tableName);
   }
 }
コード例 #4
0
 @Override
 public ColumnHandle getSampleWeightColumnHandle(ConnectorTableHandle tableHandle) {
   SchemaTableName tableName = schemaTableName(tableHandle);
   try {
     Table table = metastore.getTable(tableName.getSchemaName(), tableName.getTableName());
     for (HiveColumnHandle columnHandle :
         hiveColumnHandles(typeManager, connectorId, table, true)) {
       if (columnHandle.getName().equals(SAMPLE_WEIGHT_COLUMN_NAME)) {
         return columnHandle;
       }
     }
     return null;
   } catch (NoSuchObjectException e) {
     throw new TableNotFoundException(tableName);
   }
 }