libaquery: optimizations that reduces vector copy.
This commit is contained in:
@@ -30,14 +30,14 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<EnableASAN>false</EnableASAN>
|
<EnableASAN>false</EnableASAN>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<EnableASAN>true</EnableASAN>
|
<EnableASAN>true</EnableASAN>
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<EnableASAN>false</EnableASAN>
|
<EnableASAN>false</EnableASAN>
|
||||||
<EnableFuzzer>false</EnableFuzzer>
|
<EnableFuzzer>false</EnableFuzzer>
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<EnableASAN>true</EnableASAN>
|
<EnableASAN>true</EnableASAN>
|
||||||
|
|||||||
+1
-1
@@ -930,7 +930,7 @@ class udf(ast_node):
|
|||||||
cname = get_legal_name(args)
|
cname = get_legal_name(args)
|
||||||
self.var_table[args] = cname
|
self.var_table[args] = cname
|
||||||
self.args.append(cname)
|
self.args.append(cname)
|
||||||
front = [*self.code_list, ', '.join([f'auto {a}' for a in self.args])]
|
front = [*self.code_list, ', '.join([f'const auto& {a}' for a in self.args])]
|
||||||
self.code_list = []
|
self.code_list = []
|
||||||
|
|
||||||
self.with_storage = False
|
self.with_storage = False
|
||||||
|
|||||||
+3
-19
@@ -278,25 +278,9 @@ int test_main()
|
|||||||
printf("sibal: %p %p\n", aa, bb);
|
printf("sibal: %p %p\n", aa, bb);
|
||||||
|
|
||||||
const char* qs[]= {
|
const char* qs[]= {
|
||||||
"SELECT MIN(3)-MAX(2);",
|
"CREATE TABLE test1(a INT, b INT, c INT, d INT);",
|
||||||
"CREATE TABLE stocks(timestamp INT, price INT);",
|
"COPY OFFSET 2 INTO test1 FROM 'W:/gg/AQuery++/data/test.csv' ON SERVER USING DELIMITERS ',';",
|
||||||
"INSERT INTO stocks VALUES(1, 15);;",
|
"SELECT sum(a), b, c, d FROM test1 GROUP BY c, b, d ORDER BY b ;",
|
||||||
"INSERT INTO stocks VALUES(2,19); ",
|
|
||||||
"INSERT INTO stocks VALUES(3,16);",
|
|
||||||
"INSERT INTO stocks VALUES(4,17);",
|
|
||||||
"INSERT INTO stocks VALUES(5,15);",
|
|
||||||
"INSERT INTO stocks VALUES(6,13);",
|
|
||||||
"INSERT INTO stocks VALUES(7,5);",
|
|
||||||
"INSERT INTO stocks VALUES(8,8);",
|
|
||||||
"INSERT INTO stocks VALUES(9,7);",
|
|
||||||
"INSERT INTO stocks VALUES(10,13);",
|
|
||||||
"INSERT INTO stocks VALUES(11,11);",
|
|
||||||
"INSERT INTO stocks VALUES(12,14);",
|
|
||||||
"INSERT INTO stocks VALUES(13,10);",
|
|
||||||
"INSERT INTO stocks VALUES(14,5);",
|
|
||||||
"INSERT INTO stocks VALUES(15,2);",
|
|
||||||
"INSERT INTO stocks VALUES(16,5);",
|
|
||||||
"SELECT price, timestamp FROM stocks WHERE (((price - timestamp) > 1) AND (NOT ((price * timestamp) < 100))) ;",
|
|
||||||
};
|
};
|
||||||
n_recv = sizeof(qs)/(sizeof (char*));
|
n_recv = sizeof(qs)/(sizeof (char*));
|
||||||
n_recvd = const_cast<char**>(qs);
|
n_recvd = const_cast<char**>(qs);
|
||||||
|
|||||||
@@ -93,4 +93,3 @@ Global
|
|||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {572EA821-8162-4161-9AC2-464C79F08B47}
|
SolutionGuid = {572EA821-8162-4161-9AC2-464C79F08B47}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
|
||||||
|
|||||||
+19
-3
@@ -32,6 +32,8 @@ public:
|
|||||||
typedef ColRef<_Ty> Decayed_t;
|
typedef ColRef<_Ty> Decayed_t;
|
||||||
const char* name;
|
const char* name;
|
||||||
types::Type_t ty = types::Type_t::ERROR;
|
types::Type_t ty = types::Type_t::ERROR;
|
||||||
|
ColRef(const ColRef<_Ty>& vt) : vector_type<_Ty>(vt) {}
|
||||||
|
ColRef(ColRef<_Ty>&& vt) : vector_type<_Ty>(std::move(vt)) {}
|
||||||
ColRef() : vector_type<_Ty>(0), name("") {}
|
ColRef() : vector_type<_Ty>(0), name("") {}
|
||||||
ColRef(const uint32_t& size, const char* name = "") : vector_type<_Ty>(size), name(name) {}
|
ColRef(const uint32_t& size, const char* name = "") : vector_type<_Ty>(size), name(name) {}
|
||||||
ColRef(const char* name) : name(name) {}
|
ColRef(const char* name) : name(name) {}
|
||||||
@@ -62,10 +64,22 @@ public:
|
|||||||
}
|
}
|
||||||
ColRef(const char* name, types::Type_t ty) : name(name), ty(ty) {}
|
ColRef(const char* name, types::Type_t ty) : name(name), ty(ty) {}
|
||||||
using vector_type<_Ty>::operator[];
|
using vector_type<_Ty>::operator[];
|
||||||
using vector_type<_Ty>::operator=;
|
//using vector_type<_Ty>::operator=;
|
||||||
using vector_type<_Ty>::subvec;
|
using vector_type<_Ty>::subvec;
|
||||||
using vector_type<_Ty>::subvec_memcpy;
|
using vector_type<_Ty>::subvec_memcpy;
|
||||||
using vector_type<_Ty>::subvec_deep;
|
using vector_type<_Ty>::subvec_deep;
|
||||||
|
ColRef<_Ty>& operator= (const _Ty& vt){
|
||||||
|
vector_type<_Ty>::operator=(vt);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ColRef<_Ty>& operator =(const ColRef<_Ty>& vt) {
|
||||||
|
vector_type<_Ty>::operator=(vt);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ColRef<_Ty>& operator =(ColRef<_Ty>&& vt) {
|
||||||
|
vector_type<_Ty>::operator=(std::move(vt));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
ColView<_Ty> operator [](const vector_type<uint32_t>&idxs) const {
|
ColView<_Ty> operator [](const vector_type<uint32_t>&idxs) const {
|
||||||
return ColView<_Ty>(*this, idxs);
|
return ColView<_Ty>(*this, idxs);
|
||||||
}
|
}
|
||||||
@@ -100,6 +114,8 @@ public:
|
|||||||
void* monetdb_get_col();
|
void* monetdb_get_col();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
template<>
|
||||||
|
class ColRef<void> : public ColRef<int>{};
|
||||||
|
|
||||||
template<typename _Ty>
|
template<typename _Ty>
|
||||||
class ColView {
|
class ColView {
|
||||||
@@ -151,11 +167,11 @@ public:
|
|||||||
ret[i] = orig[idxs[i]];
|
ret[i] = orig[idxs[i]];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ColView<_Ty> subvec(uint32_t start, uint32_t end) {
|
ColView<_Ty> subvec(uint32_t start, uint32_t end) const {
|
||||||
uint32_t len = end - start;
|
uint32_t len = end - start;
|
||||||
return ColView<_Ty>(orig, idxs.subvec(start, end));
|
return ColView<_Ty>(orig, idxs.subvec(start, end));
|
||||||
}
|
}
|
||||||
ColRef<_Ty> subvec_deep(uint32_t start, uint32_t end) {
|
ColRef<_Ty> subvec_deep(uint32_t start, uint32_t end) const{
|
||||||
uint32_t len = end - start;
|
uint32_t len = end - start;
|
||||||
ColRef<_Ty> subvec(len);
|
ColRef<_Ty> subvec(len);
|
||||||
for (uint32_t i = 0; i < len; ++i)
|
for (uint32_t i = 0; i < len; ++i)
|
||||||
|
|||||||
+19
-6
@@ -29,9 +29,14 @@ public:
|
|||||||
|
|
||||||
this->size = vt.size;
|
this->size = vt.size;
|
||||||
this->capacity = vt.capacity;
|
this->capacity = vt.capacity;
|
||||||
this->container = (_Ty*)malloc(size * sizeof(_Ty));
|
if (capacity) {
|
||||||
|
puts("copy");
|
||||||
memcpy(container, vt.container, sizeof(_Ty) * size);
|
this->container = (_Ty*)malloc(size * sizeof(_Ty));
|
||||||
|
memcpy(container, vt.container, sizeof(_Ty) * size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->container = vt.container;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void inline _move(vector_type<_Ty>&& vt) {
|
void inline _move(vector_type<_Ty>&& vt) {
|
||||||
if (capacity > 0) free(container);
|
if (capacity > 0) free(container);
|
||||||
@@ -39,7 +44,7 @@ public:
|
|||||||
this->size = vt.size;
|
this->size = vt.size;
|
||||||
this->capacity = vt.capacity;
|
this->capacity = vt.capacity;
|
||||||
this->container = vt.container;
|
this->container = vt.container;
|
||||||
|
puts("move");
|
||||||
vt.size = vt.capacity = 0;
|
vt.size = vt.capacity = 0;
|
||||||
vt.container = 0;
|
vt.container = 0;
|
||||||
}
|
}
|
||||||
@@ -60,7 +65,7 @@ public:
|
|||||||
}
|
}
|
||||||
constexpr vector_type() noexcept : size(0), capacity(0), container(0) {};
|
constexpr vector_type() noexcept : size(0), capacity(0), container(0) {};
|
||||||
constexpr vector_type(_Ty* container, uint32_t len) noexcept : size(len), capacity(0), container(container) {};
|
constexpr vector_type(_Ty* container, uint32_t len) noexcept : size(len), capacity(0), container(container) {};
|
||||||
constexpr vector_type(const vector_type<_Ty>& vt) noexcept : capacity(0) {
|
constexpr explicit vector_type(const vector_type<_Ty>& vt) noexcept : capacity(0) {
|
||||||
_copy(vt);
|
_copy(vt);
|
||||||
}
|
}
|
||||||
constexpr vector_type(vector_type<_Ty>&& vt) noexcept : capacity(0) {
|
constexpr vector_type(vector_type<_Ty>&& vt) noexcept : capacity(0) {
|
||||||
@@ -107,18 +112,26 @@ public:
|
|||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
void emplace_back(_Ty _val) {
|
inline void grow() {
|
||||||
if (size >= capacity) { // geometric growth
|
if (size >= capacity) { // geometric growth
|
||||||
uint32_t new_capacity = size + 1 + (size >> 1);
|
uint32_t new_capacity = size + 1 + (size >> 1);
|
||||||
_Ty* n_container = (_Ty*)malloc(new_capacity * sizeof(_Ty));
|
_Ty* n_container = (_Ty*)malloc(new_capacity * sizeof(_Ty));
|
||||||
memcpy(n_container, container, sizeof(_Ty) * size);
|
memcpy(n_container, container, sizeof(_Ty) * size);
|
||||||
|
memset(n_container + size, 0, sizeof(_Ty) * (new_capacity - size));
|
||||||
if (capacity)
|
if (capacity)
|
||||||
free(container);
|
free(container);
|
||||||
container = n_container;
|
container = n_container;
|
||||||
capacity = new_capacity;
|
capacity = new_capacity;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
void emplace_back(const _Ty& _val) {
|
||||||
|
grow();
|
||||||
container[size++] = _val;
|
container[size++] = _val;
|
||||||
}
|
}
|
||||||
|
void emplace_back(_Ty&& _val) {
|
||||||
|
grow();
|
||||||
|
container[size++] = std::move(_val);
|
||||||
|
}
|
||||||
iterator_t erase(iterator_t _it) {
|
iterator_t erase(iterator_t _it) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Do bound checks
|
// Do bound checks
|
||||||
|
|||||||
+1
-1
@@ -22,4 +22,4 @@ FIELDS TERMINATED BY ","
|
|||||||
SELECT pairCorr(c, b) * d, sum(a), b
|
SELECT pairCorr(c, b) * d, sum(a), b
|
||||||
FROM test1
|
FROM test1
|
||||||
group by c,b,d
|
group by c,b,d
|
||||||
order by b ASC
|
order by b ASC
|
||||||
|
|||||||
+3
-3
@@ -24,11 +24,11 @@ LOAD DATA INFILE "data/test.csv"
|
|||||||
INTO TABLE tt
|
INTO TABLE tt
|
||||||
FIELDS TERMINATED BY ","
|
FIELDS TERMINATED BY ","
|
||||||
|
|
||||||
CREATE TABLE sale(Mont INT, sales INT)
|
CREATE TABLE sale1(Mont INT, sales INT)
|
||||||
|
|
||||||
LOAD DATA INFILE "data/moving_avg.csv"
|
LOAD DATA INFILE "data/moving_avg.csv"
|
||||||
INTO TABLE sale
|
INTO TABLE sale1
|
||||||
FIELDS TERMINATED BY ","
|
FIELDS TERMINATED BY ","
|
||||||
|
|
||||||
select sd(a) + sales from tt, sale where tt.a = sale.Mont
|
select sd(a) + sales from tt, sale1 where tt.a = sale1.Mont
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
AGGREGATION FUNCTION covariances2(x, y, w){
|
AGGREGATION FUNCTION covariances2(x, y, win){
|
||||||
xmeans := 0.;
|
xmeans := 0.;
|
||||||
ymeans := 0.;
|
ymeans := 0.;
|
||||||
l := _builtin_len;
|
l := _builtin_len;
|
||||||
@@ -11,6 +11,7 @@ AGGREGATION FUNCTION covariances2(x, y, w){
|
|||||||
ymeans := y[0];
|
ymeans := y[0];
|
||||||
_builtin_ret[0] := 0.;
|
_builtin_ret[0] := 0.;
|
||||||
}
|
}
|
||||||
|
w := win;
|
||||||
if (w > l)
|
if (w > l)
|
||||||
w := l;
|
w := l;
|
||||||
for (i := 1, j:= 0; i < w; i := i+1) {
|
for (i := 1, j:= 0; i < w; i := i+1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user