fixed limit doesn't work for queries w/o postproc.
This commit is contained in:
@@ -333,7 +333,7 @@ SELECT * FROM my_table WHERE c1 > 10
|
|||||||
License (BSD 3-Clause License): https://github.com/ben-strasser/fast-cpp-csv-parser/blob/master/LICENSE
|
License (BSD 3-Clause License): https://github.com/ben-strasser/fast-cpp-csv-parser/blob/master/LICENSE
|
||||||
|
|
||||||
- [Dragonbox](https://github.com/jk-jeon/dragonbox)<br>
|
- [Dragonbox](https://github.com/jk-jeon/dragonbox)<br>
|
||||||
Author: Junekey Jeon
|
Author: Junekey Jeon<br>
|
||||||
License (Boost, Apache2-LLVM): <br>https://github.com/jk-jeon/dragonbox/blob/master/LICENSE-Boost <br>
|
License (Boost, Apache2-LLVM): <br>https://github.com/jk-jeon/dragonbox/blob/master/LICENSE-Boost <br>
|
||||||
https://github.com/jk-jeon/dragonbox/blob/master/LICENSE-Apache2-LLVM
|
https://github.com/jk-jeon/dragonbox/blob/master/LICENSE-Apache2-LLVM
|
||||||
|
|
||||||
|
|||||||
@@ -550,7 +550,8 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None):
|
|||||||
continue
|
continue
|
||||||
elif q == 'r': # build and run
|
elif q == 'r': # build and run
|
||||||
if state.server_mode == RunType.Threaded:
|
if state.server_mode == RunType.Threaded:
|
||||||
qs = [ctypes.c_char_p(bytes(q, 'utf-8')) for q in cxt.queries if len(q)]
|
enc = lambda q: 'latin-1' if q.startswith('O') else 'utf-8'
|
||||||
|
qs = [ctypes.c_char_p(bytes(q, enc(q))) for q in cxt.queries if len(q)]
|
||||||
sz = len(qs)
|
sz = len(qs)
|
||||||
payload = (ctypes.c_char_p*sz)(*qs)
|
payload = (ctypes.c_char_p*sz)(*qs)
|
||||||
state.payload = payload
|
state.payload = payload
|
||||||
|
|||||||
+2
-3
@@ -424,7 +424,7 @@ class projection(ast_node):
|
|||||||
else:
|
else:
|
||||||
self.context.ccode = ''
|
self.context.ccode = ''
|
||||||
if self.limit != 0 and not self.outfile:
|
if self.limit != 0 and not self.outfile:
|
||||||
self.context.direct_output()
|
self.context.direct_output(self.limit)
|
||||||
|
|
||||||
class select_distinct(projection):
|
class select_distinct(projection):
|
||||||
first_order = 'select_distinct'
|
first_order = 'select_distinct'
|
||||||
@@ -1554,8 +1554,7 @@ class passthru_sql(ast_node):
|
|||||||
context.queries.append('Q' + sql.strip('\r\n\t ;') + ';')
|
context.queries.append('Q' + sql.strip('\r\n\t ;') + ';')
|
||||||
lq = sq.lower()
|
lq = sq.lower()
|
||||||
if lq.startswith('select'):
|
if lq.startswith('select'):
|
||||||
context.queries.append('O')
|
context.direct_output()
|
||||||
|
|
||||||
|
|
||||||
class user_module_function(OperatorBase):
|
class user_module_function(OperatorBase):
|
||||||
def __init__(self, name, nargs, ret_type, context : Context):
|
def __init__(self, name, nargs, ret_type, context : Context):
|
||||||
|
|||||||
@@ -250,8 +250,12 @@ class Context:
|
|||||||
self.ccode = ''
|
self.ccode = ''
|
||||||
self.finalize_query()
|
self.finalize_query()
|
||||||
|
|
||||||
def direct_output(self):
|
def direct_output(self, limit = -1, sep = ' ', end = '\n'):
|
||||||
self.queries.append('O')
|
if type(limit) is not int or limit > 2**32 - 1 or limit < 0:
|
||||||
|
limit = 2**32 - 1
|
||||||
|
limit = limit.to_bytes(4, 'little').decode('latin-1')
|
||||||
|
self.queries.append(
|
||||||
|
'O' + limit + sep + end)
|
||||||
|
|
||||||
def abandon_postproc(self):
|
def abandon_postproc(self):
|
||||||
self.ccode = ''
|
self.ccode = ''
|
||||||
|
|||||||
+9
-3
@@ -200,7 +200,7 @@ void print_monetdb_results(Server* srv, const char* sep = " ", const char* end =
|
|||||||
if (!srv->haserror() && srv->cnt && limit){
|
if (!srv->haserror() && srv->cnt && limit){
|
||||||
char buffer[output_buffer_size];
|
char buffer[output_buffer_size];
|
||||||
auto _res = static_cast<monetdbe_result*> (srv->res);
|
auto _res = static_cast<monetdbe_result*> (srv->res);
|
||||||
const auto& ncols = _res->ncols;
|
const auto ncols = _res->ncols;
|
||||||
monetdbe_column** cols = static_cast<monetdbe_column**>(malloc(sizeof(monetdbe_column*) * ncols));
|
monetdbe_column** cols = static_cast<monetdbe_column**>(malloc(sizeof(monetdbe_column*) * ncols));
|
||||||
prt_fn_t *prtfns = (prt_fn_t*) alloca(sizeof(prt_fn_t) * ncols);
|
prt_fn_t *prtfns = (prt_fn_t*) alloca(sizeof(prt_fn_t) * ncols);
|
||||||
char** col_data = static_cast<char**> (alloca(sizeof(char*) * ncols));
|
char** col_data = static_cast<char**> (alloca(sizeof(char*) * ncols));
|
||||||
@@ -210,6 +210,7 @@ void print_monetdb_results(Server* srv, const char* sep = " ", const char* end =
|
|||||||
const size_t l_sep = strlen(sep);
|
const size_t l_sep = strlen(sep);
|
||||||
const size_t l_end = strlen(end);
|
const size_t l_end = strlen(end);
|
||||||
char* _buffer = buffer;
|
char* _buffer = buffer;
|
||||||
|
const auto cnt = srv->cnt < limit? srv->cnt : limit;
|
||||||
|
|
||||||
for(uint32_t i = 0; i < ncols; ++i){
|
for(uint32_t i = 0; i < ncols; ++i){
|
||||||
err_msg = monetdbe_result_fetch(_res, &cols[i], i);
|
err_msg = monetdbe_result_fetch(_res, &cols[i], i);
|
||||||
@@ -228,7 +229,7 @@ void print_monetdb_results(Server* srv, const char* sep = " ", const char* end =
|
|||||||
header_string.resize(header_string.size() - l_sep - 1);
|
header_string.resize(header_string.size() - l_sep - 1);
|
||||||
header_string += end + std::string(header_string.size(), '=') + end;
|
header_string += end + std::string(header_string.size(), '=') + end;
|
||||||
fputs(header_string.c_str(), stdout);
|
fputs(header_string.c_str(), stdout);
|
||||||
for(uint64_t i = 0; i < srv->cnt; ++i){
|
for(uint64_t i = 0; i < cnt; ++i){
|
||||||
for(uint32_t j = 0; j < ncols; ++j){
|
for(uint32_t j = 0; j < ncols; ++j){
|
||||||
//copy the field to buf
|
//copy the field to buf
|
||||||
_buffer = prtfns[j](col_data[j], _buffer);
|
_buffer = prtfns[j](col_data[j], _buffer);
|
||||||
@@ -357,8 +358,13 @@ int dll_main(int argc, char** argv, Context* cxt){
|
|||||||
case 'O':
|
case 'O':
|
||||||
{
|
{
|
||||||
if(!server->haserror()){
|
if(!server->haserror()){
|
||||||
|
uint32_t limit;
|
||||||
|
memcpy(&limit, n_recvd[i] + 1, sizeof(uint32_t));
|
||||||
|
printf("Limit: %x\n", limit);
|
||||||
|
if (limit == 0)
|
||||||
|
continue;
|
||||||
timer.reset();
|
timer.reset();
|
||||||
print_monetdb_results(server);
|
print_monetdb_results(server, " ", "\n", limit);
|
||||||
cfg->stats.postproc_time += timer.elapsed();
|
cfg->stats.postproc_time += timer.elapsed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user