You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AQuery/out.cpp

60 lines
2.3 KiB

3 years ago
#include <unordered_map>
#include "./server/libaquery.h"
3 years ago
#include "./server/hasher.h"
#include "./server/aggregations.h"
#include "csv.h"
extern "C" int __DLLEXPORT__ dllmain(Context* cxt) {
using namespace std;
using namespace types;
3 years ago
3 years ago
auto test = new TableInfo<int,int,int,int>("test", 4);
cxt->tables.insert({"test", test});
auto& test_a = *(ColRef<int> *)(&test->colrefs[0]);
auto& test_b = *(ColRef<int> *)(&test->colrefs[1]);
auto& test_c = *(ColRef<int> *)(&test->colrefs[2]);
auto& test_d = *(ColRef<int> *)(&test->colrefs[3]);
test_a.init();
test_b.init();
test_c.init();
test_d.init();
3 years ago
io::CSVReader<4> csv_reader_4bTMJ9("test.csv");
csv_reader_4bTMJ9.read_header(io::ignore_extra_column, "a","b","c","d");
int tmp_78E1nhZJ;
int tmp_4wnHGd9t;
int tmp_5OL9GlRp;
int tmp_155GVQC6;
while(csv_reader_4bTMJ9.read_row(tmp_78E1nhZJ,tmp_4wnHGd9t,tmp_5OL9GlRp,tmp_155GVQC6)) {
3 years ago
test_a.emplace_back(tmp_78E1nhZJ);
test_b.emplace_back(tmp_4wnHGd9t);
test_c.emplace_back(tmp_5OL9GlRp);
test_d.emplace_back(tmp_155GVQC6);
3 years ago
}
3 years ago
typedef record<decltype(test_a[0]),decltype(test_b[0]),decltype(test_d[0])> record_type6jn8Y49;
unordered_map<record_type6jn8Y49, vector_type<uint32_t>, transTypes<record_type6jn8Y49, hasher>> g5gn6KEb;
for (uint32_t i3V = 0; i3V < test_a.size; ++i3V){
g5gn6KEb[forward_as_tuple(test_a[i3V],test_b[i3V],test_d[i3V])].emplace_back(i3V);
3 years ago
}
3 years ago
auto out_4DCN = new TableInfo<decays<decltype(sum(test_c))>,value_type<decays<decltype(test_b)>>,value_type<decays<decltype(test_d)>>>("out_4DCN", 3);
cxt->tables.insert({"out_4DCN", out_4DCN});
auto& out_4DCN_sumtestc = *(ColRef<decays<decltype(sum(test_c))>> *)(&out_4DCN->colrefs[0]);
auto& out_4DCN_b = *(ColRef<value_type<decays<decltype(test_b)>>> *)(&out_4DCN->colrefs[1]);
auto& out_4DCN_d = *(ColRef<value_type<decays<decltype(test_d)>>> *)(&out_4DCN->colrefs[2]);
3 years ago
auto lineage = test->bind(out_4DCN);
3 years ago
out_4DCN_sumtestc.init();
out_4DCN_b.init();
out_4DCN_d.init();
for(auto& i1s : g5gn6KEb) {
auto &key_4Q0aEyH = i1s.first;
auto &val_7BUMR6d = i1s.second;
out_4DCN_sumtestc.emplace_back(sum(test_c[val_7BUMR6d]));
out_4DCN_b.emplace_back(get<1>(key_4Q0aEyH));
out_4DCN_d.emplace_back(get<2>(key_4Q0aEyH));
3 years ago
lineage.emplace_back(val_7BUMR6d[0]);
3 years ago
}
3 years ago
print(lineage.rid);
auto d6X0PMzl = out_4DCN->order_by_view<-3,1>();
3 years ago
print(d6X0PMzl);
3 years ago
return 0;
}