bord.h
Go to the documentation of this file.
1 // File: $Id$
2 // Author: John Wu <John.Wu at acm.org>
3 // Lawrence Berkeley National Laboratory
4 // Copyright (c) 2007-2016 the Regents of the University of California
5 #ifndef IBIS_BORD_H
6 #define IBIS_BORD_H
7 #include "table.h" // ibis::table
8 #include "util.h" // ibis::partList
9 #include "part.h" // ibis::part
10 #include "selectClause.h"// ibis::selectClause
11 #include "dictionary.h" // ibis::dictionary
12 
16 namespace ibis {
17  class bord;
18  class hyperslab;
19 } // namespace ibis
20 
23 class FASTBIT_CXX_DLLSPEC ibis::hyperslab {
24  public:
27  hyperslab() : ndim(0) {}
28  hyperslab(unsigned, const uint64_t*, const uint64_t*,
29  const uint64_t*, const uint64_t*);
30  void tobitvector(uint32_t, const uint64_t*, ibis::bitvector&) const;
31 
34  unsigned ndim;
39 }; // class ibis::hyperslab
40 
51 class FASTBIT_CXX_DLLSPEC ibis::bord : public ibis::table, public ibis::part {
52 public:
53  bord(const char *tn, const char *td, uint64_t nr,
55  const ibis::table::typeArray &ct,
56  const ibis::table::stringArray &cn,
57  const ibis::table::stringArray *cdesc=0,
58  const std::vector<const ibis::dictionary*> *dct=0);
59  bord(const char *tn, const char *td,
60  const ibis::selectClause &sc, const ibis::part &ref);
61  bord(const char *tn, const char *td,
62  const ibis::selectClause &sc, const ibis::constPartList &ref);
63  virtual ~bord() {clear();}
64 
65  virtual uint64_t nRows() const {return nEvents;}
66  virtual uint32_t nColumns() const {return ibis::part::nColumns();}
67 
68  virtual ibis::table::stringArray columnNames() const;
69  virtual ibis::table::typeArray columnTypes() const;
70 
71  virtual void describe(std::ostream&) const;
72  virtual void dumpNames(std::ostream&, const char*) const;
73  virtual int dump(std::ostream&, const char*) const;
74  virtual int dump(std::ostream&, uint64_t, const char*) const;
75  virtual int dumpJSON(std::ostream&, uint64_t) const;
76  virtual int dump(std::ostream&, uint64_t, uint64_t, const char*) const;
77  virtual int backup(const char* dir, const char* tname=0,
78  const char* tdesc=0) const;
79 
80  virtual int64_t getColumnAsBytes(const char*, char*,
81  uint64_t =0, uint64_t =0) const;
82  virtual int64_t getColumnAsUBytes(const char*, unsigned char*,
83  uint64_t =0, uint64_t =0) const;
84  virtual int64_t getColumnAsShorts(const char*, int16_t*,
85  uint64_t =0, uint64_t =0) const;
86  virtual int64_t getColumnAsUShorts(const char*, uint16_t*,
87  uint64_t =0, uint64_t =0) const;
88  virtual int64_t getColumnAsInts(const char*, int32_t*,
89  uint64_t =0, uint64_t =0) const;
90  virtual int64_t getColumnAsUInts(const char*, uint32_t*,
91  uint64_t =0, uint64_t =0) const;
92  virtual int64_t getColumnAsLongs(const char*, int64_t*,
93  uint64_t =0, uint64_t =0) const;
94  virtual int64_t getColumnAsULongs(const char*, uint64_t*,
95  uint64_t =0, uint64_t =0) const;
96  virtual int64_t getColumnAsFloats(const char*, float*,
97  uint64_t =0, uint64_t =0) const;
98  virtual int64_t getColumnAsDoubles(const char*, double*,
99  uint64_t =0, uint64_t =0) const;
100  virtual int64_t getColumnAsDoubles(const char*, std::vector<double>&,
101  uint64_t =0, uint64_t =0) const;
102  virtual int64_t getColumnAsStrings(const char*, std::vector<std::string>&,
103  uint64_t =0, uint64_t =0) const;
104  virtual int64_t getColumnAsOpaques(const char*, std::vector<ibis::opaque>&,
105  uint64_t =0, uint64_t =0) const;
106  virtual double getColumnMin(const char*) const;
107  virtual double getColumnMax(const char*) const;
108 
109  virtual long getHistogram(const char*, const char*,
110  double, double, double,
111  std::vector<uint32_t>&) const;
112  virtual long getHistogram2D(const char*, const char*,
113  double, double, double,
114  const char*,
115  double, double, double,
116  std::vector<uint32_t>&) const;
117  virtual long getHistogram3D(const char*, const char*,
118  double, double, double,
119  const char*,
120  double, double, double,
121  const char*,
122  double, double, double,
123  std::vector<uint32_t>&) const;
124 
125  virtual void estimate(const char* cond,
126  uint64_t &nmin, uint64_t &nmax) const;
127  virtual void estimate(const ibis::qExpr* cond,
128  uint64_t &nmin, uint64_t &nmax) const;
129  using table::select;
130  virtual table* select(const char* sel, const char* cond) const;
131  virtual table* groupby(const ibis::table::stringArray&) const;
132  virtual table* groupby(const char* str) const;
133  using table::orderby;
134  virtual void orderby(const ibis::table::stringArray&);
135  virtual void orderby(const ibis::table::stringArray&,
136  const std::vector<bool>&);
137  virtual void reverseRows();
138 
140  virtual int buildIndex(const char*, const char*) {return -1;}
141  virtual int buildIndexes(const ibis::table::stringArray&) {return -1;}
142  virtual int buildIndexes(const char*) {return -1;}
143  virtual int getPartitions(constPartList&) const;
144  virtual void indexSpec(const char*, const char*) {return;}
145  virtual const char* indexSpec(const char*) const {return 0;}
146 
149  const char*) const;
150 
151  int merge(const ibis::bord&, const ibis::selectClause&);
152  ibis::table* xgroupby(const ibis::selectClause&) const;
153  ibis::table* groupby(const ibis::selectClause&) const;
154  static ibis::bord*
155  groupbya(const ibis::bord&, const ibis::selectClause&);
156  static ibis::bord*
157  groupbyc(const ibis::bord&, const ibis::selectClause&);
158 
159  virtual long reorder();
160  virtual long reorder(const ibis::table::stringArray&);
161  virtual long reorder(const ibis::table::stringArray&,
162  const std::vector<bool>&);
163 
164  int append(const ibis::selectClause&, const ibis::part&,
165  const ibis::bitvector&);
166  int append(const ibis::selectClause&, const ibis::part&,
167  const ibis::qContinuousRange&);
168  int renameColumns(const ibis::selectClause&);
169  int limit(uint32_t);
170 
171  template <typename T>
172  long sortValues(array_t<T> &vals,
173  array_t<uint32_t> &starts,
174  array_t<uint32_t> &indout,
175  const array_t<uint32_t> &indin,
176  bool ascending) const;
177  template <typename T>
178  long reorderValues(array_t<T> &vals,
179  const array_t<uint32_t> &ind) const;
180  long sortStrings(std::vector<std::string> &vals,
181  array_t<uint32_t> &starts,
182  array_t<uint32_t> &idxout,
183  const array_t<uint32_t> &idxin,
184  bool ascending) const;
185  long reorderStrings(std::vector<std::string> &vals,
186  const array_t<uint32_t> &ind) const;
187 
188 
189  void copyColumn(const char*, ibis::TYPE_T&, void*&,
190  const ibis::dictionary*&) const;
191  static void copyValue(ibis::TYPE_T type,
192  void* outbuf, size_t outpos,
193  const void* inbuf, size_t inpos);
194 
195  // Cursor class for row-wise data accesses.
196  class cursor;
198  virtual ibis::table::cursor* createCursor() const;
199 
200  // forward declarations
201  class column;
202  bord(const std::vector<ibis::bord::column*> &cols, uint32_t nr=0);
203 
204 protected:
206  bord() : ibis::part("in-core") {}
207  void clear();
208  int64_t computeHits(const char* cond) const;
209 
210  static int merger(std::vector<ibis::bord::column*>&,
211  std::vector<ibis::bord::column*>&,
212  const std::vector<ibis::bord::column*>&,
213  const std::vector<ibis::bord::column*>&,
214  const std::vector<ibis::selectClause::AGREGADO>&);
215 
216  static int merge0(std::vector<ibis::bord::column*>&,
217  const std::vector<ibis::bord::column*>&,
218  const std::vector<ibis::selectClause::AGREGADO>&);
219  template <typename T> static int
222 
223  static int merge10(ibis::bord::column&,
224  std::vector<ibis::bord::column*>&,
225  const ibis::bord::column&,
226  const std::vector<ibis::bord::column*>&,
227  const std::vector<ibis::selectClause::AGREGADO>&);
228  template <typename Tk> static int
230  std::vector<ibis::bord::column*> &vout,
231  const ibis::array_t<Tk> &kin1,
232  const std::vector<ibis::bord::column*> &vin1,
233  const ibis::array_t<Tk> &kin2,
234  const std::vector<ibis::bord::column*> &vin2,
235  const std::vector<ibis::selectClause::AGREGADO> &agg);
236  static int
237  merge10S(std::vector<std::string> &kout,
238  std::vector<ibis::bord::column*> &vout,
239  const std::vector<std::string> &kin1,
240  const std::vector<ibis::bord::column*> &vin1,
241  const std::vector<std::string> &kin2,
242  const std::vector<ibis::bord::column*> &vin2,
243  const std::vector<ibis::selectClause::AGREGADO> &agg);
244 
245  static int merge11(ibis::bord::column&,
247  const ibis::bord::column&,
248  const ibis::bord::column&,
250  template <typename Tk, typename Tv> static int
252  ibis::array_t<Tv> &vout,
253  const ibis::array_t<Tk> &kin1,
254  const ibis::array_t<Tv> &vin1,
255  const ibis::array_t<Tk> &kin2,
256  const ibis::array_t<Tv> &vin2,
258  template <typename Tv> static int
259  merge11S(std::vector<std::string> &kout,
260  ibis::array_t<Tv> &vout,
261  const std::vector<std::string> &kin1,
262  const ibis::array_t<Tv> &vin1,
263  const std::vector<std::string> &kin2,
264  const ibis::array_t<Tv> &vin2,
266 
267  static int merge12(ibis::bord::column&,
270  const ibis::bord::column&,
271  const ibis::bord::column&,
272  const ibis::bord::column&,
275  template <typename Tk> static int
276  merge12T1(ibis::array_t<Tk> &kout,
277  const ibis::array_t<Tk> &kin1,
278  const ibis::array_t<Tk> &kin2,
281  const ibis::bord::column&,
282  const ibis::bord::column&,
285  template <typename Tk, typename Tu, typename Tv> static int
286  merge12T(ibis::array_t<Tk> &kout,
287  ibis::array_t<Tu> &uout,
288  ibis::array_t<Tv> &vout,
289  const ibis::array_t<Tk> &kin1,
290  const ibis::array_t<Tu> &uin1,
291  const ibis::array_t<Tv> &vin1,
292  const ibis::array_t<Tk> &kin2,
293  const ibis::array_t<Tu> &uin2,
294  const ibis::array_t<Tv> &vin2,
297  static int
298  merge12S1(std::vector<std::string> &kout,
299  const std::vector<std::string> &kin1,
300  const std::vector<std::string> &kin2,
303  const ibis::bord::column&,
304  const ibis::bord::column&,
307  template <typename Tu, typename Tv> static int
308  merge12S(std::vector<std::string> &kout,
309  ibis::array_t<Tu> &uout,
310  ibis::array_t<Tv> &vout,
311  const std::vector<std::string> &kin1,
312  const ibis::array_t<Tu> &uin1,
313  const ibis::array_t<Tv> &vin1,
314  const std::vector<std::string> &kin2,
315  const ibis::array_t<Tu> &uin2,
316  const ibis::array_t<Tv> &vin2,
319 
320  static int merge20(ibis::bord::column &k11,
321  ibis::bord::column &k21,
322  std::vector<ibis::bord::column*> &v1,
323  const ibis::bord::column &k12,
324  const ibis::bord::column &k22,
325  const std::vector<ibis::bord::column*> &v2,
326  const std::vector<ibis::selectClause::AGREGADO> &agg);
327  template <typename Tk1> static int
329  const ibis::array_t<Tk1> &k1in1,
330  const ibis::array_t<Tk1> &k1in2,
331  ibis::bord::column &k21,
332  std::vector<ibis::bord::column*> &vin1,
333  const ibis::bord::column &k22,
334  const std::vector<ibis::bord::column*> &vin2,
335  const std::vector<ibis::selectClause::AGREGADO> &agg);
336  template <typename Tk1, typename Tk2> static int
338  ibis::array_t<Tk2> &k2out,
339  std::vector<ibis::bord::column*> &vout,
340  const ibis::array_t<Tk1> &k1in1,
341  const ibis::array_t<Tk2> &k2in1,
342  const std::vector<ibis::bord::column*> &vin1,
343  const ibis::array_t<Tk1> &k1in2,
344  const ibis::array_t<Tk2> &k2in2,
345  const std::vector<ibis::bord::column*> &vin2,
346  const std::vector<ibis::selectClause::AGREGADO> &agg);
347  static int
348  merge20S0(std::vector<std::string> &k1out,
349  std::vector<std::string> &k2out,
350  std::vector<ibis::bord::column*> &vout,
351  const std::vector<std::string> &k1in1,
352  const std::vector<std::string> &k2in1,
353  const std::vector<ibis::bord::column*> &vin1,
354  const std::vector<std::string> &k1in2,
355  const std::vector<std::string> &k2in2,
356  const std::vector<ibis::bord::column*> &vin2,
357  const std::vector<ibis::selectClause::AGREGADO> &agg);
358  static int
359  merge20S1(std::vector<std::string> &k1out,
360  const std::vector<std::string> &k1in1,
361  const std::vector<std::string> &k1in2,
362  ibis::bord::column &k21,
363  std::vector<ibis::bord::column*> &vin1,
364  const ibis::bord::column &k22,
365  const std::vector<ibis::bord::column*> &vin2,
366  const std::vector<ibis::selectClause::AGREGADO> &agg);
367  template <typename Tk2> static int
368  merge20S2(std::vector<std::string> &k1out,
369  ibis::array_t<Tk2> &k2out,
370  std::vector<ibis::bord::column*> &vout,
371  const std::vector<std::string> &k1in1,
372  const ibis::array_t<Tk2> &k2in1,
373  const std::vector<ibis::bord::column*> &vin1,
374  const std::vector<std::string> &k1in2,
375  const ibis::array_t<Tk2> &k2in2,
376  const std::vector<ibis::bord::column*> &vin2,
377  const std::vector<ibis::selectClause::AGREGADO> &agg);
378  template <typename Tk1> static int
379  merge20S3(ibis::array_t<Tk1> &k1out,
380  std::vector<std::string> &k2out,
381  std::vector<ibis::bord::column*> &vout,
382  const ibis::array_t<Tk1> &k1in1,
383  const std::vector<std::string> &k2in1,
384  const std::vector<ibis::bord::column*> &vin1,
385  const ibis::array_t<Tk1> &k1in2,
386  const std::vector<std::string> &k2in2,
387  const std::vector<ibis::bord::column*> &vin2,
388  const std::vector<ibis::selectClause::AGREGADO> &agg);
389 
390  static int merge21(ibis::bord::column &k11,
391  ibis::bord::column &k21,
392  ibis::bord::column &v1,
393  const ibis::bord::column &k12,
394  const ibis::bord::column &k22,
395  const ibis::bord::column &v2,
397  template <typename Tk1> static int
399  const ibis::array_t<Tk1> &k1in1,
400  const ibis::array_t<Tk1> &k1in2,
401  ibis::bord::column &k21,
402  ibis::bord::column &v1,
403  const ibis::bord::column &k22,
404  const ibis::bord::column &v2,
406  template <typename Tk1, typename Tk2> static int
408  ibis::array_t<Tk2> &k2out,
409  const ibis::array_t<Tk1> &k1in1,
410  const ibis::array_t<Tk2> &k2in1,
411  const ibis::array_t<Tk1> &k1in2,
412  const ibis::array_t<Tk2> &k2in2,
413  ibis::bord::column &v1,
414  const ibis::bord::column &v2,
416  template <typename Tk1, typename Tk2, typename Tv> static int
418  ibis::array_t<Tk2> &k2out,
419  ibis::array_t<Tv> &vout,
420  const ibis::array_t<Tk1> &k1in1,
421  const ibis::array_t<Tk2> &k2in1,
422  const ibis::array_t<Tv> &vin1,
423  const ibis::array_t<Tk1> &k1in2,
424  const ibis::array_t<Tk2> &k2in2,
425  const ibis::array_t<Tv> &vin2,
427  static int
428  merge21S1(std::vector<std::string> &k1out,
429  const std::vector<std::string> &k1in1,
430  const std::vector<std::string> &k1in2,
431  ibis::bord::column &k21,
432  ibis::bord::column &v1,
433  const ibis::bord::column &k22,
434  const ibis::bord::column &v2,
436  template <typename Tk2> static int
437  merge21S2(std::vector<std::string> &k1out,
438  ibis::array_t<Tk2> &k2out,
439  const std::vector<std::string> &k1in1,
440  const ibis::array_t<Tk2> &k2in1,
441  const std::vector<std::string> &k1in2,
442  const ibis::array_t<Tk2> &k2in2,
443  ibis::bord::column &v1,
444  const ibis::bord::column &v2,
446  template <typename Tk2, typename Tv> static int
447  merge21S3(std::vector<std::string> &k1out,
448  ibis::array_t<Tk2> &k2out,
449  ibis::array_t<Tv> &vout,
450  const std::vector<std::string> &k1in1,
451  const ibis::array_t<Tk2> &k2in1,
452  const ibis::array_t<Tv> &vin1,
453  const std::vector<std::string> &k1in2,
454  const ibis::array_t<Tk2> &k2in2,
455  const ibis::array_t<Tv> &vin2,
457  static int
458  merge21S4(std::vector<std::string> &k1out,
459  std::vector<std::string> &k2out,
460  const std::vector<std::string> &k1in1,
461  const std::vector<std::string> &k2in1,
462  const std::vector<std::string> &k1in2,
463  const std::vector<std::string> &k2in2,
464  ibis::bord::column &v1,
465  const ibis::bord::column &v2,
467  template <typename Tv> static int
468  merge21S5(std::vector<std::string> &k1out,
469  std::vector<std::string> &k2out,
470  ibis::array_t<Tv> &vout,
471  const std::vector<std::string> &k1in1,
472  const std::vector<std::string> &k2in1,
473  const ibis::array_t<Tv> &vin1,
474  const std::vector<std::string> &k1in2,
475  const std::vector<std::string> &k2in2,
476  const ibis::array_t<Tv> &vin2,
478  template <typename Tk1> static int
479  merge21S6(ibis::array_t<Tk1> &k1out,
480  std::vector<std::string> &k2out,
481  const ibis::array_t<Tk1> &k1in1,
482  const std::vector<std::string> &k2in1,
483  const ibis::array_t<Tk1> &k1in2,
484  const std::vector<std::string> &k2in2,
485  ibis::bord::column &v1,
486  const ibis::bord::column &v2,
488  template <typename Tk1, typename Tv> static int
489  merge21S7(ibis::array_t<Tk1> &k1out,
490  std::vector<std::string> &k2out,
491  ibis::array_t<Tv> &vout,
492  const ibis::array_t<Tk1> &k1in1,
493  const std::vector<std::string> &k2in1,
494  const ibis::array_t<Tv> &vin1,
495  const ibis::array_t<Tk1> &k1in2,
496  const std::vector<std::string> &k2in2,
497  const ibis::array_t<Tv> &vin2,
499 
500 private:
501  // disallow copying.
502  bord(const bord&);
503  bord &operator=(const bord&);
504 
505  friend class cursor;
506 }; // ibis::bord
507 
518 public:
519  column(const ibis::bord* tbl, ibis::TYPE_T t, const char* name,
520  void *buf=0, const char* desc="", double low=DBL_MAX,
521  double high=-DBL_MAX);
522  column(ibis::TYPE_T t, const char *nm, void *st,
523  uint64_t *dim, uint64_t nd);
524  column(FastBitReadExtArray rd, void *ctx, uint64_t *dims, uint64_t nd,
525  ibis::TYPE_T t, const char *name, const char *desc="",
526  double lo=DBL_MAX, double hi=-DBL_MAX);
527  column(const ibis::bord*, const ibis::column&, void *buf);
528  column(const column &rhs);
529  virtual ~column();
530 
531  virtual ibis::fileManager::storage* getRawData() const;
532  virtual bool hasRawData() const;
533 
535  virtual long evaluateRange(const ibis::qContinuousRange &cmp,
536  const ibis::bitvector &mask,
537  ibis::bitvector &res) const;
538  virtual long evaluateRange(const ibis::qDiscreteRange &cmp,
539  const ibis::bitvector &mask,
540  ibis::bitvector &res) const;
541  virtual long stringSearch(const char*, ibis::bitvector&) const;
542  virtual long stringSearch(const std::vector<std::string>&,
543  ibis::bitvector&) const;
544  virtual long stringSearch(const char*) const;
545  virtual long stringSearch(const std::vector<std::string>&) const;
546  virtual long keywordSearch(const char*, ibis::bitvector&) const;
547  virtual long keywordSearch(const char*) const;
548  virtual long keywordSearch(const std::vector<std::string>&,
549  ibis::bitvector&) const;
550  virtual long keywordSearch(const std::vector<std::string>&) const;
551  virtual long patternSearch(const char*) const;
552  virtual long patternSearch(const char*, ibis::bitvector &) const;
553 
554  virtual array_t<signed char>* selectBytes(const ibis::bitvector&) const;
555  virtual array_t<unsigned char>* selectUBytes(const ibis::bitvector&) const;
556  virtual array_t<int16_t>* selectShorts(const ibis::bitvector&) const;
557  virtual array_t<uint16_t>* selectUShorts(const ibis::bitvector&) const;
558  virtual array_t<int32_t>* selectInts(const ibis::bitvector&) const;
559  virtual array_t<uint32_t>* selectUInts(const ibis::bitvector&) const;
560  virtual array_t<int64_t>* selectLongs(const ibis::bitvector&) const;
561  virtual array_t<uint64_t>* selectULongs(const ibis::bitvector&) const;
562  virtual array_t<float>* selectFloats(const ibis::bitvector&) const;
563  virtual array_t<double>* selectDoubles(const ibis::bitvector&) const;
564  virtual std::vector<std::string>*
565  selectStrings(const bitvector &mask) const;
566  virtual std::vector<ibis::opaque>*
567  selectOpaques(const bitvector &mask) const;
568 
569  virtual long append(const char* dt, const char* df, const uint32_t nold,
570  const uint32_t nnew, uint32_t nbuf, char* buf);
571  virtual long append(const void* vals, const ibis::bitvector &msk);
572  virtual long append(const ibis::column &scol, const ibis::bitvector &msk);
573  virtual long append(const ibis::column &scol,
574  const ibis::qContinuousRange &cnd);
575 
576  virtual void computeMinMax();
577  virtual void computeMinMax(const char *);
578  virtual void computeMinMax(const char *, double &, double &, bool &) const;
579 
580  void reverseRows();
581  int limit(uint32_t nr);
582 
583  virtual int getString(uint32_t, std::string &) const;
584  virtual int getValuesArray(void*) const;
585 
586  void*& getArray() {return buffer;}
587  void* getArray() const {return buffer;}
588  int dump(std::ostream &out, uint32_t i) const;
589 
590  bool equal_to(const column&) const;
591  inline bool equal_to(const column&, uint32_t, uint32_t) const;
592  inline bool less_than(const column&, uint32_t, uint32_t) const;
593  inline void append(const void*, uint32_t);
594  inline void append(const void*, uint32_t, const void*, uint32_t,
596  void addCounts(uint32_t);
597 
601  template <typename T> static int
602  addIncoreData(array_t<T>* &to, uint32_t nold, const array_t<T> &from,
603  const T special);
604  static int addStrings(std::vector<std::string>*&, uint32_t,
605  const std::vector<std::string>&);
606  static int addBlobs(std::vector<ibis::opaque>*&, uint32_t,
607  const std::vector<ibis::opaque>&);
608 
612  virtual const ibis::dictionary* getDictionary() const {return dic;}
614  void setDictionary(const ibis::dictionary* d) {dic = d;}
615 
616  const ibis::array_t<uint64_t>& getMeshShape() const {return shape;}
617  int setMeshShape(uint64_t*, uint64_t);
618 
619 protected:
623  void *buffer;
627  void *xmeta;
638 
639  column &operator=(const column&); // no assignment
640 }; // ibis::bord::column
641 
642 class FASTBIT_CXX_DLLSPEC ibis::bord::cursor : public ibis::table::cursor {
643 public:
644  cursor(const ibis::bord &t);
645  virtual ~cursor() {};
646 
647  virtual uint64_t nRows() const {return tab.nRows();}
648  virtual uint32_t nColumns() const {return tab.nColumns();}
649  virtual ibis::table::stringArray columnNames() const {
650  return tab.columnNames();}
651  virtual ibis::table::typeArray columnTypes() const {
652  return tab.columnTypes();}
653  virtual int fetch();
654  virtual int fetch(uint64_t);
655  virtual int fetch(ibis::table::row&);
656  virtual int fetch(uint64_t, ibis::table::row&);
657  virtual uint64_t getCurrentRowNumber() const {return curRow;}
658  virtual int dump(std::ostream &out, const char* del) const;
659 
660  virtual int getColumnAsByte(const char*, char&) const;
661  virtual int getColumnAsUByte(const char*, unsigned char&) const;
662  virtual int getColumnAsShort(const char*, int16_t&) const;
663  virtual int getColumnAsUShort(const char*, uint16_t&) const;
664  virtual int getColumnAsInt(const char*, int32_t&) const;
665  virtual int getColumnAsUInt(const char*, uint32_t&) const;
666  virtual int getColumnAsLong(const char*, int64_t&) const;
667  virtual int getColumnAsULong(const char*, uint64_t&) const;
668  virtual int getColumnAsFloat(const char*, float&) const;
669  virtual int getColumnAsDouble(const char*, double&) const;
670  virtual int getColumnAsString(const char*, std::string&) const;
671  virtual int getColumnAsOpaque(const char*, ibis::opaque&) const;
672 
673  virtual int getColumnAsByte(uint32_t, char&) const;
674  virtual int getColumnAsUByte(uint32_t, unsigned char&) const;
675  virtual int getColumnAsShort(uint32_t, int16_t&) const;
676  virtual int getColumnAsUShort(uint32_t, uint16_t&) const;
677  virtual int getColumnAsInt(uint32_t, int32_t&) const;
678  virtual int getColumnAsUInt(uint32_t, uint32_t&) const;
679  virtual int getColumnAsLong(uint32_t, int64_t&) const;
680  virtual int getColumnAsULong(uint32_t, uint64_t&) const;
681  virtual int getColumnAsFloat(uint32_t, float&) const;
682  virtual int getColumnAsDouble(uint32_t, double&) const;
683  virtual int getColumnAsString(uint32_t, std::string&) const;
684  virtual int getColumnAsOpaque(uint32_t, ibis::opaque&) const;
685 
686 protected:
687  struct bufferElement {
688  const char* cname;
689  ibis::TYPE_T ctype;
690  void* cval;
691  const ibis::dictionary* dic;
692 
693  bufferElement()
694  : cname(0), ctype(ibis::UNKNOWN_TYPE), cval(0), dic(0) {}
695  }; // bufferElement
696  typedef std::map<const char*, uint32_t, ibis::lessi> bufferMap;
697  std::vector<bufferElement> buffer;
698  bufferMap bufmap;
699  const ibis::bord &tab;
700  int64_t curRow; // the current row number
701 
702  void fillRow(ibis::table::row &res) const;
703  int dumpIJ(std::ostream&, uint32_t, uint32_t) const;
704 
705 private:
706  cursor();
707  cursor(const cursor&);
708  cursor &operator=(const cursor&);
709 }; // ibis::bord::cursor
710 
714 inline void
715 ibis::bord::copyValue(ibis::TYPE_T type, void* outbuf, size_t outpos,
716  const void* inbuf, size_t inpos) {
717  switch (type) {
718  default:
719  LOGGER(ibis::gVerbose > 0)
720  << "Warning -- bord::copyValue can not copy a value of type "
721  << ibis::TYPESTRING[(int)type];
722  break;
723  case ibis::BYTE: {
724  (*static_cast<array_t<signed char>*>(outbuf))[outpos]
725  = (*static_cast<const array_t<signed char>*>(inbuf))[inpos];
726  break;}
727  case ibis::UBYTE: {
728  (*static_cast<array_t<unsigned char>*>(outbuf))[outpos]
729  = (*static_cast<const array_t<unsigned char>*>(inbuf))[inpos];
730  break;}
731  case ibis::SHORT: {
732  (*static_cast<array_t<int16_t>*>(outbuf))[outpos]
733  = (*static_cast<const array_t<int16_t>*>(inbuf))[inpos];
734  break;}
735  case ibis::USHORT: {
736  (*static_cast<array_t<uint16_t>*>(outbuf))[outpos]
737  = (*static_cast<const array_t<uint16_t>*>(inbuf))[inpos];
738  break;}
739  case ibis::INT: {
740  (*static_cast<array_t<int32_t>*>(outbuf))[outpos]
741  = (*static_cast<const array_t<int32_t>*>(inbuf))[inpos];
742  break;}
743  case ibis::UINT: {
744  (*static_cast<array_t<uint32_t>*>(outbuf))[outpos]
745  = (*static_cast<const array_t<uint32_t>*>(inbuf))[inpos];
746  break;}
747  case ibis::LONG: {
748  (*static_cast<array_t<int64_t>*>(outbuf))[outpos]
749  = (*static_cast<const array_t<int64_t>*>(inbuf))[inpos];
750  break;}
751  case ibis::ULONG: {
752  (*static_cast<array_t<uint64_t>*>(outbuf))[outpos]
753  = (*static_cast<const array_t<uint64_t>*>(inbuf))[inpos];
754  break;}
755  case ibis::FLOAT: {
756  (*static_cast<array_t<float>*>(outbuf))[outpos]
757  = (*static_cast<const array_t<float>*>(inbuf))[inpos];
758  break;}
759  case ibis::DOUBLE: {
760  (*static_cast<array_t<double>*>(outbuf))[outpos]
761  = (*static_cast<const array_t<double>*>(inbuf))[inpos];
762  break;}
763  case ibis::BLOB: {
764  (*static_cast<std::vector<ibis::opaque>*>(outbuf))[outpos]
765  = (*static_cast<const std::vector<ibis::opaque>*>(inbuf))[inpos];
766  break;}
767  case ibis::TEXT:
768  case ibis::CATEGORY: {
769  (*static_cast<std::vector<std::string>*>(outbuf))[outpos]
770  = (*static_cast<const std::vector<std::string>*>(inbuf))[inpos];
771  break;}
772  }
773 } //ibis::bord::copyValue
774 
776 inline bool
778  uint32_t i, uint32_t j) const {
779  if (m_type != other.m_type) return false;
780  if (buffer == 0 || other.buffer == 0) return false;
781  if (buffer == other.buffer && i == j) return true;
782 
783  switch (m_type) {
784  default:
785  LOGGER(ibis::gVerbose > 0)
786  << "Warning -- bord::column[" << (thePart ? thePart->name() : "")
787  << '.' << m_name << "]::equal_to can not compare values of type "
788  << ibis::TYPESTRING[(int)m_type];
789  return false;
790  case ibis::BYTE: {
791  const ibis::array_t<signed char> &v0 =
792  *static_cast<const ibis::array_t<signed char>*>(buffer);
793  const ibis::array_t<signed char> &v1 =
794  *static_cast<const ibis::array_t<signed char>*>(other.buffer);
795  return (v0[i] == v1[j]);}
796  case ibis::UBYTE: {
797  const ibis::array_t<unsigned char> &v0 =
798  *static_cast<const ibis::array_t<unsigned char>*>(buffer);
799  const ibis::array_t<unsigned char> &v1 =
800  *static_cast<const ibis::array_t<unsigned char>*>(other.buffer);
801  return (v0[i] == v1[j]);}
802  case ibis::SHORT: {
803  const ibis::array_t<int16_t> &v0 =
804  *static_cast<const ibis::array_t<int16_t>*>(buffer);
805  const ibis::array_t<int16_t> &v1 =
806  *static_cast<const ibis::array_t<int16_t>*>(other.buffer);
807  return (v0[i] == v1[j]);}
808  case ibis::USHORT: {
809  const ibis::array_t<uint16_t> &v0 =
810  *static_cast<const ibis::array_t<uint16_t>*>(buffer);
811  const ibis::array_t<uint16_t> &v1 =
812  *static_cast<const ibis::array_t<uint16_t>*>(other.buffer);
813  return (v0[i] == v1[j]);}
814  case ibis::INT: {
815  const ibis::array_t<int32_t> &v0 =
816  *static_cast<const ibis::array_t<int32_t>*>(buffer);
817  const ibis::array_t<int32_t> &v1 =
818  *static_cast<const ibis::array_t<int32_t>*>(other.buffer);
819  return (v0[i] == v1[j]);}
820  case ibis::UINT: {
821  const ibis::array_t<uint32_t> &v0 =
822  *static_cast<const ibis::array_t<uint32_t>*>(buffer);
823  const ibis::array_t<uint32_t> &v1 =
824  *static_cast<const ibis::array_t<uint32_t>*>(other.buffer);
825  return (v0[i] == v1[j]);}
826  case ibis::LONG: {
827  const ibis::array_t<int64_t> &v0 =
828  *static_cast<const ibis::array_t<int64_t>*>(buffer);
829  const ibis::array_t<int64_t> &v1 =
830  *static_cast<const ibis::array_t<int64_t>*>(other.buffer);
831  return (v0[i] == v1[j]);}
832  case ibis::OID:
833  case ibis::ULONG: {
834  const ibis::array_t<uint64_t> &v0 =
835  *static_cast<const ibis::array_t<uint64_t>*>(buffer);
836  const ibis::array_t<uint64_t> &v1 =
837  *static_cast<const ibis::array_t<uint64_t>*>(other.buffer);
838  return (v0[i] == v1[j]);}
839  case ibis::FLOAT: {
840  const ibis::array_t<float> &v0 =
841  *static_cast<const ibis::array_t<float>*>(buffer);
842  const ibis::array_t<float> &v1 =
843  *static_cast<const ibis::array_t<float>*>(other.buffer);
844  return (v0[i] == v1[j]);}
845  case ibis::DOUBLE: {
846  const ibis::array_t<double> &v0 =
847  *static_cast<const ibis::array_t<double>*>(buffer);
848  const ibis::array_t<double> &v1 =
849  *static_cast<const ibis::array_t<double>*>(other.buffer);
850  return (v0[i] == v1[j]);}
851  case ibis::BLOB: {
852  const ibis::opaque &v0 =
853  (*static_cast<const std::vector<ibis::opaque>*>(buffer))[i];
854  const ibis::opaque &v1 =
855  (*static_cast<const std::vector<ibis::opaque>*>(other.buffer))[j];
856  bool match = (v0.size() == v1.size());
857  for (size_t j = 0; match && j < v0.size(); ++ j)
858  match = (v0.address()[j] == v1.address()[j]);
859  return match;}
860  case ibis::TEXT:
861  case ibis::CATEGORY: {
862  const std::string &v0 =
863  (*static_cast<const std::vector<std::string>*>(buffer))[i];
864  const std::string &v1 =
865  (*static_cast<const std::vector<std::string>*>(other.buffer))[j];
866  return (v0 == v1);}
867  }
868 } // ibis::bord::column::equal_to
869 
871 inline bool
873  uint32_t i, uint32_t j) const {
874  if (m_type != other.m_type) return false;
875  if (buffer == 0 || other.buffer == 0) return false;
876  if (buffer == other.buffer && i == j) return true;
877 
878  switch (m_type) {
879  default:
880  LOGGER(ibis::gVerbose > 0)
881  << "Warning -- bord::column[" << (thePart ? thePart->name() : "")
882  << '.' << m_name << "]::less_than can not compare values of type "
883  << ibis::TYPESTRING[(int)m_type];
884  return false;
885  case ibis::BYTE: {
886  const ibis::array_t<signed char> &v0 =
887  *static_cast<const ibis::array_t<signed char>*>(buffer);
888  const ibis::array_t<signed char> &v1 =
889  *static_cast<const ibis::array_t<signed char>*>(other.buffer);
890  return (v0[i] < v1[j]);}
891  case ibis::UBYTE: {
892  const ibis::array_t<unsigned char> &v0 =
893  *static_cast<const ibis::array_t<unsigned char>*>(buffer);
894  const ibis::array_t<unsigned char> &v1 =
895  *static_cast<const ibis::array_t<unsigned char>*>(other.buffer);
896  return (v0[i] < v1[j]);}
897  case ibis::SHORT: {
898  const ibis::array_t<int16_t> &v0 =
899  *static_cast<const ibis::array_t<int16_t>*>(buffer);
900  const ibis::array_t<int16_t> &v1 =
901  *static_cast<const ibis::array_t<int16_t>*>(other.buffer);
902  return (v0[i] < v1[j]);}
903  case ibis::USHORT: {
904  const ibis::array_t<uint16_t> &v0 =
905  *static_cast<const ibis::array_t<uint16_t>*>(buffer);
906  const ibis::array_t<uint16_t> &v1 =
907  *static_cast<const ibis::array_t<uint16_t>*>(other.buffer);
908  return (v0[i] < v1[j]);}
909  case ibis::INT: {
910  const ibis::array_t<int32_t> &v0 =
911  *static_cast<const ibis::array_t<int32_t>*>(buffer);
912  const ibis::array_t<int32_t> &v1 =
913  *static_cast<const ibis::array_t<int32_t>*>(other.buffer);
914  return (v0[i] < v1[j]);}
915  case ibis::UINT: {
916  const ibis::array_t<uint32_t> &v0 =
917  *static_cast<const ibis::array_t<uint32_t>*>(buffer);
918  const ibis::array_t<uint32_t> &v1 =
919  *static_cast<const ibis::array_t<uint32_t>*>(other.buffer);
920  return (v0[i] < v1[j]);}
921  case ibis::LONG: {
922  const ibis::array_t<int64_t> &v0 =
923  *static_cast<const ibis::array_t<int64_t>*>(buffer);
924  const ibis::array_t<int64_t> &v1 =
925  *static_cast<const ibis::array_t<int64_t>*>(other.buffer);
926  return (v0[i] < v1[j]);}
927  case ibis::OID:
928  case ibis::ULONG: {
929  const ibis::array_t<uint64_t> &v0 =
930  *static_cast<const ibis::array_t<uint64_t>*>(buffer);
931  const ibis::array_t<uint64_t> &v1 =
932  *static_cast<const ibis::array_t<uint64_t>*>(other.buffer);
933  return (v0[i] < v1[j]);}
934  case ibis::FLOAT: {
935  const ibis::array_t<float> &v0 =
936  *static_cast<const ibis::array_t<float>*>(buffer);
937  const ibis::array_t<float> &v1 =
938  *static_cast<const ibis::array_t<float>*>(other.buffer);
939  return (v0[i] < v1[j]);}
940  case ibis::DOUBLE: {
941  const ibis::array_t<double> &v0 =
942  *static_cast<const ibis::array_t<double>*>(buffer);
943  const ibis::array_t<double> &v1 =
944  *static_cast<const ibis::array_t<double>*>(other.buffer);
945  return (v0[i] < v1[j]);}
946  case ibis::BLOB: {
947  const ibis::opaque &v0 =
948  (*static_cast<const std::vector<ibis::opaque>*>(buffer))[i];
949  const ibis::opaque &v1 =
950  (*static_cast<const std::vector<ibis::opaque>*>(other.buffer))[j];
951  const size_t minlen = (v0.size() <= v1.size() ? v0.size() : v1.size());
952  int cmp = 0;
953  for (size_t j = 0; cmp == 0 && j < v0.size(); ++ j)
954  cmp = ((int)(v0.address()[j]) - (int)(v1.address()[j]));
955  if (cmp == 0 && v1.size() > minlen)
956  cmp = -1;
957  return (cmp < 0);}
958  case ibis::TEXT:
959  case ibis::CATEGORY: {
960  const std::string &v0 =
961  (*static_cast<const std::vector<std::string>*>(buffer))[i];
962  const std::string &v1 =
963  (*static_cast<const std::vector<std::string>*>(other.buffer))[j];
964  return (v0 < v1);}
965  }
966 } // ibis::bord::column::less_than
967 
972 inline void
973 ibis::bord::column::append(const void* c1, uint32_t i1) {
974  switch (m_type) {
975  default:
976  LOGGER(ibis::gVerbose > 0)
977  << "Warning -- bord::column[" << (thePart ? thePart->name() : "")
978  << '.' << m_name << "]::append can not handle data type "
979  << ibis::TYPESTRING[(int)m_type];
980  break;
981  case ibis::BYTE: {
983  *(static_cast<array_t<signed char>*>(buffer));
984  const ibis::array_t<signed char> &v1 =
985  *(static_cast<const array_t<signed char>*>(c1));
986  v0.push_back(v1[i1]);
987  break;}
988  case ibis::UBYTE: {
990  *(static_cast<array_t<unsigned char>*>(buffer));
991  const ibis::array_t<unsigned char> &v1 =
992  *(static_cast<const array_t<unsigned char>*>(c1));
993  v0.push_back(v1[i1]);
994  break;}
995  case ibis::SHORT: {
997  *(static_cast<array_t<int16_t>*>(buffer));
998  const ibis::array_t<int16_t> &v1 =
999  *(static_cast<const array_t<int16_t>*>(c1));
1000  v0.push_back(v1[i1]);
1001  break;}
1002  case ibis::USHORT: {
1004  *(static_cast<array_t<uint16_t>*>(buffer));
1005  const ibis::array_t<uint16_t> &v1 =
1006  *(static_cast<const array_t<uint16_t>*>(c1));
1007  v0.push_back(v1[i1]);
1008  break;}
1009  case ibis::INT: {
1011  *(static_cast<array_t<int32_t>*>(buffer));
1012  const ibis::array_t<int32_t> &v1 =
1013  *(static_cast<const array_t<int32_t>*>(c1));
1014  v0.push_back(v1[i1]);
1015  break;}
1016  case ibis::UINT: {
1018  *(static_cast<array_t<uint32_t>*>(buffer));
1019  const ibis::array_t<uint32_t> &v1 =
1020  *(static_cast<const array_t<uint32_t>*>(c1));
1021  v0.push_back(v1[i1]);
1022  break;}
1023  case ibis::LONG: {
1025  *(static_cast<array_t<int64_t>*>(buffer));
1026  const ibis::array_t<int64_t> &v1 =
1027  *(static_cast<const array_t<int64_t>*>(c1));
1028  v0.push_back(v1[i1]);
1029  break;}
1030  case ibis::ULONG: {
1032  *(static_cast<array_t<uint64_t>*>(buffer));
1033  const ibis::array_t<uint64_t> &v1 =
1034  *(static_cast<const array_t<uint64_t>*>(c1));
1035  v0.push_back(v1[i1]);
1036  break;}
1037  case ibis::FLOAT: {
1038  ibis::array_t<float> &v0 =
1039  *(static_cast<array_t<float>*>(buffer));
1040  const ibis::array_t<float> &v1 =
1041  *(static_cast<const array_t<float>*>(c1));
1042  v0.push_back(v1[i1]);
1043  break;}
1044  case ibis::DOUBLE: {
1045  ibis::array_t<double> &v0 =
1046  *(static_cast<array_t<double>*>(buffer));
1047  const ibis::array_t<double> &v1 =
1048  *(static_cast<const array_t<double>*>(c1));
1049  v0.push_back(v1[i1]);
1050  break;}
1051  case ibis::TEXT:
1052  case ibis::CATEGORY: {
1053  std::vector<std::string> &v0 =
1054  *(static_cast<std::vector<std::string>*>(buffer));
1055  const std::vector<std::string> &v1 =
1056  *(static_cast<const std::vector<std::string>*>(c1));
1057  v0.push_back(v1[i1]);
1058  break;}
1059  case ibis::BLOB: {
1060  std::vector<ibis::opaque> &v0 =
1061  *(static_cast<std::vector<ibis::opaque>*>(buffer));
1062  const std::vector<ibis::opaque> &v1 =
1063  *(static_cast<const std::vector<ibis::opaque>*>(c1));
1064  v0.push_back(v1[i1]);
1065  break;}
1066  }
1067 } // ibis::bord::column::append
1068 
1074 inline void
1075 ibis::bord::column::append(const void* c1, uint32_t i1,
1076  const void* c2, uint32_t i2,
1078  switch (m_type) {
1079  default:
1080  LOGGER(ibis::gVerbose > 0)
1081  << "Warning -- bord::column[" << (thePart ? thePart->name() : "")
1082  << '.' << m_name << "]::append can not handle data type "
1083  << ibis::TYPESTRING[(int)m_type] << " with aggregations";
1084  return;
1085  case ibis::BYTE: {
1087  *(static_cast<array_t<signed char>*>(buffer));
1088  const ibis::array_t<signed char> &v1 =
1089  *(static_cast<const array_t<signed char>*>(c1));
1090  const ibis::array_t<signed char> &v2 =
1091  *(static_cast<const array_t<signed char>*>(c2));
1092  signed char tmp = 0;
1093  switch (agg) {
1094  default:
1095  break;
1096  case ibis::selectClause::CNT:
1097  case ibis::selectClause::SUM:
1098  tmp = v1[i1] + v2[i2];
1099  break;
1100  case ibis::selectClause::MIN:
1101  tmp = (v1[i1] <= v2[i2] ? v1[i1] : v2[i2]);
1102  break;
1103  case ibis::selectClause::MAX:
1104  tmp = (v1[i1] >= v2[i2] ? v1[i1] : v2[i2]);
1105  break;
1106  }
1107  v0.push_back(tmp);
1108  break;}
1109  case ibis::UBYTE: {
1111  *(static_cast<array_t<unsigned char>*>(buffer));
1112  const ibis::array_t<unsigned char> &v1 =
1113  *(static_cast<const array_t<unsigned char>*>(c1));
1114  const ibis::array_t<unsigned char> &v2 =
1115  *(static_cast<const array_t<unsigned char>*>(c2));
1116  unsigned char tmp = 0;
1117  switch (agg) {
1118  default:
1119  break;
1120  case ibis::selectClause::CNT:
1121  case ibis::selectClause::SUM:
1122  tmp = v1[i1] + v2[i2];
1123  break;
1124  case ibis::selectClause::MIN:
1125  tmp = (v1[i1] <= v2[i2] ? v1[i1] : v2[i2]);
1126  break;
1127  case ibis::selectClause::MAX:
1128  tmp = (v1[i1] >= v2[i2] ? v1[i1] : v2[i2]);
1129  break;
1130  }
1131  v0.push_back(tmp);
1132  break;}
1133  case ibis::SHORT: {
1135  *(static_cast<array_t<int16_t>*>(buffer));
1136  const ibis::array_t<int16_t> &v1 =
1137  *(static_cast<const array_t<int16_t>*>(c1));
1138  const ibis::array_t<int16_t> &v2 =
1139  *(static_cast<const array_t<int16_t>*>(c2));
1140  int16_t tmp = 0;
1141  switch (agg) {
1142  default:
1143  break;
1144  case ibis::selectClause::CNT:
1145  case ibis::selectClause::SUM:
1146  tmp = v1[i1] + v2[i2];
1147  break;
1148  case ibis::selectClause::MIN:
1149  tmp = (v1[i1] <= v2[i2] ? v1[i1] : v2[i2]);
1150  break;
1151  case ibis::selectClause::MAX:
1152  tmp = (v1[i1] >= v2[i2] ? v1[i1] : v2[i2]);
1153  break;
1154  }
1155  v0.push_back(tmp);
1156  break;}
1157  case ibis::USHORT: {
1159  *(static_cast<array_t<uint16_t>*>(buffer));
1160  const ibis::array_t<uint16_t> &v1 =
1161  *(static_cast<const array_t<uint16_t>*>(c1));
1162  const ibis::array_t<uint16_t> &v2 =
1163  *(static_cast<const array_t<uint16_t>*>(c2));
1164  uint16_t tmp = 0;
1165  switch (agg) {
1166  default:
1167  break;
1168  case ibis::selectClause::CNT:
1169  case ibis::selectClause::SUM:
1170  tmp = v1[i1] + v2[i2];
1171  break;
1172  case ibis::selectClause::MIN:
1173  tmp = (v1[i1] <= v2[i2] ? v1[i1] : v2[i2]);
1174  break;
1175  case ibis::selectClause::MAX:
1176  tmp = (v1[i1] >= v2[i2] ? v1[i1] : v2[i2]);
1177  break;
1178  }
1179  v0.push_back(tmp);
1180  break;}
1181  case ibis::INT: {
1183  *(static_cast<array_t<int32_t>*>(buffer));
1184  const ibis::array_t<int32_t> &v1 =
1185  *(static_cast<const array_t<int32_t>*>(c1));
1186  const ibis::array_t<int32_t> &v2 =
1187  *(static_cast<const array_t<int32_t>*>(c2));
1188  int32_t tmp = 0;
1189  switch (agg) {
1190  default:
1191  break;
1192  case ibis::selectClause::CNT:
1193  case ibis::selectClause::SUM:
1194  tmp = v1[i1] + v2[i2];
1195  break;
1196  case ibis::selectClause::MIN:
1197  tmp = (v1[i1] <= v2[i2] ? v1[i1] : v2[i2]);
1198  break;
1199  case ibis::selectClause::MAX:
1200  tmp = (v1[i1] >= v2[i2] ? v1[i1] : v2[i2]);
1201  break;
1202  }
1203  v0.push_back(tmp);
1204  break;}
1205  case ibis::UINT: {
1207  *(static_cast<array_t<uint32_t>*>(buffer));
1208  const ibis::array_t<uint32_t> &v1 =
1209  *(static_cast<const array_t<uint32_t>*>(c1));
1210  const ibis::array_t<uint32_t> &v2 =
1211  *(static_cast<const array_t<uint32_t>*>(c2));
1212  uint32_t tmp = 0;
1213  switch (agg) {
1214  default:
1215  break;
1216  case ibis::selectClause::CNT:
1217  case ibis::selectClause::SUM:
1218  tmp = v1[i1] + v2[i2];
1219  break;
1220  case ibis::selectClause::MIN:
1221  tmp = (v1[i1] <= v2[i2] ? v1[i1] : v2[i2]);
1222  break;
1223  case ibis::selectClause::MAX:
1224  tmp = (v1[i1] >= v2[i2] ? v1[i1] : v2[i2]);
1225  break;
1226  }
1227  v0.push_back(tmp);
1228  break;}
1229  case ibis::LONG: {
1231  *(static_cast<array_t<int64_t>*>(buffer));
1232  const ibis::array_t<int64_t> &v1 =
1233  *(static_cast<const array_t<int64_t>*>(c1));
1234  const ibis::array_t<int64_t> &v2 =
1235  *(static_cast<const array_t<int64_t>*>(c2));
1236  int64_t tmp = 0;
1237  switch (agg) {
1238  default:
1239  break;
1240  case ibis::selectClause::CNT:
1241  case ibis::selectClause::SUM:
1242  tmp = v1[i1] + v2[i2];
1243  break;
1244  case ibis::selectClause::MIN:
1245  tmp = (v1[i1] <= v2[i2] ? v1[i1] : v2[i2]);
1246  break;
1247  case ibis::selectClause::MAX:
1248  tmp = (v1[i1] >= v2[i2] ? v1[i1] : v2[i2]);
1249  break;
1250  }
1251  v0.push_back(tmp);
1252  break;}
1253  case ibis::ULONG: {
1255  *(static_cast<array_t<uint64_t>*>(buffer));
1256  const ibis::array_t<uint64_t> &v1 =
1257  *(static_cast<const array_t<uint64_t>*>(c1));
1258  const ibis::array_t<uint64_t> &v2 =
1259  *(static_cast<const array_t<uint64_t>*>(c2));
1260  uint64_t tmp = 0;
1261  switch (agg) {
1262  default:
1263  break;
1264  case ibis::selectClause::CNT:
1265  case ibis::selectClause::SUM:
1266  tmp = v1[i1] + v2[i2];
1267  break;
1268  case ibis::selectClause::MIN:
1269  tmp = (v1[i1] <= v2[i2] ? v1[i1] : v2[i2]);
1270  break;
1271  case ibis::selectClause::MAX:
1272  tmp = (v1[i1] >= v2[i2] ? v1[i1] : v2[i2]);
1273  break;
1274  }
1275  v0.push_back(tmp);
1276  break;}
1277  case ibis::FLOAT: {
1278  ibis::array_t<float> &v0 =
1279  *(static_cast<array_t<float>*>(buffer));
1280  const ibis::array_t<float> &v1 =
1281  *(static_cast<const array_t<float>*>(c1));
1282  const ibis::array_t<float> &v2 =
1283  *(static_cast<const array_t<float>*>(c2));
1284  float tmp = 0;
1285  switch (agg) {
1286  default:
1287  break;
1288  case ibis::selectClause::CNT:
1289  case ibis::selectClause::SUM:
1290  tmp = v1[i1] + v2[i2];
1291  break;
1292  case ibis::selectClause::MIN:
1293  tmp = (v1[i1] <= v2[i2] ? v1[i1] : v2[i2]);
1294  break;
1295  case ibis::selectClause::MAX:
1296  tmp = (v1[i1] >= v2[i2] ? v1[i1] : v2[i2]);
1297  break;
1298  }
1299  v0.push_back(tmp);
1300  break;}
1301  case ibis::DOUBLE: {
1302  ibis::array_t<double> &v0 =
1303  *(static_cast<array_t<double>*>(buffer));
1304  const ibis::array_t<double> &v1 =
1305  *(static_cast<const array_t<double>*>(c1));
1306  const ibis::array_t<double> &v2 =
1307  *(static_cast<const array_t<double>*>(c2));
1308  double tmp = 0;
1309  switch (agg) {
1310  default:
1311  break;
1312  case ibis::selectClause::CNT:
1313  case ibis::selectClause::SUM:
1314  tmp = v1[i1] + v2[i2];
1315  break;
1316  case ibis::selectClause::MIN:
1317  tmp = (v1[i1] <= v2[i2] ? v1[i1] : v2[i2]);
1318  break;
1319  case ibis::selectClause::MAX:
1320  tmp = (v1[i1] >= v2[i2] ? v1[i1] : v2[i2]);
1321  break;
1322  }
1323  v0.push_back(tmp);
1324  break;}
1325  }
1326 } // ibis::bord::column::append
1327 
1329  ++ curRow;
1330  return (0 - (curRow >= (int64_t) tab.nRows()));
1331 } // ibis::bord::cursor::fetch
1332 
1333 inline int ibis::bord::cursor::fetch(uint64_t irow) {
1334  if (irow < tab.nRows()) {
1335  curRow = static_cast<int64_t>(irow);
1336  return 0;
1337  }
1338  else {
1339  return -1;
1340  }
1341 } // ibis::bord::cursor::fetch
1342 
1344  ++ curRow;
1345  if ((uint64_t) curRow < tab.nRows()) {
1346  fillRow(res);
1347  return 0;
1348  }
1349  else {
1350  return -1;
1351  }
1352 } // ibis::bord::cursor::fetch
1353 
1354 inline int ibis::bord::cursor::fetch(uint64_t irow, ibis::table::row &res) {
1355  if (irow < tab.nRows()) {
1356  curRow = static_cast<int64_t>(irow);
1357  fillRow(res);
1358  return 0;
1359  }
1360  else {
1361  return -1;
1362  }
1363 } // ibis::bord::cursor::fetch
1364 
1365 inline int
1366 ibis::bord::cursor::dumpIJ(std::ostream &out, uint32_t i,
1367  uint32_t j) const {
1368  if (buffer[j].cval == 0) return -1;
1369 
1370  switch (buffer[j].ctype) {
1371  case ibis::BYTE: {
1372  const array_t<const signed char>* vals =
1373  static_cast<const array_t<const signed char>*>(buffer[j].cval);
1374  out << (int) ((*vals)[i]);
1375  break;}
1376  case ibis::UBYTE: {
1377  const array_t<const unsigned char>* vals =
1378  static_cast<const array_t<const unsigned char>*>(buffer[j].cval);
1379  out << (unsigned int) ((*vals)[i]);
1380  break;}
1381  case ibis::SHORT: {
1382  const array_t<const int16_t>* vals =
1383  static_cast<const array_t<const int16_t>*>(buffer[j].cval);
1384  out << (*vals)[i];
1385  break;}
1386  case ibis::USHORT: {
1387  const array_t<const uint16_t>* vals =
1388  static_cast<const array_t<const uint16_t>*>(buffer[j].cval);
1389  out << (*vals)[i];
1390  break;}
1391  case ibis::INT: {
1392  const array_t<const int32_t>* vals =
1393  static_cast<const array_t<const int32_t>*>(buffer[j].cval);
1394  out << (*vals)[i];
1395  break;}
1396  case ibis::UINT: {
1397  const array_t<const uint32_t>* vals =
1398  static_cast<const array_t<const uint32_t>*>(buffer[j].cval);
1399  if (buffer[j].dic == 0) {
1400  out << (*vals)[i];
1401  }
1402  else if (buffer[j].dic->size() >= (*vals)[i]) {
1403  out << buffer[j].dic->operator[]((*vals)[i]);
1404  }
1405  else {
1406  out << (*vals)[i];
1407  }
1408  break;}
1409  case ibis::LONG: {
1410  const array_t<const int64_t>* vals =
1411  static_cast<const array_t<const int64_t>*>(buffer[j].cval);
1412  out << (*vals)[i];
1413  break;}
1414  case ibis::ULONG: {
1415  const array_t<const uint64_t>* vals =
1416  static_cast<const array_t<const uint64_t>*>(buffer[j].cval);
1417  out << (*vals)[i];
1418  break;}
1419  case ibis::FLOAT: {
1420  const array_t<const float>* vals =
1421  static_cast<const array_t<const float>*>(buffer[j].cval);
1422  out << (*vals)[i];
1423  break;}
1424  case ibis::DOUBLE: {
1425  const array_t<const double>* vals =
1426  static_cast<const array_t<const double>*>(buffer[j].cval);
1427  out << (*vals)[i];
1428  break;}
1429  case ibis::TEXT:
1430  case ibis::CATEGORY: {
1431  const std::vector<std::string>* vals =
1432  static_cast<const std::vector<std::string>*>(buffer[j].cval);
1433  out << '"' << (*vals)[i] << '"';
1434  break;}
1435  default: {
1436  return -2;}
1437  }
1438  return 0;
1439 } // ibis::bord::cursor::dumpIJ
1440 
1441 inline int
1442 ibis::bord::cursor::getColumnAsByte(const char* cn, char &val) const {
1443  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1444  return -1;
1445  bufferMap::const_iterator it = bufmap.find(cn);
1446  if (it != bufmap.end())
1447  return getColumnAsByte((*it).second, val);
1448  else
1449  return -2;
1450 } // ibis::bord::cursor::getColumnAsByte
1451 
1452 inline int
1454  unsigned char &val) const {
1455  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1456  return -1;
1457  bufferMap::const_iterator it = bufmap.find(cn);
1458  if (it != bufmap.end())
1459  return getColumnAsUByte((*it).second, val);
1460  else
1461  return -2;
1462 } // ibis::bord::cursor::getColumnAsUByte
1463 
1464 inline int
1465 ibis::bord::cursor::getColumnAsShort(const char* cn, int16_t &val) const {
1466  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1467  return -1;
1468  bufferMap::const_iterator it = bufmap.find(cn);
1469  if (it != bufmap.end())
1470  return getColumnAsShort((*it).second, val);
1471  else
1472  return -2;
1473 } // ibis::bord::cursor::getColumnAsShort
1474 
1475 inline int
1476 ibis::bord::cursor::getColumnAsUShort(const char* cn, uint16_t &val) const {
1477  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1478  return -1;
1479  bufferMap::const_iterator it = bufmap.find(cn);
1480  if (it != bufmap.end())
1481  return getColumnAsUShort((*it).second, val);
1482  else
1483  return -2;
1484 } // ibis::bord::cursor::getColumnAsUShort
1485 
1486 inline int
1487 ibis::bord::cursor::getColumnAsInt(const char* cn, int32_t &val) const {
1488  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1489  return -1;
1490  bufferMap::const_iterator it = bufmap.find(cn);
1491  if (it != bufmap.end())
1492  return getColumnAsInt((*it).second, val);
1493  else
1494  return -2;
1495 } // ibis::bord::cursor::getColumnAsInt
1496 
1497 inline int
1498 ibis::bord::cursor::getColumnAsUInt(const char* cn, uint32_t &val) const {
1499  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1500  return -1;
1501  bufferMap::const_iterator it = bufmap.find(cn);
1502  if (it != bufmap.end())
1503  return getColumnAsUInt((*it).second, val);
1504  else
1505  return -2;
1506 } // ibis::bord::cursor::getColumnAsUInt
1507 
1508 inline int
1509 ibis::bord::cursor::getColumnAsLong(const char* cn, int64_t &val) const {
1510  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1511  return -1;
1512  bufferMap::const_iterator it = bufmap.find(cn);
1513  if (it != bufmap.end())
1514  return getColumnAsLong((*it).second, val);
1515  else
1516  return -2;
1517 } // ibis::bord::cursor::getColumnAsLong
1518 
1519 inline int
1520 ibis::bord::cursor::getColumnAsULong(const char* cn, uint64_t &val) const {
1521  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1522  return -1;
1523  bufferMap::const_iterator it = bufmap.find(cn);
1524  if (it != bufmap.end())
1525  return getColumnAsULong((*it).second, val);
1526  else
1527  return -2;
1528 } // ibis::bord::cursor::getColumnAsULong
1529 
1530 inline int
1531 ibis::bord::cursor::getColumnAsFloat(const char* cn, float &val) const {
1532  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1533  return -1;
1534  bufferMap::const_iterator it = bufmap.find(cn);
1535  if (it != bufmap.end())
1536  return getColumnAsFloat((*it).second, val);
1537  else
1538  return -2;
1539 } // ibis::bord::cursor::getColumnAsFloat
1540 
1541 inline int
1542 ibis::bord::cursor::getColumnAsDouble(const char* cn, double &val) const {
1543  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1544  return -1;
1545  bufferMap::const_iterator it = bufmap.find(cn);
1546  if (it != bufmap.end())
1547  return getColumnAsDouble((*it).second, val);
1548  else
1549  return -2;
1550 } // ibis::bord::cursor::getColumnAsDouble
1551 
1552 inline int
1554  std::string &val) const {
1555  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1556  return -1;
1557  bufferMap::const_iterator it = bufmap.find(cn);
1558  if (it != bufmap.end())
1559  return getColumnAsString((*it).second, val);
1560  else
1561  return -2;
1562 } // ibis::bord::cursor::getColumnAsString
1563 
1564 inline int
1566  ibis::opaque &val) const {
1567  if (curRow < 0 || curRow >= (int64_t) tab.nRows() || cn == 0 || *cn == 0)
1568  return -1;
1569  bufferMap::const_iterator it = bufmap.find(cn);
1570  if (it != bufmap.end())
1571  return getColumnAsOpaque((*it).second, val);
1572  else
1573  return -2;
1574 } // ibis::bord::cursor::getColumnAsOpaque
1575 #endif // IBIS_BORD_H
static int merge21T2(ibis::array_t< Tk1 > &k1out, ibis::array_t< Tk2 > &k2out, const ibis::array_t< Tk1 > &k1in1, const ibis::array_t< Tk2 > &k2in1, const ibis::array_t< Tk1 > &k1in2, const ibis::array_t< Tk2 > &k2in2, ibis::bord::column &v1, const ibis::bord::column &v2, ibis::selectClause::AGREGADO ag)
Merge two key columns with one value column.
Definition: bordm.cpp:5643
static int merge12(ibis::bord::column &, ibis::bord::column &, ibis::bord::column &, const ibis::bord::column &, const ibis::bord::column &, const ibis::bord::column &, ibis::selectClause::AGREGADO, ibis::selectClause::AGREGADO)
Merge two aggregations sharing the same key.
Definition: bordm.cpp:1987
virtual int64_t getColumnAsShorts(const char *, int16_t *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: bord.cpp:622
virtual int getColumnAsOpaque(const char *, ibis::opaque &) const
Definition: bord.h:1565
int(* FastBitReadExtArray)(void *context, uint64_t nd, uint64_t *starts, uint64_t *counts, void *data)
A function prototype for reading a portion of an external array.
Definition: const.h:365
!< One bit per record, represented by a bit vector.
Definition: table.h:44
virtual int64_t getColumnAsDoubles(const char *, double *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: bord.cpp:1143
virtual int64_t getColumnAsULongs(const char *, uint64_t *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: bord.cpp:982
ibis::bord * evaluateTerms(const ibis::selectClause &, const char *) const
Evaluate the arithmetic expressions in the select clause to derive an in-memory data table...
Definition: bord.cpp:4289
virtual void dumpNames(std::ostream &, const char *) const
Print all column names on one line.
Definition: bord.cpp:2085
virtual int getColumnAsUInt(const char *, uint32_t &) const
Definition: bord.h:1498
long sortStrings(std::vector< std::string > &vals, array_t< uint32_t > &starts, array_t< uint32_t > &idxout, const array_t< uint32_t > &idxin, bool ascending) const
Sort the string values.
Definition: bord.cpp:4072
bool equal_to(const column &) const
Does this column have the same values as the other.
Definition: bord.cpp:12036
virtual int64_t getColumnAsUInts(const char *, uint32_t *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: bord.cpp:808
static ibis::bord * groupbya(const ibis::bord &, const ibis::selectClause &)
Perform the aggregation operations specified in the select clause.
Definition: bord.cpp:3342
virtual array_t< uint16_t > * selectUShorts(const ibis::bitvector &) const
Return selected rows of the column in an array_t object.
Definition: bord.cpp:7111
virtual array_t< int32_t > * selectInts(const ibis::bitvector &) const
Return selected rows of the column in an array_t object.
Definition: bord.cpp:7248
int restoreCategoriesAsStrings(const ibis::category &)
Convert the integer representation back to the string representation.
Definition: bord.cpp:11525
virtual long append(const char *dt, const char *df, const uint32_t nold, const uint32_t nnew, uint32_t nbuf, char *buf)
Append new data in directory df to the end of existing data in dt.
Definition: bord.cpp:11549
FastBitReadExtArray xreader
Reader for externally managed data.
Definition: bord.h:625
virtual int buildIndexes(const ibis::table::stringArray &)
The following functions deal with auxillary data for accelerating query processing, primarily for building indexes.
Definition: bord.h:141
Definition: bord.h:642
static int merge0(std::vector< ibis::bord::column * > &, const std::vector< ibis::bord::column * > &, const std::vector< ibis::selectClause::AGREGADO > &)
Merge values according to the given operators.
Definition: bordm.cpp:275
uint32_t nColumns() const
Return the number of attributes in the partition.
Definition: part.h:84
void copyColumn(const char *, ibis::TYPE_T &, void *&, const ibis::dictionary *&) const
Copy the type and values of the named column.
Definition: bord.cpp:4590
virtual int64_t getColumnAsBytes(const char *, char *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: bord.cpp:571
static int merge21(ibis::bord::column &k11, ibis::bord::column &k21, ibis::bord::column &v1, const ibis::bord::column &k12, const ibis::bord::column &k22, const ibis::bord::column &v2, ibis::selectClause::AGREGADO ag)
Merge two key columns with one value column.
Definition: bordm.cpp:5394
Simple range condition.
Definition: qExpr.h:252
The storage class treats all memory as char*.
Definition: fileManager.h:237
!< Four-byte signed integers, internally int32_t.
Definition: table.h:35
virtual table * groupby(const ibis::table::stringArray &) const
Perform aggregate functions on the current table.
Definition: bord.cpp:2998
void addCounts(uint32_t)
Extend the buffer to have nr elements.
Definition: bord.cpp:11967
virtual ~column()
Destructor.
Definition: bord.cpp:5624
The top level query expression object.
Definition: qExpr.h:36
virtual int buildIndexes(const char *iopt, int nthr)
Make sure indexes for all columns are available.
Definition: part.cpp:6500
A simple struct for storing a row of a table.
Definition: table.h:395
virtual array_t< uint32_t > * selectUInts(const ibis::bitvector &) const
Can be called on columns of unsigned integral types, UINT, CATEGORY, USHORT, and UBYTE.
Definition: bord.cpp:7573
ibis::array_t< uint64_t > vals
An array of size 4*ndim with ndim quadruples of (start, stride, count, block).
Definition: bord.h:38
int64_t computeHits(const char *cond) const
Compute the number of hits.
Definition: bord.cpp:2003
A class to represent the select clause.
Definition: selectClause.h:112
int merge(const ibis::bord &, const ibis::selectClause &)
Merge the incoming data partition with this one.
Definition: bordm.cpp:20
virtual table * select(const char *sel, const char *cond) const
Given a set of column names and a set of selection conditions, compute another table that represents ...
Definition: bord.cpp:1996
virtual int fetch()
Make the next row of the data set available for retrieval.
Definition: bord.h:1328
long reorderStrings(std::vector< std::string > &vals, const array_t< uint32_t > &ind) const
Reorder the vector of strings.
Definition: bord.cpp:4241
Byte array.
Definition: table.h:56
The current implementation of FastBit is code named IBIS; most data structures and functions are in t...
Definition: bord.h:16
Cursor class for row-wise data accesses.
Definition: table.h:835
!< Eight-byte unsigned integers, internally uint64_t.
Definition: table.h:38
The class to represent a column of a data partition.
Definition: column.h:65
virtual int getColumnAsUShort(const char *, uint16_t &) const
Definition: bord.h:1476
static int merge21T1(ibis::array_t< Tk1 > &k1out, const ibis::array_t< Tk1 > &k1in1, const ibis::array_t< Tk1 > &k1in2, ibis::bord::column &k21, ibis::bord::column &v1, const ibis::bord::column &k22, const ibis::bord::column &v2, ibis::selectClause::AGREGADO ag)
Merge two key columns with one value column.
Definition: bordm.cpp:5518
virtual void indexSpec(const char *, const char *)
Replace the current indexing option.
Definition: bord.h:144
static int merge20T2(ibis::array_t< Tk1 > &k1out, ibis::array_t< Tk2 > &k2out, std::vector< ibis::bord::column * > &vout, const ibis::array_t< Tk1 > &k1in1, const ibis::array_t< Tk2 > &k2in1, const std::vector< ibis::bord::column * > &vin1, const ibis::array_t< Tk1 > &k1in2, const ibis::array_t< Tk2 > &k2in2, const std::vector< ibis::bord::column * > &vin2, const std::vector< ibis::selectClause::AGREGADO > &agg)
Merge in-memory table with two keys and more than one value columns.
Definition: bordm.cpp:4919
virtual ibis::table::cursor * createCursor() const
Create a cursor object to perform row-wise data access.
Definition: bord.cpp:4995
static int merge21T3(ibis::array_t< Tk1 > &k1out, ibis::array_t< Tk2 > &k2out, ibis::array_t< Tv > &vout, const ibis::array_t< Tk1 > &k1in1, const ibis::array_t< Tk2 > &k2in1, const ibis::array_t< Tv > &vin1, const ibis::array_t< Tk1 > &k1in2, const ibis::array_t< Tk2 > &k2in2, const ibis::array_t< Tv > &vin2, ibis::selectClause::AGREGADO av)
Merge two key columns with one value column.
Definition: bordm.cpp:5780
virtual array_t< unsigned char > * selectUBytes(const ibis::bitvector &) const
Return selected rows of the column in an array_t object.
Definition: bord.cpp:6842
void push_back(const T &elm)
Add one element from the back.
Definition: array_t.h:204
int restoreCategoriesAsStrings(const ibis::part &)
Convert the integer representation of categorical columns back to the string representation.
Definition: bord.cpp:4570
static int merger(std::vector< ibis::bord::column * > &, std::vector< ibis::bord::column * > &, const std::vector< ibis::bord::column * > &, const std::vector< ibis::bord::column * > &, const std::vector< ibis::selectClause::AGREGADO > &)
Merge values from two partial results and place the final resules in the first argument.
Definition: bordm.cpp:172
virtual int64_t getColumnAsOpaques(const char *, std::vector< ibis::opaque > &, uint64_t=0, uint64_t=0) const
Retrieve the blobs as ibis::opaque objects.
Definition: bord.cpp:1659
virtual void orderby(const stringArray &)=0
Reorder the rows.
void * buffer
The in-memory storage.
Definition: bord.h:623
!< Two-byte unsigned integers, internally uint16_t.
Definition: table.h:34
virtual int getColumnAsUByte(const char *, unsigned char &) const
Definition: bord.h:1453
virtual int getColumnAsDouble(const char *, double &) const
Definition: bord.h:1542
virtual void computeMinMax()
Compute the actual min/max values.
Definition: bord.cpp:5710
refHolder< T > ref(T &r)
A function template to produce refHolder.
Definition: util.h:1258
virtual int64_t getColumnAsUShorts(const char *, uint16_t *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: bord.cpp:679
virtual const ibis::dictionary * getDictionary() const
Return the dictionary associated with the column.
Definition: bord.h:612
virtual int dumpJSON(std::ostream &, uint64_t) const
Dump out the first nr rows in JSON format.
Definition: bord.cpp:2146
virtual ibis::table::typeArray columnTypes() const
!< Return column names.
Definition: bord.cpp:567
virtual int getValuesArray(void *) const
Makes a copy of the in-memory data.
Definition: bord.cpp:11127
virtual int64_t getColumnAsLongs(const char *, int64_t *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: bord.cpp:865
virtual long stringSearch(const char *, ibis::bitvector &) const
Locate the strings that match the given string.
Definition: bord.cpp:6273
static int merge11T(ibis::array_t< Tk > &kout, ibis::array_t< Tv > &vout, const ibis::array_t< Tk > &kin1, const ibis::array_t< Tv > &vin1, const ibis::array_t< Tk > &kin2, const ibis::array_t< Tv > &vin2, ibis::selectClause::AGREGADO agg)
Template to perform merge operation with one column as key and one column as value.
Definition: bordm.cpp:1841
Arbitrary null-terminated strings.
Definition: table.h:51
hyperslab()
Default constructor.
Definition: bord.h:27
void setDictionary(const ibis::dictionary *d)
Assign the dictionary to use.
Definition: bord.h:614
virtual int dump(std::ostream &out, const char *del) const
Print the content of the current row.
Definition: bord.cpp:12173
Definition: bord.h:687
int setMeshShape(uint64_t *, uint64_t)
Specify the shape of the array.
Definition: bord.cpp:12128
!< Two-byte signed integers, internally int16_t.
Definition: table.h:33
!< Eight-byte signed integers, internally int64_t.
Definition: table.h:37
virtual int64_t getColumnAsStrings(const char *, std::vector< std::string > &, uint64_t=0, uint64_t=0) const
Retrieve the null-terminated strings as a vector of std::string objects.
Definition: bord.cpp:1420
virtual array_t< uint64_t > * selectULongs(const ibis::bitvector &) const
Return selected rows of the column in an array_t object.
Definition: bord.cpp:8283
int limit(uint32_t nr)
Reduce the number of rows stored in this column object to nr.
Definition: bord.cpp:11424
!< One-byte unsigned integers, internally unsigned char.
Definition: table.h:32
int limit(uint32_t)
Reset the number of rows in the data partition to be nr.
Definition: bord.cpp:4272
virtual array_t< int16_t > * selectShorts(const ibis::bitvector &) const
Return selected rows of the column in an array_t object.
Definition: bord.cpp:6925
virtual long getHistogram3D(const char *, const char *, double, double, double, const char *, double, double, double, const char *, double, double, double, std::vector< uint32_t > &) const
Compute a three-dimensional histogram on the named columns.
Definition: bord.cpp:1931
The abstract table class.
Definition: table.h:77
!< Four-byte IEEE floating-point numbers, internally float.
Definition: table.h:39
virtual long patternSearch(const char *) const
Compute an estimate of the maximum number of possible matches.
Definition: bord.cpp:6621
virtual int64_t getColumnAsUBytes(const char *, unsigned char *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: bord.cpp:597
Defines minor utility functions and common classes used by FastBit.
ibis::table * xgroupby(const ibis::selectClause &) const
The actual function to perform the group by operation.
Definition: bord.cpp:3009
virtual array_t< int64_t > * selectLongs(const ibis::bitvector &) const
Can be called on all integral types.
Definition: bord.cpp:7783
The class ibis::part represents a partition of a relational table.
Definition: part.h:27
virtual double getColumnMin(const char *) const
Compute the minimum of all valid values in the name column.
Definition: bord.cpp:1877
TYPE_T
Supported data types.
Definition: table.h:25
virtual array_t< double > * selectDoubles(const ibis::bitvector &) const
Put the selected values into an array as doubles.
Definition: bord.cpp:9088
An in-memory version of ibis::column.
Definition: bord.h:517
virtual array_t< signed char > * selectBytes(const ibis::bitvector &) const
Retrieve selected 1-byte integer values.
Definition: bord.cpp:6710
virtual int buildIndex(const char *, const char *)
The following functions deal with auxillary data for accelerating query processing, primarily for building indexes.
Definition: bord.h:140
static int addIncoreData(array_t< T > *&to, uint32_t nold, const array_t< T > &from, const T special)
Append new data (in from) to a larger array (pointed to by to).
Definition: bord.cpp:11981
virtual long evaluateRange(const ibis::qContinuousRange &cmp, const ibis::bitvector &mask, ibis::bitvector &res) const
Compute the exact answer.
Definition: column.cpp:6029
virtual int getColumnAsULong(const char *, uint64_t &) const
Definition: bord.h:1520
virtual bool hasRawData() const
Does the raw data file exist?
Definition: bord.cpp:12146
Declares ibis::selectClause class.
virtual int getColumnAsInt(const char *, int32_t &) const
Definition: bord.h:1487
static void copyValue(ibis::TYPE_T type, void *outbuf, size_t outpos, const void *inbuf, size_t inpos)
Copy a single value from inbuf to outbuf.
Definition: bord.h:715
static ibis::bord * groupbyc(const ibis::bord &, const ibis::selectClause &)
The function to perform the final computations specified by the select clause.
Definition: bord.cpp:3519
Class ibis::bord stores all its data in memory.
Definition: bord.h:51
virtual int getColumnAsFloat(const char *, float &) const
Definition: bord.h:1531
const ibis::dictionary * dic
A dictionary.
Definition: bord.h:630
virtual const char * indexSpec(const char *) const
Retrieve the current indexing option.
Definition: bord.h:145
static int merge20T1(ibis::array_t< Tk1 > &k1out, const ibis::array_t< Tk1 > &k1in1, const ibis::array_t< Tk1 > &k1in2, ibis::bord::column &k21, std::vector< ibis::bord::column * > &vin1, const ibis::bord::column &k22, const std::vector< ibis::bord::column * > &vin2, const std::vector< ibis::selectClause::AGREGADO > &agg)
Merge with two key columns and arbitrary number of value columns.
Definition: bordm.cpp:4778
A specialized low-cardinality text field.
Definition: category.h:120
virtual ibis::table::stringArray columnNames() const
Definition: bord.cpp:563
A special eight-byte ID type for internal use.
Definition: table.h:29
virtual int dump(std::ostream &, const char *) const
Print the values in ASCII form to the specified output stream.
Definition: bord.cpp:2138
virtual long getHistogram2D(const char *, const char *, double, double, double, const char *, double, double, double, std::vector< uint32_t > &) const
Compute a two-dimension histogram on columns cname1 and cname2.
Definition: bord.cpp:1906
virtual array_t< float > * selectFloats(const ibis::bitvector &) const
Put selected values of a float column into an array.
Definition: bord.cpp:8784
virtual void orderby(const ibis::table::stringArray &)
Reorder the rows.
Definition: bord.cpp:3605
virtual long reorder()
Sort rows with the lowest cardinality column first.
Definition: bord.cpp:3615
virtual int64_t getColumnAsInts(const char *, int32_t *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: bord.cpp:721
static int merge10(ibis::bord::column &, std::vector< ibis::bord::column * > &, const ibis::bord::column &, const std::vector< ibis::bord::column * > &, const std::vector< ibis::selectClause::AGREGADO > &)
Merge with one key column and an arbitrary number of value columns.
Definition: bordm.cpp:402
ibis::TYPE_T m_type
!< The entries marked 1 are valid.
Definition: column.h:413
virtual int getColumnAsShort(const char *, int16_t &) const
Definition: bord.h:1465
long reorderValues(const char *fname, array_t< uint32_t > &starts, array_t< uint32_t > &indout, const array_t< uint32_t > &indin, bool ascending)
Write the named data file in a segmented sorted order.
Definition: parti.cpp:529
virtual void estimate(const char *cond, uint64_t &nmin, uint64_t &nmax) const
Estimate the number of rows satisfying the selection conditions.
Definition: bord.cpp:1960
long sortValues(array_t< T > &vals, array_t< uint32_t > &starts, array_t< uint32_t > &indout, const array_t< uint32_t > &indin, bool ascending) const
A simple sorting procedure.
Definition: bord.cpp:3927
AGREGADO
Functions related to internal aggregation operations.
Definition: selectClause.h:164
A data structure to represent a sequence of bits.
Definition: bitvector.h:62
virtual int getColumnAsString(const char *, std::string &) const
Definition: bord.h:1553
virtual long getHistogram(const char *, const char *, double, double, double, std::vector< uint32_t > &) const
Definition: bord.cpp:1885
Class ibis::hyperslab for recording a HDF5 style hyperslab.
Definition: bord.h:23
virtual int backup(const char *dir, const char *tname=0, const char *tdesc=0) const
Write the content of partition into the specified directory dir.
Definition: bord.cpp:2586
virtual double getColumnMax(const char *) const
Compute the maximum of all valid values in the name column.
Definition: bord.cpp:1881
Unknown type, a place holder. Can not process data of this type!
Definition: table.h:27
static int merge11(ibis::bord::column &, ibis::bord::column &, const ibis::bord::column &, const ibis::bord::column &, ibis::selectClause::AGREGADO)
Function to merge one column as key and one column as value.
Definition: bordm.cpp:648
virtual ibis::fileManager::storage * getRawData() const
Retrieve the raw data buffer as an ibis::fileManager::storage.
Definition: bord.cpp:5643
virtual int64_t getColumnAsFloats(const char *, float *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: bord.cpp:1054
virtual table * select(const char *sel, const char *cond) const =0
Given a set of column names and a set of selection conditions, compute another table that represents ...
virtual void describe(std::ostream &) const
!< Return data types.
Definition: bord.cpp:2019
FastBit Table Interface.
virtual void reverseRows()
Reverse the order of the rows.
Definition: bord.cpp:4259
virtual int getColumnAsLong(const char *, int64_t &) const
Definition: bord.h:1509
const char * name() const
Name of the column.
Definition: column.h:78
int append(const ibis::selectClause &, const ibis::part &, const ibis::bitvector &)
Append the values marked 1 to this data partition.
Definition: bord.cpp:4715
!< One-byte signed integers, internally char.
Definition: table.h:31
virtual int getColumnAsByte(const char *, char &) const
Definition: bord.h:1442
virtual uint64_t getCurrentRowNumber() const
Return the current row number.
Definition: bord.h:657
unsigned ndim
The number of dimensions of the mesh.
Definition: bord.h:34
virtual long keywordSearch(const char *, ibis::bitvector &) const
Find the given keyword and return the rows.
Definition: bord.cpp:6458
virtual int getPartitions(ibis::constPartList &) const
Retrieve the list of partitions.
Definition: table.h:225
const char ** TYPESTRING
Human readable version of the enumeration types.
Definition: column.cpp:39
A discrete range expression.
Definition: qExpr.h:337
virtual uint64_t nRows() const
The number of rows in this table.
Definition: bord.h:65
!< Four-byte unsigned integers, internally uint32_t.
Definition: table.h:36
virtual std::vector< std::string > * selectStrings(const bitvector &mask) const
Output the selected values as strings.
Definition: bord.cpp:9734
Provide a dual-directional mapping between strings and integers.
Definition: dict-0.h:19
virtual int buildIndexes(const char *)
Create indexes for every column of the table.
Definition: bord.h:142
uint32_t nEvents
!< List of the columns.
Definition: part.h:731
static int merge0T(ibis::array_t< T > &, const ibis::array_t< T > &, ibis::selectClause::AGREGADO)
Template function to perform the merger operations on arrays with matching keys.
Definition: bordm.cpp:376
column(const ibis::bord *tbl, ibis::TYPE_T t, const char *name, void *buf=0, const char *desc="", double low=DBL_MAX, double high=-DBL_MAX)
Constructor.
Definition: bord.cpp:5222
void clear()
Clear the existing content.
Definition: bord.cpp:556
ibis::array_t< uint64_t > shape
Shape of the mesh for the data.
Definition: bord.h:637
bool less_than(const column &, uint32_t, uint32_t) const
Is the ith value of this column less than the jth value of other?
Definition: bord.h:872
Define a dictionary data structure used by ibis::category.
void * xmeta
Context to be passed back to reader.
Definition: bord.h:627
Define the class ibis::part.
bord()
Default constructor. Creates a empty unnamed data partition.
Definition: bord.h:206
virtual long evaluateRange(const ibis::qContinuousRange &cmp, const ibis::bitvector &mask, ibis::bitvector &res) const
Compute the exact answer.
Definition: bord.cpp:5801
static int merge10T(ibis::array_t< Tk > &kout, std::vector< ibis::bord::column * > &vout, const ibis::array_t< Tk > &kin1, const std::vector< ibis::bord::column * > &vin1, const ibis::array_t< Tk > &kin2, const std::vector< ibis::bord::column * > &vin2, const std::vector< ibis::selectClause::AGREGADO > &agg)
Perform merge operation with one key column and an arbitrary number of value columns.
Definition: bordm.cpp:532
virtual int getString(uint32_t, std::string &) const
Return the string at the ith row.
Definition: bord.cpp:10665
void tobitvector(uint32_t, const uint64_t *, ibis::bitvector &) const
Convert to a bitvector.
Definition: bord.cpp:13024
static int merge20(ibis::bord::column &k11, ibis::bord::column &k21, std::vector< ibis::bord::column * > &v1, const ibis::bord::column &k12, const ibis::bord::column &k22, const std::vector< ibis::bord::column * > &v2, const std::vector< ibis::selectClause::AGREGADO > &agg)
Merge with two key columns and arbitrary number of value columns.
Definition: bordm.cpp:4655
virtual uint32_t nColumns() const
The number of columns in this table.
Definition: bord.h:66

Make It A Bit Faster
Contact us
Disclaimers
FastBit source code
FastBit mailing list archive