github.com/apache/beam/sdks/v2@v2.48.2/python/apache_beam/runners/worker/opcounters.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 cimport libc.stdint 20 21 from apache_beam.utils.counters cimport Counter 22 from apache_beam.runners.worker cimport statesampler_fast 23 24 25 cdef class TransformIOCounter(object): 26 cdef readonly object _counter_factory 27 cdef readonly object _state_sampler 28 cdef Counter bytes_read_counter 29 cdef statesampler_fast.ScopedState scoped_state 30 cdef object _latest_step 31 32 cpdef update_current_step(self) 33 cpdef add_bytes_read(self, libc.stdint.int64_t n) 34 cpdef __enter__(self) 35 cpdef __exit__(self, exc_type, exc_value, traceback) 36 37 38 cdef class NoOpTransformIOCounter(TransformIOCounter): 39 pass 40 41 42 cdef class SideInputReadCounter(TransformIOCounter): 43 cdef readonly object declaring_step 44 cdef readonly object input_index 45 46 47 cdef class SumAccumulator(object): 48 cdef libc.stdint.int64_t _value 49 cpdef update(self, libc.stdint.int64_t value) 50 cpdef libc.stdint.int64_t value(self) 51 52 53 cdef class OperationCounters(object): 54 cdef public _counter_factory 55 cdef public Counter element_counter 56 cdef public Counter mean_byte_counter 57 cdef public coder_impl 58 cdef public SumAccumulator active_accumulator 59 cdef public object current_size 60 cdef public libc.stdint.int64_t _sample_counter 61 cdef public libc.stdint.int64_t _next_sample 62 cdef public object output_type_constraints 63 cdef public object producer_batch_converter 64 65 cpdef update_from(self, windowed_value) 66 cpdef update_from_batch(self, windowed_batch) 67 cdef inline do_sample(self, windowed_value) 68 cpdef update_collect(self) 69 cpdef type_check(self, value) 70 71 cdef libc.stdint.int64_t _compute_next_sample(self, libc.stdint.int64_t i) 72 cdef inline bint _should_sample(self) 73 cpdef bint should_sample(self)