@@ -1732,6 +1732,7 @@ class SchemaParserV22(_SchemaParser):
1732
1732
"dclocal_read_repair_chance" , # kept to be safe, but see _build_table_options()
1733
1733
"local_read_repair_chance" ,
1734
1734
"replicate_on_write" ,
1735
+ 'in_memory' ,
1735
1736
"gc_grace_seconds" ,
1736
1737
"bloom_filter_fp_chance" ,
1737
1738
"caching" ,
@@ -1759,13 +1760,15 @@ def __init__(self, connection, timeout):
1759
1760
self .types_result = []
1760
1761
self .functions_result = []
1761
1762
self .aggregates_result = []
1763
+ self .scylla_result = []
1762
1764
1763
1765
self .keyspace_table_rows = defaultdict (list )
1764
1766
self .keyspace_table_col_rows = defaultdict (lambda : defaultdict (list ))
1765
1767
self .keyspace_type_rows = defaultdict (list )
1766
1768
self .keyspace_func_rows = defaultdict (list )
1767
1769
self .keyspace_agg_rows = defaultdict (list )
1768
1770
self .keyspace_table_trigger_rows = defaultdict (lambda : defaultdict (list ))
1771
+ self .keyspace_scylla_rows = defaultdict (lambda : defaultdict (list ))
1769
1772
1770
1773
def get_all_keyspaces (self ):
1771
1774
self ._query_all ()
@@ -2176,9 +2179,24 @@ def _query_all(self):
2176
2179
self ._aggregate_results ()
2177
2180
2178
2181
def _aggregate_results (self ):
2182
+ m = self .keyspace_scylla_rows
2183
+ for row in self .scylla_result :
2184
+ ksname = row ["keyspace_name" ]
2185
+ cfname = row [self ._table_name_col ]
2186
+ m [ksname ][cfname ].append (row )
2187
+
2179
2188
m = self .keyspace_table_rows
2180
2189
for row in self .tables_result :
2181
- m [row ["keyspace_name" ]].append (row )
2190
+ ksname = row ["keyspace_name" ]
2191
+ cfname = row [self ._table_name_col ]
2192
+ # in_memory property is stored in scylla private table
2193
+ # add it to table properties if enabled
2194
+ try :
2195
+ if self .keyspace_scylla_rows [ksname ][cfname ][0 ]["in_memory" ] == True :
2196
+ row ["in_memory" ] = True
2197
+ except (IndexError , KeyError ):
2198
+ pass
2199
+ m [ksname ].append (row )
2182
2200
2183
2201
m = self .keyspace_table_col_rows
2184
2202
for row in self .columns_result :
@@ -2220,6 +2238,7 @@ class SchemaParserV3(SchemaParserV22):
2220
2238
_SELECT_FUNCTIONS = "SELECT * FROM system_schema.functions"
2221
2239
_SELECT_AGGREGATES = "SELECT * FROM system_schema.aggregates"
2222
2240
_SELECT_VIEWS = "SELECT * FROM system_schema.views"
2241
+ _SELECT_SCYLLA = "SELECT * FROM system_schema.scylla_tables"
2223
2242
2224
2243
_table_name_col = 'table_name'
2225
2244
@@ -2235,6 +2254,7 @@ class SchemaParserV3(SchemaParserV22):
2235
2254
'crc_check_chance' ,
2236
2255
'dclocal_read_repair_chance' ,
2237
2256
'default_time_to_live' ,
2257
+ 'in_memory' ,
2238
2258
'gc_grace_seconds' ,
2239
2259
'max_index_interval' ,
2240
2260
'memtable_flush_period_in_ms' ,
@@ -2262,23 +2282,33 @@ def get_table(self, keyspaces, keyspace, table):
2262
2282
col_query = QueryMessage (query = self ._SELECT_COLUMNS + where_clause , consistency_level = cl )
2263
2283
indexes_query = QueryMessage (query = self ._SELECT_INDEXES + where_clause , consistency_level = cl )
2264
2284
triggers_query = QueryMessage (query = self ._SELECT_TRIGGERS + where_clause , consistency_level = cl )
2285
+ scylla_query = QueryMessage (query = self ._SELECT_SCYLLA + where_clause , consistency_level = cl )
2265
2286
2266
2287
# in protocol v4 we don't know if this event is a view or a table, so we look for both
2267
2288
where_clause = bind_params (" WHERE keyspace_name = %s AND view_name = %s" , (keyspace , table ), _encoder )
2268
2289
view_query = QueryMessage (query = self ._SELECT_VIEWS + where_clause ,
2269
2290
consistency_level = cl )
2270
2291
((cf_success , cf_result ), (col_success , col_result ),
2271
2292
(indexes_sucess , indexes_result ), (triggers_success , triggers_result ),
2272
- (view_success , view_result )) = (
2293
+ (view_success , view_result ),
2294
+ (scylla_sucess , scylla_result )) = (
2273
2295
self .connection .wait_for_responses (
2274
2296
cf_query , col_query , indexes_query , triggers_query ,
2275
- view_query , timeout = self .timeout , fail_on_error = False )
2297
+ view_query , scylla_query , timeout = self .timeout , fail_on_error = False )
2276
2298
)
2277
2299
table_result = self ._handle_results (cf_success , cf_result )
2278
2300
col_result = self ._handle_results (col_success , col_result )
2279
2301
if table_result :
2280
2302
indexes_result = self ._handle_results (indexes_sucess , indexes_result )
2281
2303
triggers_result = self ._handle_results (triggers_success , triggers_result )
2304
+ # in_memory property is stored in scylla private table
2305
+ # add it to table properties if enabled
2306
+ scylla_result = self ._handle_results (scylla_success , scylla_result )
2307
+ try :
2308
+ if scylla_result [0 ]["in_memory" ] == True :
2309
+ table_result [0 ]["in_memory" ] = True
2310
+ except (IndexError , KeyError ):
2311
+ pass
2282
2312
return self ._build_table_metadata (table_result [0 ], col_result , triggers_result , indexes_result )
2283
2313
2284
2314
view_result = self ._handle_results (view_success , view_result )
@@ -2434,7 +2464,8 @@ def _query_all(self):
2434
2464
QueryMessage (query = self ._SELECT_AGGREGATES , consistency_level = cl ),
2435
2465
QueryMessage (query = self ._SELECT_TRIGGERS , consistency_level = cl ),
2436
2466
QueryMessage (query = self ._SELECT_INDEXES , consistency_level = cl ),
2437
- QueryMessage (query = self ._SELECT_VIEWS , consistency_level = cl )
2467
+ QueryMessage (query = self ._SELECT_VIEWS , consistency_level = cl ),
2468
+ QueryMessage (query = self ._SELECT_SCYLLA , consistency_level = cl )
2438
2469
]
2439
2470
2440
2471
((ks_success , ks_result ),
@@ -2445,7 +2476,8 @@ def _query_all(self):
2445
2476
(aggregates_success , aggregates_result ),
2446
2477
(triggers_success , triggers_result ),
2447
2478
(indexes_success , indexes_result ),
2448
- (views_success , views_result )) = self .connection .wait_for_responses (
2479
+ (views_success , views_result ),
2480
+ (scylla_success , scylla_result )) = self .connection .wait_for_responses (
2449
2481
* queries , timeout = self .timeout , fail_on_error = False
2450
2482
)
2451
2483
@@ -2458,6 +2490,7 @@ def _query_all(self):
2458
2490
self .aggregates_result = self ._handle_results (aggregates_success , aggregates_result )
2459
2491
self .indexes_result = self ._handle_results (indexes_success , indexes_result )
2460
2492
self .views_result = self ._handle_results (views_success , views_result )
2493
+ self .scylla_result = self ._handle_results (scylla_success , scylla_result )
2461
2494
2462
2495
self ._aggregate_results ()
2463
2496
0 commit comments