order by refactoring
This commit is contained in:
20
row.cpp
20
row.cpp
@@ -3,6 +3,26 @@
|
||||
|
||||
namespace usql {
|
||||
|
||||
int ColNullValue::compare(ColValue * other) {
|
||||
return other->isNull() ? 0 : -1; // null goes to end
|
||||
}
|
||||
|
||||
int ColIntegerValue::compare(ColValue * other) {
|
||||
return other->isNull() ? 1 : m_integer - other->getIntValue(); // null goes to end
|
||||
}
|
||||
|
||||
int ColDoubleValue::compare(ColValue * other) {
|
||||
if (other->isNull()) { // null goes to end
|
||||
return 1;
|
||||
}
|
||||
double c = m_double - other->getDoubleValue();
|
||||
return c < 0 ? -1 : c == 0.0 ? 0 : 1;
|
||||
}
|
||||
|
||||
int ColStringValue::compare(ColValue * other) {
|
||||
return other->isNull() ? 1 : m_string.compare(other->getStringValue()); // null goes to end
|
||||
}
|
||||
|
||||
Row::Row(int cols_count) {
|
||||
m_columns.reserve(cols_count);
|
||||
for (int i = 0; i < cols_count; i++) {
|
||||
|
||||
Reference in New Issue
Block a user