CUBRID Engine  latest
filter_pred_cache.c File Reference
#include "binaryheap.h"
#include "filter_pred_cache.h"
#include "lock_free.h"
#include "query_executor.h"
#include "stream_to_xasl.h"
#include "system_parameter.h"
#include "thread_lockfree_hash_map.hpp"
#include "thread_manager.hpp"
#include "xasl.h"
#include "xasl_unpack_info.hpp"
#include <algorithm>
Include dependency graph for filter_pred_cache.c:

Go to the source code of this file.

Classes

struct  fpcache_ent
 
struct  fpcache_cleanup_candidate
 

Macros

#define FPCACHE_PTR_TO_KEY(ptr)   ((BTID *) ptr)
 
#define FPCACHE_PTR_TO_ENTRY(ptr)   ((FPCACHE_ENTRY *) ptr)
 
#define FPCACHE_CLEANUP_RATIO   0.2
 
#define FPCACHE_DELETE_BTIDS_SIZE   1024
 

Typedefs

typedef struct fpcache_ent FPCACHE_ENTRY
 
using fpcache_hashmap_type = cubthread::lockfree_hashmap< BTID, fpcache_ent >
 
using fpcache_hashmap_iterator = fpcache_hashmap_type::iterator
 
typedef struct fpcache_cleanup_candidate FPCACHE_CLEANUP_CANDIDATE
 

Functions

static void * fpcache_entry_alloc (void)
 
static int fpcache_entry_free (void *entry)
 
static int fpcache_entry_init (void *entry)
 
static int fpcache_entry_uninit (void *entry)
 
static int fpcache_copy_key (void *src, void *dest)
 
static void fpcache_cleanup (THREAD_ENTRY *thread_p)
 
static BH_CMP_RESULT fpcache_compare_cleanup_candidates (const void *left, const void *right, BH_CMP_ARG ingore_arg)
 
int fpcache_initialize (THREAD_ENTRY *thread_p)
 
void fpcache_finalize (THREAD_ENTRY *thread_p)
 
int fpcache_claim (THREAD_ENTRY *thread_p, BTID *btid, or_predicate *or_pred, pred_expr_with_context **filter_pred)
 
int fpcache_retire (THREAD_ENTRY *thread_p, OID *class_oid, BTID *btid, pred_expr_with_context *filter_pred)
 
void fpcache_remove_by_class (THREAD_ENTRY *thread_p, const OID *class_oid)
 
void fpcache_dump (THREAD_ENTRY *thread_p, FILE *fp)
 
void fpcache_drop_all (THREAD_ENTRY *thread_p)
 

Variables

static bool fpcache_Enabled = false
 
static INT32 fpcache_Soft_capacity = 0
 
static fpcache_hashmap_type fpcache_Hashmap
 
static LF_HASH_TABLE fpcache_Ht = LF_HASH_TABLE_INITIALIZER
 
static LF_FREELIST fpcache_Ht_freelist = LF_FREELIST_INITIALIZER
 
static volatile INT32 fpcache_Entry_counter = 0
 
static volatile INT32 fpcache_Clone_counter = 0
 
static int fpcache_Clone_stack_size
 
INT32 fpcache_Cleanup_flag
 
BINARY_HEAPfpcache_Cleanup_bh
 
static INT64 fpcache_Stat_lookup
 
static INT64 fpcache_Stat_miss
 
static INT64 fpcache_Stat_hit
 
static INT64 fpcache_Stat_discard
 
static INT64 fpcache_Stat_add
 
static INT64 fpcache_Stat_clone_miss
 
static INT64 fpcache_Stat_clone_hit
 
static INT64 fpcache_Stat_clone_discard
 
static INT64 fpcache_Stat_clone_add
 
static INT64 fpcache_Stat_cleanup
 
static INT64 fpcache_Stat_cleanup_entry
 
static LF_ENTRY_DESCRIPTOR fpcache_Entry_descriptor
 

Macro Definition Documentation

#define FPCACHE_CLEANUP_RATIO   0.2

Definition at line 90 of file filter_pred_cache.c.

Referenced by fpcache_initialize().

#define FPCACHE_DELETE_BTIDS_SIZE   1024

Referenced by fpcache_remove_by_class().

#define FPCACHE_PTR_TO_ENTRY (   ptr)    ((FPCACHE_ENTRY *) ptr)

Definition at line 63 of file filter_pred_cache.c.

Referenced by fpcache_entry_init(), and fpcache_entry_uninit().

#define FPCACHE_PTR_TO_KEY (   ptr)    ((BTID *) ptr)

Definition at line 62 of file filter_pred_cache.c.

Typedef Documentation

Definition at line 81 of file filter_pred_cache.c.

typedef struct fpcache_ent FPCACHE_ENTRY

Definition at line 38 of file filter_pred_cache.c.

Function Documentation

static BH_CMP_RESULT fpcache_compare_cleanup_candidates ( const void *  left,
const void *  right,
BH_CMP_ARG  ingore_arg 
)
static

