github.com/apache/beam/sdks/v2@v2.48.2/python/apache_beam/transforms/stats.pxd (about) 1 # 2 # Licensed to the Apache Software Foundation (ASF) under one or more 3 # contributor license agreements. See the NOTICE file distributed with 4 # this work for additional information regarding copyright ownership. 5 # The ASF licenses this file to You under the Apache License, Version 2.0 6 # (the "License"); you may not use this file except in compliance with 7 # 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, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 # 17 18 cimport cython 19 from libc.stdint cimport int64_t 20 21 cdef class _QuantileSpec(object): 22 cdef readonly int64_t buffer_size 23 cdef readonly int64_t num_buffers 24 cdef readonly bint weighted 25 cdef readonly key 26 cdef readonly bint reverse 27 cdef readonly weighted_key 28 cdef readonly less_than 29 30 cdef class _QuantileBuffer(object): 31 cdef readonly elements 32 cdef readonly weights 33 cdef readonly bint weighted 34 cdef readonly int64_t level 35 cdef readonly min_val 36 cdef readonly max_val 37 cdef readonly _iter 38 39 cdef class _QuantileState(object): 40 cdef readonly _QuantileSpec spec 41 cdef public buffers 42 cdef public unbuffered_elements 43 cdef public unbuffered_weights 44 cdef public add_unbuffered 45 cpdef bint is_empty(self) 46 @cython.locals(num_new_buffers=int64_t, idx=int64_t) 47 cpdef _add_unbuffered(self, elements, offset_fn) 48 @cython.locals(num_new_buffers=int64_t, idx=int64_t) 49 cpdef _add_unbuffered_weighted(self, elements, offset_fn) 50 cpdef finalize(self) 51 @cython.locals(min_level=int64_t) 52 cpdef collapse_if_needed(self, offset_fn) 53 54 55 @cython.locals(new_level=int64_t, new_weight=double, step=double, offset=double) 56 cdef _QuantileBuffer _collapse(buffers, offset_fn, _QuantileSpec spec) 57 58 @cython.locals(j=int64_t) 59 cdef _interpolate(buffers, int64_t count, double step, double offset, 60 _QuantileSpec spec)