Github user jianqiao commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/179#discussion_r99930761
  
    --- Diff: storage/AggregationOperationState.cpp ---
    @@ -556,80 +655,83 @@ void AggregationOperationState::finalizeSingleState(
       output_destination->insertTuple(Tuple(std::move(attribute_values)));
     }
     
    -void AggregationOperationState::mergeGroupByHashTables(
    -    AggregationStateHashTableBase *src, AggregationStateHashTableBase 
*dst) {
    -  HashTableMergerFast merger(dst);
    -  (static_cast<FastHashTable<true, false, true, false> *>(src))
    -      ->forEachCompositeKeyFast(&merger);
    +void AggregationOperationState::finalizeHashTable(
    +    const std::size_t partition_id,
    +    InsertDestination *output_destination) {
    +  if (is_aggregate_collision_free_) {
    +    finalizeHashTableImplCollisionFree(partition_id, output_destination);
    +  } else if (is_aggregate_partitioned_) {
    +    finalizeHashTableImplPartitioned(partition_id, output_destination);
    +  } else {
    +    DCHECK_EQ(0u, partition_id);
    +    finalizeHashTableImplThreadPrivate(output_destination);
    +  }
     }
     
    -void AggregationOperationState::finalizeHashTable(
    +void AggregationOperationState::finalizeHashTableImplCollisionFree(
    +    const std::size_t partition_id,
    +    InsertDestination *output_destination) {
    +  std::vector<std::unique_ptr<ColumnVector>> final_values;
    +  CollisionFreeVectorTable *hash_table =
    +      static_cast<CollisionFreeVectorTable 
*>(collision_free_hashtable_.get());
    +
    +  const std::size_t max_length =
    +      hash_table->getNumTuplesInFinalizationPartition(partition_id);
    +  ColumnVectorsValueAccessor complete_result;
    +
    +  DCHECK_EQ(1u, group_by_types_.size());
    +  const Type *key_type = group_by_types_.front();
    +  DCHECK(NativeColumnVector::UsableForType(*key_type));
    +
    +  std::unique_ptr<NativeColumnVector> key_cv(
    +      new NativeColumnVector(*key_type, max_length));
    +  hash_table->finalizeKey(partition_id, key_cv.get());
    +  complete_result.addColumn(key_cv.release());
    +
    +  for (std::size_t i = 0; i < handles_.size(); ++i) {
    +    const Type *result_type = handles_[i]->getResultType();
    +    DCHECK(NativeColumnVector::UsableForType(*result_type));
    +
    +    std::unique_ptr<NativeColumnVector> result_cv(
    +        new NativeColumnVector(*result_type, max_length));
    --- End diff --
    
    Updated.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to