Definition at line 730 of file filter_pred_cache.c.

References BH_EQ, BH_GT, and BH_LT.

Referenced by fpcache_initialize().

Here is the caller graph for this function:

static int fpcache_copy_key ( void *  src,
void *  dest 
)
static

Definition at line 342 of file filter_pred_cache.c.

References BTID_COPY, and NO_ERROR.

void fpcache_drop_all ( THREAD_ENTRY thread_p)
static void * fpcache_entry_alloc ( void  )
static

Definition at line 247 of file filter_pred_cache.c.

References fpcache_ent::mutex, NULL, and pthread_mutex_init.

static int fpcache_entry_free ( void *  entry)
static

Definition at line 265 of file filter_pred_cache.c.

References fpcache_ent::mutex, NO_ERROR, and pthread_mutex_destroy.

void fpcache_finalize ( THREAD_ENTRY thread_p)

Definition at line 206 of file filter_pred_cache.c.

References bh_destroy(), db_change_private_heap(), cubthread::lockfree_hashmap< Key, T >::destroy(), fpcache_Enabled, and NULL.

Referenced by boot_restart_server(), and xboot_shutdown_server().

Here is the caller graph for this function:

void fpcache_remove_by_class ( THREAD_ENTRY thread_p,
const OID class_oid 
)

Variable Documentation

BINARY_HEAP* fpcache_Cleanup_bh

Definition at line 88 of file filter_pred_cache.c.

INT32 fpcache_Cleanup_flag

Definition at line 87 of file filter_pred_cache.c.

Referenced by fpcache_cleanup(), and fpcache_initialize().

volatile INT32 fpcache_Clone_counter = 0
static
int fpcache_Clone_stack_size
static
volatile INT32 fpcache_Entry_counter = 0
static
LF_ENTRY_DESCRIPTOR fpcache_Entry_descriptor
static
Initial value:
= {
offsetof (FPCACHE_ENTRY, stack),
offsetof (FPCACHE_ENTRY, next),
offsetof (FPCACHE_ENTRY, del_id),
offsetof (FPCACHE_ENTRY, btid),
offsetof (FPCACHE_ENTRY, mutex),
NULL,
}
static int fpcache_entry_init(void *entry)
static API_MUTEX mutex
Definition: api_util.c:72
unsigned int btree_hash_btid(void *btid, int hash_size)
Definition: btree.c:32874
static int fpcache_copy_key(void *src, void *dest)
int btree_compare_btids(void *mem_btid1, void *mem_btid2)
Definition: btree.c:21777
static int fpcache_entry_uninit(void *entry)
#define NULL
Definition: freelistheap.h:34
static int fpcache_entry_free(void *entry)
#define LF_EM_USING_MUTEX
Definition: lock_free.h:60
static void * fpcache_entry_alloc(void)

Definition at line 116 of file filter_pred_cache.c.

fpcache_hashmap_type fpcache_Hashmap
static

Definition at line 72 of file filter_pred_cache.c.

Definition at line 73 of file filter_pred_cache.c.

LF_FREELIST fpcache_Ht_freelist = LF_FREELIST_INITIALIZER
static

Definition at line 74 of file filter_pred_cache.c.

INT32 fpcache_Soft_capacity = 0
static
INT64 fpcache_Stat_add
static

Definition at line 97 of file filter_pred_cache.c.

Referenced by fpcache_dump(), fpcache_initialize(), and fpcache_retire().

INT64 fpcache_Stat_cleanup
static

Definition at line 102 of file filter_pred_cache.c.

Referenced by fpcache_cleanup(), fpcache_dump(), and fpcache_initialize().

INT64 fpcache_Stat_cleanup_entry
static

Definition at line 103 of file filter_pred_cache.c.

Referenced by fpcache_cleanup(), fpcache_dump(), and fpcache_initialize().

INT64 fpcache_Stat_clone_add
static

Definition at line 101 of file filter_pred_cache.c.

Referenced by fpcache_dump(), and fpcache_retire().

INT64 fpcache_Stat_clone_discard
static
INT64 fpcache_Stat_clone_hit
static

Definition at line 99 of file filter_pred_cache.c.

Referenced by fpcache_claim(), fpcache_dump(), and fpcache_initialize().

INT64 fpcache_Stat_clone_miss
static

Definition at line 98 of file filter_pred_cache.c.

Referenced by fpcache_claim(), fpcache_dump(), and fpcache_initialize().

INT64 fpcache_Stat_discard
static
INT64 fpcache_Stat_hit
static

Definition at line 95 of file filter_pred_cache.c.

Referenced by fpcache_claim(), fpcache_dump(), and fpcache_initialize().

INT64 fpcache_Stat_lookup
static

Definition at line 93 of file filter_pred_cache.c.

Referenced by fpcache_claim(), fpcache_dump(), and fpcache_initialize().

INT64 fpcache_Stat_miss
static

Definition at line 94 of file filter_pred_cache.c.

Referenced by fpcache_claim(), fpcache_dump(), and fpcache_initialize().