alamb commented on code in PR #13306:
URL: https://github.com/apache/datafusion/pull/13306#discussion_r1840322724


##########
benchmarks/src/bin/sort_integration.rs:
##########
@@ -0,0 +1,336 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! This module provides integration benchmark for sort operation.
+//! It will run different sort SQL queries on parquet dataset.
+//!
+//! Another `Sort` benchmark focus on single core execution. This benchmark
+//! runs end-to-end sort queries and test the performance on multiple CPU 
cores.
+
+use std::path::PathBuf;
+use std::sync::Arc;
+use structopt::StructOpt;
+
+use arrow::record_batch::RecordBatch;
+use datafusion::datasource::file_format::parquet::ParquetFormat;
+use datafusion::datasource::listing::{
+    ListingOptions, ListingTable, ListingTableConfig, ListingTableUrl,
+};
+use datafusion::datasource::{MemTable, TableProvider};
+use datafusion::error::Result;
+use datafusion::execution::runtime_env::RuntimeConfig;
+use datafusion::physical_plan::display::DisplayableExecutionPlan;
+use datafusion::physical_plan::{collect, displayable};
+use datafusion::prelude::*;
+use datafusion_benchmarks::util::{BenchmarkRun, CommonOpt};
+use datafusion_common::instant::Instant;
+use datafusion_common::DEFAULT_PARQUET_EXTENSION;
+
+#[derive(Debug, StructOpt)]
+#[structopt(
+    name = "datafusion-sort-integration",
+    about = "DataFusion sort integration benchmark"
+)]
+enum SortQueryOpt {
+    Benchmark(SortConfig),
+}
+
+#[derive(Debug, StructOpt)]
+struct SortConfig {
+    /// Common options
+    #[structopt(flatten)]
+    common: CommonOpt,
+
+    /// Sort query number. If not specified, runs all queries
+    #[structopt(short, long)]
+    query: Option<usize>,
+
+    /// Path to data files (lineitem). Only parquet format is supported
+    #[structopt(parse(from_os_str), required = true, short = "p", long = 
"path")]
+    path: PathBuf,
+
+    /// Path to JSON benchmark result to be compare using `compare.py`
+    #[structopt(parse(from_os_str), short = "o", long = "output")]
+    output_path: Option<PathBuf>,
+
+    /// Load the data into a MemTable before executing the query
+    #[structopt(short = "m", long = "mem-table")]
+    mem_table: bool,
+}
+
+struct QueryResult {
+    elapsed: std::time::Duration,
+    row_count: usize,
+}
+
+impl SortConfig {
+    const SORT_TABLES: [&'static str; 1] = ["lineitem"];
+
+    /// Sort queries with different characteristics:
+    /// - Sort key with fixed length or variable length (VARCHAR)
+    /// - Sort key with different cardinality
+    /// - Different number of sort keys
+    /// - Different number of payload columns (thin: 1 additional column other
+    ///   than sort keys; wide: all columns except sort keys)
+    ///
+    /// DataSet is `lineitem` table in TPCH dataset (16 columns, 6M rows for
+    /// scale factor 1.0, cardinality is counted from SF1 dataset)
+    ///
+    /// Key Columns:
+    /// - Column `l_linenumber`, type: `INTEGER`, cardinality: 7
+    /// - Column `l_suppkey`, type: `BIGINT`, cardinality: 10k
+    /// - Column `l_orderkey`, type: `BIGINT`, cardinality: 1.5M
+    /// - Column `l_comment`, type: `VARCHAR`, cardinality: 4.5M (len is ~26 
chars)
+    ///
+    /// Payload Columns:
+    /// - Thin variant: `l_partkey` column with `BIGINT` type (1 column)
+    /// - Wide variant: all columns except for possible key columns (12 
columns)
+    const SORT_QUERIES: [&'static str; 10] = [
+        // Q1: 1 sort key (type: INTEGER, cardinality: 7) + 1 payload column

Review Comment:
   thank you for your annotations here. 👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to