Jimexist commented on code in PR #3570: URL: https://github.com/apache/arrow-datafusion/pull/3570#discussion_r979543168
########## datafusion/common/src/bisect.rs: ########## @@ -0,0 +1,113 @@ +// 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 the bisect function, which implements binary search. + +use crate::{DataFusionError, Result, ScalarValue}; +use arrow::array::ArrayRef; + +/// this function implements bisct_left and bisect_right since these functions +/// are a lot of code in common we have decided to implement with single function where +/// we separate left and right with compile time lookup. +/// To use bisect_left give true in the template argument +/// To use bisect_right give false in the template argument +pub fn bisect<const SIDE: bool>( + item_columns: &[ArrayRef], + target: &[ScalarValue], +) -> Result<usize> { Review Comment: if this returns an index then it's a binary search instead of bisect? -- 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]
