22 const char* colname,
const char* condr,
const char* conds);
25 virtual void estimate(uint64_t& nmin, uint64_t& nmax);
28 virtual ibis::join::result*
29 select(
const std::vector<const char*>& colnames);
60 virtual uint64_t nRows()
const {
return jin_.nrows;}
61 virtual uint32_t nColumns()
const {
return 0;}
63 virtual std::vector<std::string> columnNames()
const;
65 virtual void describe(std::ostream& out)
const;
68 virtual int dump(std::ostream& out,
const char* del=
", ")
const;
70 virtual int getColumnAsByte(
const char* cname,
char&)
const;
71 virtual int getColumnAsUByte(
const char* cname,
unsigned char&)
const;
72 virtual int getColumnAsShort(
const char* cname, int16_t&)
const;
73 virtual int getColumnAsUShort(
const char* cname, uint16_t&)
const;
74 virtual int getColumnAsInt(
const char* cname, int32_t&)
const;
75 virtual int getColumnAsUInt(
const char* cname, uint32_t&)
const;
76 virtual int getColumnAsLong(
const char* cname, int64_t&)
const;
77 virtual int getColumnAsULong(
const char* cname, uint64_t&)
const;
78 virtual int getColumnAsFloat(
const char* cname,
float&)
const;
79 virtual int getColumnAsDouble(
const char* cname,
double&)
const;
80 virtual int getColumnAsString(
const char* cname, std::string&)
const;
82 virtual int getColumnAsByte(uint32_t cnum,
char&)
const;
83 virtual int getColumnAsUByte(uint32_t cnum,
unsigned char&)
const;
84 virtual int getColumnAsShort(uint32_t cnum, int16_t&)
const;
85 virtual int getColumnAsUShort(uint32_t cnum, uint16_t&)
const;
86 virtual int getColumnAsInt(uint32_t cnum, int32_t&)
const;
87 virtual int getColumnAsUInt(uint32_t cnum, uint32_t&)
const;
88 virtual int getColumnAsLong(uint32_t cnum, int64_t&)
const;
89 virtual int getColumnAsULong(uint32_t cnum, uint64_t&)
const;
90 virtual int getColumnAsFloat(uint32_t cnum,
float&)
const;
91 virtual int getColumnAsDouble(uint32_t cnum,
double&)
const;
92 virtual int getColumnAsString(uint32_t cnum, std::string&)
const;
96 const uint32_t endR_, endS_;
97 uint32_t currR_, currS_, blockR_, blockS_, startS_;
98 std::vector<const ibis::column*> colR_, colS_;
99 std::vector<ibis::TYPE_T> typeR_, typeS_;
100 std::vector<void*> valR_, valS_;
101 std::map<const char*, uint32_t, ibis::lessi> namesToPos;
102 std::vector<uint32_t> ipToPos;
104 template <
typename T>
106 int stringMatch(
const std::vector<std::string>& col1,
107 const std::vector<std::string>& col2);
108 void dumpR(std::ostream& out, uint32_t ind)
const;
109 void dumpS(std::ostream& out, uint32_t ind)
const;
117 ibis::joinIN::result::getColumnAsByte(uint32_t cnum,
char& val)
const {
118 if (currR_ >= blockR_ || currS_ >= blockS_ || cnum >= ipToPos.size())
122 uint32_t pos = ipToPos[cnum];
123 if (pos < colR_.size()) {
124 if (typeR_[pos] == ibis::BYTE && colR_[pos] != 0) {
126 [(*jin_.orderR_)[currR_]];
132 if (typeS_[pos] == ibis::BYTE && colS_[pos] != 0) {
133 val = (*(
static_cast<array_t<char>*
>(valS_[pos])))
134 [(*jin_.orderS_)[currS_]];
142 ibis::joinIN::result::getColumnAsUByte(uint32_t cnum,
unsigned char& val)
const {
143 if (currR_ >= blockR_ || currS_ >= blockS_ || cnum >= ipToPos.size())
147 uint32_t pos = ipToPos[cnum];
148 if (pos < colR_.size()) {
149 if (typeR_[pos] ==
ibis::UBYTE && colR_[pos] != 0) {
150 val = (*(
static_cast<array_t<unsigned char>*
>(valR_[pos])))
151 [(*jin_.orderR_)[currR_]];
157 if (typeS_[pos] ==
ibis::UBYTE && colS_[pos] != 0) {
158 val = (*(
static_cast<array_t<unsigned char>*
>(valS_[pos])))
159 [(*jin_.orderS_)[currS_]];
167 ibis::joinIN::result::getColumnAsShort(uint32_t cnum, int16_t& val)
const {
168 if (currR_ >= blockR_ || currS_ >= blockS_ || cnum >= ipToPos.size())
172 uint32_t pos = ipToPos[cnum];
173 if (pos < colR_.size()) {
174 if (colR_[pos] != 0) {
175 switch (typeR_[pos]) {
178 val = (*(
static_cast<array_t<char>*
>(valR_[pos])))
179 [(*jin_.orderR_)[currR_]];
183 val = (*(
static_cast<array_t<unsigned char>*
>(valR_[pos])))
184 [(*jin_.orderR_)[currR_]];
188 val = (*(
static_cast<array_t<int16_t>*
>(valR_[pos])))
189 [(*jin_.orderR_)[currR_]];
197 if (colS_[pos] != 0) {
198 switch (typeS_[pos]) {
201 val = (*(
static_cast<array_t<char>*
>(valS_[pos])))
202 [(*jin_.orderS_)[currS_]];
206 val = (*(
static_cast<array_t<unsigned char>*
>(valS_[pos])))
207 [(*jin_.orderS_)[currS_]];
211 val = (*(
static_cast<array_t<int16_t>*
>(valS_[pos])))
212 [(*jin_.orderS_)[currS_]];
222 ibis::joinIN::result::getColumnAsUShort(uint32_t cnum, uint16_t& val)
const {
223 if (currR_ >= blockR_ || currS_ >= blockS_ || cnum >= ipToPos.size())
227 uint32_t pos = ipToPos[cnum];
228 if (pos < colR_.size()) {
229 if (colR_[pos] != 0) {
230 switch (typeR_[pos]) {
233 val = (*(
static_cast<array_t<char>*
>(valR_[pos])))
234 [(*jin_.orderR_)[currR_]];
238 val = (*(
static_cast<array_t<unsigned char>*
>(valR_[pos])))
239 [(*jin_.orderR_)[currR_]];
243 val = (*(
static_cast<array_t<uint16_t>*
>(valR_[pos])))
244 [(*jin_.orderR_)[currR_]];
252 if (colS_[pos] != 0) {
253 switch (typeS_[pos]) {
256 val = (*(
static_cast<array_t<char>*
>(valS_[pos])))
257 [(*jin_.orderS_)[currS_]];
261 val = (*(
static_cast<array_t<unsigned char>*
>(valS_[pos])))
262 [(*jin_.orderS_)[currS_]];
266 val = (*(
static_cast<array_t<uint16_t>*
>(valS_[pos])))
267 [(*jin_.orderS_)[currS_]];
277 ibis::joinIN::result::getColumnAsInt(uint32_t cnum, int32_t& val)
const {
278 if (currR_ >= blockR_ || currS_ >= blockS_ || cnum >= ipToPos.size())
282 uint32_t pos = ipToPos[cnum];
283 if (pos < colR_.size()) {
284 if (colR_[pos] != 0) {
285 switch (typeR_[pos]) {
288 val = (*(
static_cast<array_t<char>*
>(valR_[pos])))
289 [(*jin_.orderR_)[currR_]];
293 val = (*(
static_cast<array_t<unsigned char>*
>(valR_[pos])))
294 [(*jin_.orderR_)[currR_]];
298 val = (*(
static_cast<array_t<int16_t>*
>(valR_[pos])))
299 [(*jin_.orderR_)[currR_]];
303 val = (*(
static_cast<array_t<uint16_t>*
>(valR_[pos])))
304 [(*jin_.orderR_)[currR_]];
308 val = (*(
static_cast<array_t<int32_t>*
>(valR_[pos])))
309 [(*jin_.orderR_)[currR_]];
317 if (colS_[pos] != 0) {
318 switch (typeS_[pos]) {
321 val = (*(
static_cast<array_t<char>*
>(valS_[pos])))
322 [(*jin_.orderS_)[currS_]];
326 val = (*(
static_cast<array_t<unsigned char>*
>(valS_[pos])))
327 [(*jin_.orderS_)[currS_]];
331 val = (*(
static_cast<array_t<int16_t>*
>(valS_[pos])))
332 [(*jin_.orderS_)[currS_]];
336 val = (*(
static_cast<array_t<uint16_t>*
>(valS_[pos])))
337 [(*jin_.orderS_)[currS_]];
341 val = (*(
static_cast<array_t<int32_t>*
>(valS_[pos])))
342 [(*jin_.orderS_)[currS_]];
352 ibis::joinIN::result::getColumnAsUInt(uint32_t cnum, uint32_t& val)
const {
353 if (currR_ >= blockR_ || currS_ >= blockS_ || cnum >= ipToPos.size())
357 uint32_t pos = ipToPos[cnum];
358 if (pos < colR_.size()) {
359 if (colR_[pos] != 0) {
360 switch (typeR_[pos]) {
363 val = (*(
static_cast<array_t<char>*
>(valR_[pos])))
364 [(*jin_.orderR_)[currR_]];
368 val = (*(
static_cast<array_t<unsigned char>*
>(valR_[pos])))
369 [(*jin_.orderR_)[currR_]];
373 val = (*(
static_cast<array_t<int16_t>*
>(valR_[pos])))
374 [(*jin_.orderR_)[currR_]];
378 val = (*(
static_cast<array_t<uint16_t>*
>(valR_[pos])))
379 [(*jin_.orderR_)[currR_]];
383 val = (*(
static_cast<array_t<uint32_t>*
>(valR_[pos])))
384 [(*jin_.orderR_)[currR_]];
392 if (colS_[pos] != 0) {
393 switch (typeS_[pos]) {
396 val = (*(
static_cast<array_t<char>*
>(valS_[pos])))
397 [(*jin_.orderS_)[currS_]];
401 val = (*(
static_cast<array_t<unsigned char>*
>(valS_[pos])))
402 [(*jin_.orderS_)[currS_]];
406 val = (*(
static_cast<array_t<int16_t>*
>(valS_[pos])))
407 [(*jin_.orderS_)[currS_]];
411 val = (*(
static_cast<array_t<uint16_t>*
>(valS_[pos])))
412 [(*jin_.orderS_)[currS_]];
416 val = (*(
static_cast<array_t<uint32_t>*
>(valS_[pos])))
417 [(*jin_.orderS_)[currS_]];
427 ibis::joinIN::result::getColumnAsLong(uint32_t cnum, int64_t& val)
const {
428 if (currR_ >= blockR_ || currS_ >= blockS_ || cnum >= ipToPos.size())
432 uint32_t pos = ipToPos[cnum];
433 if (pos < colR_.size()) {
434 if (colR_[pos] != 0) {
435 switch (typeR_[pos]) {
438 val = (*(
static_cast<array_t<char>*
>(valR_[pos])))
439 [(*jin_.orderR_)[currR_]];
443 val = (*(
static_cast<array_t<unsigned char>*
>(valR_[pos])))
444 [(*jin_.orderR_)[currR_]];
448 val = (*(
static_cast<array_t<int16_t>*
>(valR_[pos])))
449 [(*jin_.orderR_)[currR_]];
453 val = (*(
static_cast<array_t<uint16_t>*
>(valR_[pos])))
454 [(*jin_.orderR_)[currR_]];
458 val = (*(
static_cast<array_t<int32_t>*
>(valR_[pos])))
459 [(*jin_.orderR_)[currR_]];
463 val = (*(
static_cast<array_t<uint32_t>*
>(valR_[pos])))
464 [(*jin_.orderR_)[currR_]];
468 val = (*(
static_cast<array_t<int64_t>*
>(valR_[pos])))
469 [(*jin_.orderR_)[currR_]];
477 if (colS_[pos] != 0) {
478 switch (typeS_[pos]) {
481 val = (*(
static_cast<array_t<char>*
>(valS_[pos])))
482 [(*jin_.orderS_)[currS_]];
486 val = (*(
static_cast<array_t<unsigned char>*
>(valS_[pos])))
487 [(*jin_.orderS_)[currS_]];
491 val = (*(
static_cast<array_t<int16_t>*
>(valS_[pos])))
492 [(*jin_.orderS_)[currS_]];
496 val = (*(
static_cast<array_t<uint16_t>*
>(valS_[pos])))
497 [(*jin_.orderS_)[currS_]];
501 val = (*(
static_cast<array_t<int32_t>*
>(valS_[pos])))
502 [(*jin_.orderS_)[currS_]];
506 val = (*(
static_cast<array_t<uint32_t>*
>(valS_[pos])))
507 [(*jin_.orderS_)[currS_]];
511 val = (*(
static_cast<array_t<int64_t>*
>(valS_[pos])))
512 [(*jin_.orderS_)[currS_]];
522 ibis::joinIN::result::getColumnAsULong(uint32_t cnum, uint64_t& val)
const {
523 if (currR_ >= blockR_ || currS_ >= blockS_ || cnum >= ipToPos.size())
527 uint32_t pos = ipToPos[cnum];
528 if (pos < colR_.size()) {
529 if (colR_[pos] != 0) {
530 switch (typeR_[pos]) {
533 val = (*(
static_cast<array_t<char>*
>(valR_[pos])))
534 [(*jin_.orderR_)[currR_]];
538 val = (*(
static_cast<array_t<unsigned char>*
>(valR_[pos])))
539 [(*jin_.orderR_)[currR_]];
543 val = (*(
static_cast<array_t<int16_t>*
>(valR_[pos])))
544 [(*jin_.orderR_)[currR_]];
548 val = (*(
static_cast<array_t<uint16_t>*
>(valR_[pos])))
549 [(*jin_.orderR_)[currR_]];
553 val = (*(
static_cast<array_t<int32_t>*
>(valR_[pos])))
554 [(*jin_.orderR_)[currR_]];
558 val = (*(
static_cast<array_t<uint32_t>*
>(valR_[pos])))
559 [(*jin_.orderR_)[currR_]];
563 val = (*(
static_cast<array_t<uint64_t>*
>(valR_[pos])))
564 [(*jin_.orderR_)[currR_]];
572 if (colS_[pos] != 0) {
573 switch (typeS_[pos]) {
576 val = (*(
static_cast<array_t<char>*
>(valS_[pos])))
577 [(*jin_.orderS_)[currS_]];
581 val = (*(
static_cast<array_t<unsigned char>*
>(valS_[pos])))
582 [(*jin_.orderS_)[currS_]];
586 val = (*(
static_cast<array_t<int16_t>*
>(valS_[pos])))
587 [(*jin_.orderS_)[currS_]];
591 val = (*(
static_cast<array_t<uint16_t>*
>(valS_[pos])))
592 [(*jin_.orderS_)[currS_]];
596 val = (*(
static_cast<array_t<int32_t>*
>(valS_[pos])))
597 [(*jin_.orderS_)[currS_]];
601 val = (*(
static_cast<array_t<uint32_t>*
>(valS_[pos])))
602 [(*jin_.orderS_)[currS_]];
606 val = (*(
static_cast<array_t<uint64_t>*
>(valS_[pos])))
607 [(*jin_.orderS_)[currS_]];
617 ibis::joinIN::result::getColumnAsFloat(uint32_t cnum,
float& val)
const {
618 if (currR_ >= blockR_ || currS_ >= blockS_ || cnum >= ipToPos.size())
622 uint32_t pos = ipToPos[cnum];
623 if (pos < colR_.size()) {
624 if (colR_[pos] != 0) {
625 switch (typeR_[pos]) {
628 val = (*(
static_cast<array_t<char>*
>(valR_[pos])))
629 [(*jin_.orderR_)[currR_]];
633 val = (*(
static_cast<array_t<unsigned char>*
>(valR_[pos])))
634 [(*jin_.orderR_)[currR_]];
638 val = (*(
static_cast<array_t<int16_t>*
>(valR_[pos])))
639 [(*jin_.orderR_)[currR_]];
643 val = (*(
static_cast<array_t<uint16_t>*
>(valR_[pos])))
644 [(*jin_.orderR_)[currR_]];
648 val = (*(
static_cast<array_t<float>*
>(valR_[pos])))
649 [(*jin_.orderR_)[currR_]];
657 if (colS_[pos] != 0) {
658 switch (typeS_[pos]) {
661 val = (*(
static_cast<array_t<char>*
>(valS_[pos])))
662 [(*jin_.orderS_)[currS_]];
666 val = (*(
static_cast<array_t<unsigned char>*
>(valS_[pos])))
667 [(*jin_.orderS_)[currS_]];
671 val = (*(
static_cast<array_t<int16_t>*
>(valS_[pos])))
672 [(*jin_.orderS_)[currS_]];
676 val = (*(
static_cast<array_t<uint16_t>*
>(valS_[pos])))
677 [(*jin_.orderS_)[currS_]];
681 val = (*(
static_cast<array_t<float>*
>(valS_[pos])))
682 [(*jin_.orderS_)[currS_]];
692 ibis::joinIN::result::getColumnAsDouble(uint32_t cnum,
double& val)
const {
693 if (currR_ >= blockR_ || currS_ >= blockS_ || cnum >= ipToPos.size())
697 uint32_t pos = ipToPos[cnum];
698 if (pos < colR_.size()) {
699 if (colR_[pos] != 0) {
700 switch (typeR_[pos]) {
703 val = (*(
static_cast<array_t<char>*
>(valR_[pos])))
704 [(*jin_.orderR_)[currR_]];
708 val = (*(
static_cast<array_t<unsigned char>*
>(valR_[pos])))
709 [(*jin_.orderR_)[currR_]];
713 val = (*(
static_cast<array_t<int16_t>*
>(valR_[pos])))
714 [(*jin_.orderR_)[currR_]];
718 val = (*(
static_cast<array_t<uint16_t>*
>(valR_[pos])))
719 [(*jin_.orderR_)[currR_]];
723 val = (*(
static_cast<array_t<int32_t>*
>(valR_[pos])))
724 [(*jin_.orderR_)[currR_]];
728 val = (*(
static_cast<array_t<uint32_t>*
>(valR_[pos])))
729 [(*jin_.orderR_)[currR_]];
733 val = (*(
static_cast<array_t<float>*
>(valR_[pos])))
734 [(*jin_.orderR_)[currR_]];
738 val = (*(
static_cast<array_t<double>*
>(valR_[pos])))
739 [(*jin_.orderR_)[currR_]];
747 if (colS_[pos] != 0) {
748 switch (typeS_[pos]) {
751 val = (*(
static_cast<array_t<char>*
>(valS_[pos])))
752 [(*jin_.orderS_)[currS_]];
756 val = (*(
static_cast<array_t<unsigned char>*
>(valS_[pos])))
757 [(*jin_.orderS_)[currS_]];
761 val = (*(
static_cast<array_t<int16_t>*
>(valS_[pos])))
762 [(*jin_.orderS_)[currS_]];
766 val = (*(
static_cast<array_t<uint16_t>*
>(valS_[pos])))
767 [(*jin_.orderS_)[currS_]];
771 val = (*(
static_cast<array_t<int32_t>*
>(valS_[pos])))
772 [(*jin_.orderS_)[currS_]];
776 val = (*(
static_cast<array_t<uint32_t>*
>(valS_[pos])))
777 [(*jin_.orderS_)[currS_]];
781 val = (*(
static_cast<array_t<float>*
>(valS_[pos])))
782 [(*jin_.orderS_)[currS_]];
786 val = (*(
static_cast<array_t<double>*
>(valS_[pos])))
787 [(*jin_.orderS_)[currS_]];
797 ibis::joinIN::result::dumpR(std::ostream& out, uint32_t ind)
const {
798 if (colR_[ind] == 0)
return;
799 switch (typeR_[ind]) {
802 out << (int)(*(static_cast<const array_t<char>*>(valR_[ind])))
803 [(*jin_.orderR_)[currR_]];
806 out << (int)(*(static_cast<const array_t<unsigned char>*>(valR_[ind])))
807 [(*jin_.orderR_)[currR_]];
810 out << (*(static_cast<const array_t<int16_t>*>(valR_[ind])))
811 [(*jin_.orderR_)[currR_]];
814 out << (*(static_cast<const array_t<uint16_t>*>(valR_[ind])))
815 [(*jin_.orderR_)[currR_]];
818 out << (*(static_cast<const array_t<int32_t>*>(valR_[ind])))
819 [(*jin_.orderR_)[currR_]];
822 out << (*(static_cast<const array_t<uint32_t>*>(valR_[ind])))
823 [(*jin_.orderR_)[currR_]];
826 out << (*(static_cast<const array_t<int64_t>*>(valR_[ind])))
827 [(*jin_.orderR_)[currR_]];
830 out << (*(static_cast<const array_t<uint64_t>*>(valR_[ind])))
831 [(*jin_.orderR_)[currR_]];
834 out << (*(static_cast<const array_t<float>*>(valR_[ind])))
835 [(*jin_.orderR_)[currR_]];
838 out << (*(static_cast<const array_t<double>*>(valR_[ind])))
839 [(*jin_.orderR_)[currR_]];
843 out << (*(static_cast<const std::vector<std::string>*>(valR_[ind])))
844 [(*jin_.orderR_)[currR_]];
850 ibis::joinIN::result::dumpS(std::ostream& out, uint32_t ind)
const {
851 if (colS_[ind] == 0)
return;
852 switch (typeS_[ind]) {
855 out << (int)(*(static_cast<const array_t<char>*>(valS_[ind])))
856 [(*jin_.orderS_)[currS_]];
859 out << (int)(*(static_cast<const array_t<unsigned char>*>(valS_[ind])))
860 [(*jin_.orderS_)[currS_]];
863 out << (*(static_cast<const array_t<int16_t>*>(valS_[ind])))
864 [(*jin_.orderS_)[currS_]];
867 out << (*(static_cast<const array_t<uint16_t>*>(valS_[ind])))
868 [(*jin_.orderS_)[currS_]];
871 out << (*(static_cast<const array_t<int32_t>*>(valS_[ind])))
872 [(*jin_.orderS_)[currS_]];
875 out << (*(static_cast<const array_t<uint32_t>*>(valS_[ind])))
876 [(*jin_.orderS_)[currS_]];
879 out << (*(static_cast<const array_t<int64_t>*>(valS_[ind])))
880 [(*jin_.orderS_)[currS_]];
883 out << (*(static_cast<const array_t<uint64_t>*>(valS_[ind])))
884 [(*jin_.orderS_)[currS_]];
887 out << (*(static_cast<const array_t<float>*>(valS_[ind])))
888 [(*jin_.orderS_)[currS_]];
891 out << (*(static_cast<const array_t<double>*>(valS_[ind])))
892 [(*jin_.orderS_)[currS_]];
896 out << (*(static_cast<const std::vector<std::string>*>(valS_[ind])))
897 [(*jin_.orderS_)[currS_]];
An abstract join interface.
Definition: join.h:31
!< One bit per record, represented by a bit vector.
Definition: table.h:44
!< Four-byte signed integers, internally int32_t.
Definition: table.h:35
The current implementation of FastBit is code named IBIS; most data structures and functions are in t...
Definition: bord.h:16
!< 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 void estimate(uint64_t &nmin, uint64_t &nmax)
Provide an estimate of the number of results.
Definition: joinin.cpp:123
!< Two-byte unsigned integers, internally uint16_t.
Definition: table.h:34
Arbitrary null-terminated strings.
Definition: table.h:51
!< Two-byte signed integers, internally int16_t.
Definition: table.h:33
!< Eight-byte signed integers, internally int64_t.
Definition: table.h:37
FastBit In-memory Natual Join.
Definition: joinin.h:19
!< One-byte unsigned integers, internally unsigned char.
Definition: table.h:32
virtual ibis::join::result * select(const std::vector< const char * > &colnames)
Produce a projection of the joined table.
Definition: joinin.cpp:403
!< Four-byte IEEE floating-point numbers, internally float.
Definition: table.h:39
The class ibis::part represents a partition of a relational table.
Definition: part.h:27
TYPE_T
Supported data types.
Definition: table.h:25
A data structure to represent a sequence of bits.
Definition: bitvector.h:62
virtual int64_t evaluate()
Compute the number of results.
Definition: joinin.cpp:130
!< One-byte signed integers, internally char.
Definition: table.h:31
!< Four-byte unsigned integers, internally uint32_t.
Definition: table.h:36