Skip to content

Commit

Permalink
support date and datetime. (apache#35)
Browse files Browse the repository at this point in the history
* 1. support date and datetime.
2. remove some not used file.

* remove time zone
  • Loading branch information
yangzhg authored and HappenLee committed Jul 1, 2021
1 parent b64fe1d commit 6aa454c
Show file tree
Hide file tree
Showing 70 changed files with 549 additions and 6,141 deletions.
4 changes: 3 additions & 1 deletion be/src/runtime/datetime_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,15 @@ class DateTimeValue {
int hour() const { return _hour; }
int minute() const { return _minute; }
int second() const { return _second; }
int microsecond() const { return _microsecond; }
int neg() const { return _neg; }

bool check_loss_accuracy_cast_to_date() {
auto loss_accuracy = _hour != 0 || _minute != 0 || _second != 0 || _microsecond != 0;
cast_to_date();
return loss_accuracy;
}

void cast_to_date() {
_hour = 0;
_minute = 0;
Expand Down
10 changes: 5 additions & 5 deletions be/src/runtime/row_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
#include "runtime/string_value.h"
#include "runtime/tuple_row.h"
//#include "runtime/mem_tracker.h"
#include "vec/columns/column_vector.h"
#include "vec/core/block.h"

#include "gen_cpp/Data_types.h"
#include "gen_cpp/data.pb.h"
#include "vec/columns/column_vector.h"
#include "vec/core/block.h"

using std::vector;

Expand Down Expand Up @@ -553,11 +552,12 @@ vectorized::Block RowBatch::convert_to_vec_block() const {
if (slot_desc->is_nullable() && tuple->is_null(slot_desc->null_indicator_offset())) {
columns[i]->insertData(nullptr, 0);
} else if (slot_desc->type().is_string_type()) {
auto string_value = static_cast<const StringValue*>(tuple->get_slot(slot_desc->tuple_offset()));
auto string_value =
static_cast<const StringValue*>(tuple->get_slot(slot_desc->tuple_offset()));
columns[i]->insertData(string_value->ptr, string_value->len);
} else {
columns[i]->insertData(
static_cast<const char *>(tuple->get_slot(slot_desc->tuple_offset())),
static_cast<const char*>(tuple->get_slot(slot_desc->tuple_offset())),
slot_desc->slot_size());
}
}
Expand Down
9 changes: 7 additions & 2 deletions be/src/runtime/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "olap/hll.h"
#include "runtime/primitive_type.h"
#include "thrift/protocol/TDebugProtocol.h"
#include "vec/data_types/data_type_date.h"
#include "vec/data_types/data_type_date_time.h"
#include "vec/data_types/data_type_string.h"
#include "vec/data_types/data_types_decimal.h"
#include "vec/data_types/data_types_number.h"
Expand Down Expand Up @@ -176,6 +178,8 @@ struct TypeDescriptor {

inline bool is_date_type() const { return type == TYPE_DATE || type == TYPE_DATETIME; }

inline bool is_datetime_type() const { return type == TYPE_DATETIME; }

inline bool is_decimal_type() const { return (type == TYPE_DECIMAL || type == TYPE_DECIMALV2); }

inline bool is_var_len_string_type() const {
Expand Down Expand Up @@ -297,10 +301,11 @@ struct TypeDescriptor {
return std::make_shared<vectorized::DataTypeInt64>();

case TYPE_LARGEINT:
return std::make_shared<vectorized::DataTypeInt128>();
case TYPE_DATE:
return std::make_shared<vectorized::DataTypeDate>();
case TYPE_DATETIME:
return std::make_shared<vectorized::DataTypeInt128>();

return std::make_shared<vectorized::DataTypeDateTime>();
case TYPE_DOUBLE:
return std::make_shared<vectorized::DataTypeFloat64>();

Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ set(VEC_FILES
data_types/data_types_number.cpp
data_types/get_least_supertype.cpp
data_types/nested_utils.cpp
data_types/data_type_date.cpp
data_types/data_type_date_time.cpp
exec/vaggregation_node.cpp
exec/volap_scan_node.cpp
exec/vsort_node.cpp
Expand Down
21 changes: 8 additions & 13 deletions be/src/vec/columns/column_decimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@
// specific language governing permissions and limitations
// under the License.

#include "vec/columns/column_decimal.h"

#include "vec/columns/columns_common.h"
#include "vec/common/arena.h"
#include "vec/common/assert_cast.h"
#include "vec/common/exception.h"
#include "vec/common/sip_hash.h"
#include "vec/common/unaligned.h"

//#include <IO/WriteHelpers.h>

#include "vec/columns/column_decimal.h"
#include "vec/columns/columns_common.h"
//#include <DataStreams/ColumnGathererStream.h>

template <typename T>
bool decimalLess(T x, T y, UInt32 x_scale, UInt32 y_scale);
bool decimalLess(T x, T y, doris::vectorized::UInt32 x_scale, doris::vectorized::UInt32 y_scale);

namespace doris::vectorized {

Expand Down Expand Up @@ -78,17 +75,15 @@ void ColumnDecimal<T>::updateHashWithValue(size_t n, SipHash& hash) const {
}

template <typename T>
void ColumnDecimal<T>::getPermutation(bool reverse, size_t limit, int , IColumn::Permutation & res) const
{
void ColumnDecimal<T>::getPermutation(bool reverse, size_t limit, int,
IColumn::Permutation& res) const {
#if 1 /// TODO: perf test
if (data.size() <= std::numeric_limits<UInt32>::max())
{
if (data.size() <= std::numeric_limits<UInt32>::max()) {
PaddedPODArray<UInt32> tmp_res;
permutation(reverse, limit, tmp_res);

res.resize(tmp_res.size());
for (size_t i = 0; i < tmp_res.size(); ++i)
res[i] = tmp_res[i];
for (size_t i = 0; i < tmp_res.size(); ++i) res[i] = tmp_res[i];
return;
}
#endif
Expand Down
20 changes: 6 additions & 14 deletions be/src/vec/columns/column_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
#include "vec/common/arena.h"
#include "vec/common/assert_cast.h"
#include "vec/common/memcmp_small.h"
#include "vec/core/defines.h"
//#include <DataStreams/ColumnGathererStream.h>

#include "vec/common/unaligned.h"

namespace doris::vectorized {
Expand Down Expand Up @@ -233,25 +230,20 @@ struct ColumnString::less {
}
};

void ColumnString::getPermutation(bool reverse, size_t limit, int /*nan_direction_hint*/, Permutation & res) const
{
void ColumnString::getPermutation(bool reverse, size_t limit, int /*nan_direction_hint*/,
Permutation& res) const {
size_t s = offsets.size();
res.resize(s);
for (size_t i = 0; i < s; ++i)
res[i] = i;
for (size_t i = 0; i < s; ++i) res[i] = i;

if (limit >= s)
limit = 0;
if (limit >= s) limit = 0;

if (limit)
{
if (limit) {
if (reverse)
std::partial_sort(res.begin(), res.begin() + limit, res.end(), less<false>(*this));
else
std::partial_sort(res.begin(), res.begin() + limit, res.end(), less<true>(*this));
}
else
{
} else {
if (reverse)
std::sort(res.begin(), res.end(), less<false>(*this));
else
Expand Down
1 change: 1 addition & 0 deletions be/src/vec/columns/columns_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using ColumnInt8 = ColumnVector<Int8>;
using ColumnInt16 = ColumnVector<Int16>;
using ColumnInt32 = ColumnVector<Int32>;
using ColumnInt64 = ColumnVector<Int64>;
using ColumnInt128 = ColumnVector<Int128>;

using ColumnFloat32 = ColumnVector<Float32>;
using ColumnFloat64 = ColumnVector<Float64>;
Expand Down
23 changes: 10 additions & 13 deletions be/src/vec/common/aggregation_common.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#pragma once

#include <vec/columns/column.h>
#include <vec/columns/columns_number.h>
#include <vec/common/arena.h>
#include <vec/common/assert_cast.h>
#include <vec/common/hash_table/hash.h>
#include <vec/common/memcpy_small.h>
#include <vec/common/sip_hash.h>
#include <vec/common/string_ref.h>
#include <vec/common/uint128.h>
#include <vec/core/defines.h>

#include <array>
// #include <vec/columns/columnFixedString.h>
// #include <vec/columns/columnLowCardinality.h>

#include "vec/columns/column.h"
#include "vec/columns/columns_number.h"
#include "vec/common/arena.h"
#include "vec/common/assert_cast.h"
#include "vec/common/hash_table/hash.h"
#include "vec/common/memcpy_small.h"
#include "vec/common/sip_hash.h"
#include "vec/common/string_ref.h"
#include "vec/common/uint128.h"

template <>
struct DefaultHash<StringRef> : public StringRefHash {};
Expand Down
11 changes: 2 additions & 9 deletions be/src/vec/common/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
#define ALLOCATOR_ASLR 1
#endif

//#include <pcg_random.hpp>
// #include <vec/Common/thread_local_rng.h>

#if !defined(__APPLE__) && !defined(__FreeBSD__)
#include <malloc.h>
#endif
Expand All @@ -48,13 +45,9 @@
/// Thread sanitizer does not intercept mremap. The usage of mremap will lead to false positives.
#define DISABLE_MREMAP 1
#endif
#include "vec/common/mremap.h"

// #include <vec/Common/MemoryTracker.h>
#include "vec/common/exception.h"
// #include <vec/Common/formatReadable.h>

#include "vec/common/allocator_fwd.h"
#include "vec/common/exception.h"
#include "vec/common/mremap.h"

/// Required for older Darwin builds, that lack definition of MAP_ANONYMOUS
#ifndef MAP_ANONYMOUS
Expand Down
3 changes: 1 addition & 2 deletions be/src/vec/common/arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
#if __has_include(<sanitizer/asan_interface.h>)
#include <sanitizer/asan_interface.h>
#endif
#include "vec/common/allocator.h"
#include "vec/common/memcpy_small.h"
#include "vec/core/defines.h"
//#include <vec/Common/ProfileEvents.h>
#include "vec/common/allocator.h"

//namespace ProfileEvents
//{
Expand Down
27 changes: 0 additions & 27 deletions be/src/vec/common/args_to_config.h

This file was deleted.

Loading

0 comments on commit 6aa454c

Please sign in to comment.