Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bitmap.cc
Go to the documentation of this file.
1 // Copyright 2014 Cloudera Inc.
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 #include "util/bitmap.h"
16 
17 #include <sstream>
18 
19 #include "common/names.h"
20 
21 using namespace impala;
22 
23 string Bitmap::DebugString(bool print_bits) {
24  int64_t words = BitUtil::RoundUp(size_, 64) / 64;
25  stringstream ss;
26  ss << "Size (" << size_ << ") words (" << words << ") ";
27  if (print_bits) {
28  for (int i = 0; i < size(); ++i) {
29  if (Get<false>(i)) {
30  ss << "1";
31  } else {
32  ss << "0";
33  }
34  }
35  } else {
36  for (vector<uint64_t>::iterator it = buffer_.begin(); it != buffer_.end(); ++it) {
37  ss << *it << ".";
38  }
39  }
40  ss << endl;
41  return ss.str();
42 }
int64_t size_
Definition: bitmap.h:89
std::string DebugString(bool print_bits)
If 'print_bits' prints 0/1 per bit, otherwise it prints the int64_t value.
Definition: bitmap.cc:23
std::vector< uint64_t > buffer_
Definition: bitmap.h:88
int64_t size() const
Definition: bitmap.h:82
static int RoundUp(int value, int factor)
Returns 'value' rounded up to the nearest multiple of 'factor'.
Definition: bit-util.h:37