github.com/matrixorigin/matrixone@v1.2.0/pkg/common/bitmap/cbitmap.go (about)

     1  // Copyright 2021 Matrix Origin
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package bitmap
    16  
    17  /*
    18  #include "mo.h"
    19  
    20  #cgo CFLAGS: -I../../../cgo
    21  #cgo LDFLAGS: -L../../../cgo -lmo -lm
    22  */
    23  import "C"
    24  import "unsafe"
    25  
    26  func (n *Bitmap) cPtr() *C.uint64_t {
    27  	return (*C.uint64_t)(unsafe.Pointer(&n.data[0]))
    28  }
    29  func (n *Bitmap) cLen() C.uint64_t {
    30  	return C.uint64_t(n.len)
    31  }
    32  
    33  func (n *Bitmap) C_IsEmpty() bool {
    34  	cret := C.Bitmap_IsEmpty(n.cPtr(), n.cLen())
    35  	return bool(cret)
    36  }
    37  
    38  func (n *Bitmap) C_Count() uint64 {
    39  	return uint64(C.Bitmap_Count(n.cPtr(), n.cLen()))
    40  }
    41  
    42  func (n *Bitmap) C_And(m *Bitmap) {
    43  	n.TryExpand(m)
    44  	C.Bitmap_And(n.cPtr(), n.cPtr(), m.cPtr(), n.cLen())
    45  }
    46  
    47  func (n *Bitmap) C_Or(m *Bitmap) {
    48  	n.TryExpand(m)
    49  	C.Bitmap_Or(n.cPtr(), n.cPtr(), m.cPtr(), n.cLen())
    50  }