update
This commit is contained in:
+24
-2
@@ -1746,13 +1746,35 @@ class user_module_function(OperatorBase):
|
||||
# builtin_operators[name] = self
|
||||
udf.try_init_udf(context)
|
||||
|
||||
class cache(ast_node):
|
||||
name = 'cache'
|
||||
first_order = name
|
||||
def init(self, node):
|
||||
source = node['cache']['source']
|
||||
# lazy = node['cache']['lazy']
|
||||
lazy = 0
|
||||
try:
|
||||
tbl : TableInfo = self.context.tables_byname[source]
|
||||
except KeyError:
|
||||
raise ValueError(f'Cannot find table {source}.')
|
||||
from common.utils import encode_integral
|
||||
|
||||
tbl.cached = True
|
||||
schema_string = encode_integral(len(tbl.columns))
|
||||
for t in tbl.columns:
|
||||
schema_string += t.name + '\0' + \
|
||||
encode_integral(aquery_types[t.type.ctype_name])
|
||||
|
||||
from common.utils import send_to_server
|
||||
send_to_server(f'C{source}\0{"l" if lazy else "e"}\0{schema_string}\0')
|
||||
|
||||
def include(objs):
|
||||
import inspect
|
||||
for _, cls in inspect.getmembers(objs):
|
||||
if inspect.isclass(cls) and issubclass(cls, ast_node) and type(cls.first_order) is str:
|
||||
ast_node.types[cls.first_order] = cls
|
||||
|
||||
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
include(sys.modules[__name__])
|
||||
|
||||
+4
-2
@@ -73,6 +73,7 @@ class TableInfo:
|
||||
self.columns : List[ColRef] = []
|
||||
self.triggers : Set[create_trigger] = set()
|
||||
self.cxt = cxt
|
||||
self.cached = False
|
||||
# keep track of temp vars
|
||||
self.rec = None
|
||||
self.add_cols(cols)
|
||||
@@ -186,7 +187,7 @@ class Context:
|
||||
self.force_compiled = False
|
||||
self.use_gc = compile_use_gc
|
||||
self.system_state: Optional[PromptState] = state
|
||||
|
||||
self.use_cached_tables = True
|
||||
# self.new() called everytime new query batch is started
|
||||
|
||||
def get_scan_var(self):
|
||||
@@ -267,9 +268,10 @@ class Context:
|
||||
self.finalize_query()
|
||||
|
||||
def direct_output(self, limit = -1, sep = ' ', end = '\n'):
|
||||
from common.utils import encode_integral
|
||||
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')
|
||||
limit = encode_integral(limit)
|
||||
self.queries.append(
|
||||
'O' + limit + sep + end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user