Skip to main content

datafusion_spark/function/bitmap/
mod.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18pub mod bitmap_bit_position;
19pub mod bitmap_bucket_number;
20pub mod bitmap_count;
21
22use datafusion_expr::ScalarUDF;
23use datafusion_functions::make_udf_function;
24use std::sync::Arc;
25
26make_udf_function!(bitmap_count::BitmapCount, bitmap_count);
27make_udf_function!(bitmap_bit_position::BitmapBitPosition, bitmap_bit_position);
28make_udf_function!(
29    bitmap_bucket_number::BitmapBucketNumber,
30    bitmap_bucket_number
31);
32
33pub mod expr_fn {
34    use datafusion_functions::export_functions;
35
36    export_functions!((
37        bitmap_count,
38        "Returns the number of set bits in the input bitmap.",
39        arg
40    ));
41    export_functions!((
42        bitmap_bit_position,
43        "Returns the bit position for the given input child expression.",
44        arg
45    ));
46    export_functions!((
47        bitmap_bucket_number,
48        "Returns the bucket number for the given input child expression.",
49        arg
50    ));
51}
52
53pub fn functions() -> Vec<Arc<ScalarUDF>> {
54    vec![
55        bitmap_count(),
56        bitmap_bit_position(),
57        bitmap_bucket_number(),
58    ]
59}