62 #define FPCACHE_PTR_TO_KEY(ptr) ((BTID *) ptr) 63 #define FPCACHE_PTR_TO_ENTRY(ptr) ((FPCACHE_ENTRY *) ptr) 90 #define FPCACHE_CLEANUP_RATIO 0.2 146 HL_HEAPID save_heapid;
158 const int freelist_block_count = 2;
161 fpcache_Entry_descriptor);
175 if (fpcache_Cleanup_bh ==
NULL)
208 HL_HEAPID save_heapid;
219 if (fpcache_Cleanup_bh !=
NULL)
222 fpcache_Cleanup_bh =
NULL;
250 if (fpcache_entry ==
NULL)
255 return fpcache_entry;
307 HL_HEAPID old_private_heap;
371 fpcache_entry = fpcache_Hashmap.
find (thread_p, *btid);
372 if (fpcache_entry ==
NULL)
400 if (*filter_pred ==
NULL)
431 bool inserted =
false;
437 inserted = fpcache_Hashmap.
find_or_insert (thread_p, *btid, fpcache_entry);
438 if (fpcache_entry !=
NULL)
484 if (filter_pred !=
NULL)
505 #define FPCACHE_DELETE_BTIDS_SIZE 1024 518 int n_delete_btids = 0;
520 bool finished =
false;
534 fpcache_entry = iter.iterate ();
536 if (fpcache_entry ==
NULL)
549 delete_btids[n_delete_btids++] = fpcache_entry->
btid;
556 fpcache_Hashmap.end_tran (thread_p);
563 for (btid_index = 0; btid_index < n_delete_btids; btid_index++)
565 if (fpcache_Hashmap.erase (thread_p, delete_btids[btid_index]))
580 #undef FPCACHE_DELETE_BTIDS_SIZE 601 fprintf (fp,
"Filter predicate cache is disabled.\n");
607 fprintf (fp,
"Filter predicate cache\n");
608 fprintf (fp,
"Stats: \n");
613 fprintf (fp,
"Entry Hits: %lld\n", (
long long) ATOMIC_LOAD_64 (&
fpcache_Stat_hit));
614 fprintf (fp,
"Entry Miss: %lld\n", (
long long) ATOMIC_LOAD_64 (&
fpcache_Stat_miss));
619 fprintf (fp,
"Adds: %lld\n", (
long long) ATOMIC_LOAD_64 (&
fpcache_Stat_add));
625 fprintf (fp,
"\nEntries:\n");
685 candidate.
btid = fpcache_entry->
btid;
692 for (candidate_index = 0; candidate_index < fpcache_Cleanup_bh->
element_count; candidate_index++)
695 bh_element_at (fpcache_Cleanup_bh, candidate_index, &candidate);
698 if (fpcache_Hashmap.erase (thread_p, candidate.
btid))
736 if (left_timeval.tv_sec < right_timeval.tv_sec)
740 else if (left_timeval.tv_sec == right_timeval.tv_sec)
769 fpcache_Hashmap.
clear (thread_p);
static int fpcache_entry_init(void *entry)
static void fpcache_cleanup(THREAD_ENTRY *thread_p)
cubthread::entry * thread_get_thread_entry_info(void)
#define FPCACHE_DELETE_BTIDS_SIZE
void lf_hash_destroy(LF_HASH_TABLE *table)
#define FPCACHE_CLEANUP_RATIO
#define pthread_mutex_init(a, b)
static INT64 fpcache_Stat_cleanup_entry
unsigned int btree_hash_btid(void *btid, int hash_size)
void bh_element_at(BINARY_HEAP *heap, int index, void *elem)
#define pthread_mutex_unlock(a)
#define ASSERT_ERROR_AND_SET(error_code)
#define assert_release(e)
static volatile INT32 fpcache_Clone_counter
static INT64 fpcache_Stat_hit
static BH_CMP_RESULT fpcache_compare_cleanup_candidates(const void *left, const void *right, BH_CMP_ARG ingore_arg)
static int fpcache_copy_key(void *src, void *dest)
#define FPCACHE_PTR_TO_ENTRY(ptr)
static INT64 fpcache_Stat_miss
static bool fpcache_Enabled
HL_HEAPID db_change_private_heap(THREAD_ENTRY *thread_p, HL_HEAPID heap_id)
#define COPY_OID(dest_oid_ptr, src_oid_ptr)
INT32 fpcache_Cleanup_flag
bool find_or_insert(cubthread::entry *thread_p, Key &key, T *&t)
#define LF_HASH_TABLE_INITIALIZER
static INT64 fpcache_Stat_discard
static INT64 fpcache_Stat_add
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
void bh_destroy(THREAD_ENTRY *thread_p, BINARY_HEAP *heap)
static INT32 fpcache_Soft_capacity
int prm_get_integer_value(PARAM_ID prm_id)
T * find(cubthread::entry *thread_p, Key &key)
#define ER_OUT_OF_VIRTUAL_MEMORY
PRED_EXPR_WITH_CONTEXT ** clone_stack
static LF_FREELIST fpcache_Ht_freelist
int btree_compare_btids(void *mem_btid1, void *mem_btid2)
void fpcache_remove_by_class(THREAD_ENTRY *thread_p, const OID *class_oid)
static int fpcache_entry_uninit(void *entry)
static INT64 fpcache_Stat_clone_hit
static INT64 fpcache_Stat_lookup
#define OID_EQ(oidp1, oidp2)
static INT64 fpcache_Stat_clone_add
void init(lf_tran_system &transys, int entry_idx, int hash_size, int freelist_block_size, int freelist_block_count, lf_entry_descriptor &edesc)
#define db_private_free_and_init(thrd, ptr)
static LF_ENTRY_DESCRIPTOR fpcache_Entry_descriptor
static fpcache_hashmap_type fpcache_Hashmap
#define LF_FREELIST_INITIALIZER
void free_xasl_unpack_info(THREAD_ENTRY *thread_p, REFPTR(XASL_UNPACK_INFO, xasl_unpack_info))
static volatile INT32 fpcache_Entry_counter
struct timeval time_last_used
static INT64 fpcache_Stat_clone_discard
void fpcache_finalize(THREAD_ENTRY *thread_p)
#define free_and_init(ptr)
int fpcache_initialize(THREAD_ENTRY *thread_p)
#define BTID_COPY(btid_ptr1, btid_ptr2)
BH_TRY_INSERT_RESULT bh_try_insert(BINARY_HEAP *heap, void *elem, void *replaced)
static int fpcache_Clone_stack_size
void fpcache_drop_all(THREAD_ENTRY *thread_p)
void lf_freelist_destroy(LF_FREELIST *freelist)
BINARY_HEAP * bh_create(THREAD_ENTRY *thread_p, int max_capacity, int elem_size, bh_key_comparator cmp_func, BH_CMP_ARG cmp_arg)
struct timeval time_last_used
static INT64 fpcache_Stat_clone_miss
int qexec_clear_pred_context(THREAD_ENTRY *thread_p, pred_expr_with_context *pred_filter, bool dealloc_dbvalues)
static int fpcache_entry_free(void *entry)
void fpcache_dump(THREAD_ENTRY *thread_p, FILE *fp)
BINARY_HEAP * fpcache_Cleanup_bh
void clear(cubthread::entry *thread_p)
static INT64 fpcache_Stat_cleanup
#define LF_EM_USING_MUTEX
int stx_map_stream_to_filter_pred(THREAD_ENTRY *thread_p, pred_expr_with_context **pred, char *pred_stream, int pred_stream_size)
static LF_HASH_TABLE fpcache_Ht
int fpcache_retire(THREAD_ENTRY *thread_p, OID *class_oid, BTID *btid, pred_expr_with_context *filter_pred)
LF_TRAN_SYSTEM fpcache_Ts
int fpcache_claim(THREAD_ENTRY *thread_p, BTID *btid, or_predicate *or_pred, pred_expr_with_context **filter_pred)
#define pthread_mutex_destroy(a)
static void * fpcache_entry_alloc(void)
XASL_UNPACK_INFO * unpack_info