 
     const size_type output_location = atomicAdd(&partition_offsets[row_partition_number], size_type(1));
 
-    output_locations[row_number] = output_location;
+    row_partition_numbers[row_number] = output_location;
 
     row_number += blockDim.x * gridDim.x;
   }

                                          row_partition_numbers,
                                          partition_sizes);

  // Compute exclusive scan of the partition sizes in-place to determine 
  // the starting point for each partition in the output
  thrust::exclusive_scan(partition_sizes, 
                         partition_sizes + num_partitions, 
                         partition_sizes);

  // Copy the result of the exlusive scan to the output offsets array
  // to indicate the starting point for each partition in the output
  cudaMemcpyAsync(partition_offsets, 
                  partition_sizes, 
                  num_partitions * sizeof(size_type),
                  cudaMemcpyDeviceToHost);

  size_type * row_output_locations{nullptr};
  cudaMalloc(&row_output_locations, num_rows * sizeof(size_type));

  compute_output_locations<<<grid_size, HASH_KERNEL_BLOCK_SIZE>>>(row_partition_numbers,
                                                                  num_rows,
                                                                  num_partitions,
                                                                  partition_sizes,
                                                                  row_output_locations);

  cudaFree(row_partition_numbers);
  cudaFree(partition_sizes);
  cudaFree(row_output_locations);
}

/* --------------------------------------------------------------------------*/

  // Create a separate table of the columns to be hashed
  std::unique_ptr< const gdf_table<size_type> > table_to_hash {new gdf_table<size_type>(num_cols_to_hash, 
                                                                                        gdf_columns_to_hash.data())};

  gdf_error gdf_status{GDF_SUCCESS};
  switch(hash)
  {
    case GDF_HASH_MURMUR3:
      {
        gdf_status = hash_partition_gdf_table<MurmurHash3_32>(*input_table, 
                                                              *table_to_hash,
                                                              num_partitions,
                                                              partition_offsets,
                                                              *output_table);
        break;
      }
    default:
      gdf_status = GDF_INVALID_HASH_FUNCTION;
  }

  return gdf_status;
}

