| 132 | } |
| 133 | |
| 134 | void DataProvider::Print(ostream* stream, char* data, int rows) const { |
| 135 | char* next_col = reinterpret_cast<char*>(data); |
| 136 | for (int i = 0; i < rows; ++i) { |
| 137 | for (int j = 0; j < cols_.size(); ++j) { |
| 138 | switch (cols_[j].type) { |
| 139 | case TYPE_BOOLEAN: |
| 140 | *stream << (*reinterpret_cast<int8_t*>(next_col) ? "true" : "false"); |
| 141 | break; |
| 142 | case TYPE_TINYINT: |
| 143 | *stream << (int)*reinterpret_cast<int8_t*>(next_col); |
| 144 | break; |
| 145 | case TYPE_SMALLINT: |
| 146 | *stream << *reinterpret_cast<int16_t*>(next_col); |
| 147 | break; |
| 148 | case TYPE_INT: |
| 149 | *stream << *reinterpret_cast<int32_t*>(next_col); |
| 150 | break; |
| 151 | case TYPE_BIGINT: |
| 152 | *stream << *reinterpret_cast<int64_t*>(next_col); |
| 153 | break; |
| 154 | case TYPE_FLOAT: |
| 155 | *stream << *reinterpret_cast<float*>(next_col); |
| 156 | break; |
| 157 | case TYPE_DOUBLE: |
| 158 | *stream << *reinterpret_cast<double*>(next_col); |
| 159 | break; |
| 160 | case TYPE_STRING: |
| 161 | case TYPE_VARCHAR: |
| 162 | *stream << *reinterpret_cast<StringValue*>(next_col); |
| 163 | break; |
| 164 | default: |
| 165 | *stream << "BAD" << endl; |
| 166 | return; |
| 167 | } |
| 168 | if (j != cols_.size() - 1) *stream << ", "; |
| 169 | next_col += cols_[j].bytes; |
| 170 | } |
| 171 | *stream << endl; |
| 172 | } |
| 173 | } |