CUBRID Engine  latest
partition.c File Reference
#include <assert.h>
#include "partition_sr.h"
#include "dbtype.h"
#include "fetch.h"
#include "heap_file.h"
#include "object_primitive.h"
#include "object_representation.h"
#include "query_aggregate.hpp"
#include "query_executor.h"
#include "query_opfunc.h"
#include "stream_to_xasl.h"
#include "xasl.h"
#include "xasl_predicate.hpp"
#include "xasl_unpack_info.hpp"
Include dependency graph for partition.c:

Go to the source code of this file.

Classes

struct  pruning_bitset
 
struct  pruning_bitset_iterator
 
struct  partition_cache_entry
 

Macros

#define NELEMENTS   1024 /* maximum number of partitions */
 
#define _WORDSIZE   8 * sizeof(int)
 
#define MAX_ELEMENTS   1024
 
#define BITSET_WORD_SIZE   sizeof (unsigned int)
 
#define BITS_IN_WORD   (8 * BITSET_WORD_SIZE)
 
#define BITSET_WORD_COUNT   (MAX_ELEMENTS / BITS_IN_WORD)
 
#define BITSET_LENGTH(s)   ((((s)->count - 1) / BITS_IN_WORD)+1)
 
#define PARTITIONS_COUNT(pinfo)   (((pinfo) == NULL) ? 0 : (pinfo)->count - 1)
 
#define PARTITION_CACHE_NAME   "Partitions_Cache"
 
#define PARTITION_CACHE_SIZE   200
 
#define PARTITION_IS_CACHE_INITIALIZED()   (db_Partition_Ht != NULL)
 

Typedefs

typedef enum match_status MATCH_STATUS
 
typedef enum pruning_op PRUNING_OP
 
typedef struct pruning_bitset PRUNING_BITSET
 
typedef struct pruning_bitset_iterator PRUNING_BITSET_ITERATOR
 
typedef struct partition_cache_entry PARTITION_CACHE_ENTRY
 

Enumerations

enum  match_status { MATCH_OK, MATCH_NOT_FOUND }
 
enum  pruning_op {
  PO_INVALID = 0, PO_LT, PO_LE, PO_GT,
  PO_GE, PO_EQ, PO_NE, PO_IN,
  PO_NOT_IN, PO_IS_NULL
}
 

Functions

static void pruningset_init (PRUNING_BITSET *, int)
 
static void pruningset_set_all (PRUNING_BITSET *)
 
static void pruningset_copy (PRUNING_BITSET *, const PRUNING_BITSET *)
 
static void pruningset_add (PRUNING_BITSET *, int)
 
static void pruningset_remove (PRUNING_BITSET *, int)
 
static void pruningset_intersect (PRUNING_BITSET *, const PRUNING_BITSET *)
 
static void pruningset_union (PRUNING_BITSET *, const PRUNING_BITSET *)
 
static bool pruningset_is_set (const PRUNING_BITSET *, int)
 
static int pruningset_popcount (const PRUNING_BITSET *)
 
static void pruningset_iterator_init (const PRUNING_BITSET *, PRUNING_BITSET_ITERATOR *)
 
static int pruningset_iterator_next (PRUNING_BITSET_ITERATOR *)
 
static int pruningset_to_spec_list (PRUNING_CONTEXT *pinfo, const PRUNING_BITSET *pruned)
 
static int partition_free_cache_entry_kv (const void *key, void *data, void *args)
 
static int partition_free_cache_entry (PARTITION_CACHE_ENTRY *entry)
 
static int partition_cache_pruning_context (PRUNING_CONTEXT *pinfo, bool *already_exists)
 
static bool partition_load_context_from_cache (PRUNING_CONTEXT *pinfo, bool *is_modified)
 
static int partition_cache_entry_to_pruning_context (PRUNING_CONTEXT *pinfo, PARTITION_CACHE_ENTRY *entry_p)
 
static PARTITION_CACHE_ENTRYpartition_pruning_context_to_cache_entry (PRUNING_CONTEXT *pinfo)
 
static PRUNING_OP partition_rel_op_to_pruning_op (REL_OP op)
 
static int partition_load_partition_predicate (PRUNING_CONTEXT *pinfo, OR_PARTITION *master)
 
static void partition_free_partition_predicate (PRUNING_CONTEXT *pinfo)
 
static void partition_set_specified_partition (PRUNING_CONTEXT *pinfo, const OID *partition_oid)
 
static int partition_get_position_in_key (PRUNING_CONTEXT *pinfo, BTID *btid)
 
static ATTR_ID partition_get_attribute_id (REGU_VARIABLE *regu_var)
 
static void partition_set_cache_info_for_expr (REGU_VARIABLE *regu_var, ATTR_ID attr_id, HEAP_CACHE_ATTRINFO *info)
 
static MATCH_STATUS partition_match_pred_expr (PRUNING_CONTEXT *pinfo, const PRED_EXPR *pr, PRUNING_BITSET *pruned)
 
static MATCH_STATUS partition_match_index_key (PRUNING_CONTEXT *pinfo, const KEY_INFO *key, RANGE_TYPE range_type, PRUNING_BITSET *pruned)
 
static MATCH_STATUS partition_match_key_range (PRUNING_CONTEXT *pinfo, const KEY_RANGE *range, PRUNING_BITSET *pruned)
 
static bool partition_do_regu_variables_match (PRUNING_CONTEXT *pinfo, const REGU_VARIABLE *left, const REGU_VARIABLE *right)
 
static MATCH_STATUS partition_prune (PRUNING_CONTEXT *pinfo, const REGU_VARIABLE *arg, const PRUNING_OP op, PRUNING_BITSET *pruned)
 
static MATCH_STATUS partition_prune_db_val (PRUNING_CONTEXT *pinfo, const DB_VALUE *val, const PRUNING_OP op, PRUNING_BITSET *pruned)
 
static int partition_get_value_from_key (PRUNING_CONTEXT *pinfo, const REGU_VARIABLE *key, DB_VALUE *attr_key, bool *is_present)
 
static int partition_get_value_from_inarith (PRUNING_CONTEXT *pinfo, const REGU_VARIABLE *src, DB_VALUE *value_p, bool *is_present)
 
static int partition_get_value_from_regu_var (PRUNING_CONTEXT *pinfo, const REGU_VARIABLE *key, DB_VALUE *value_p, bool *is_value)
 
static MATCH_STATUS partition_prune_range (PRUNING_CONTEXT *pinfo, const DB_VALUE *val, const PRUNING_OP op, PRUNING_BITSET *pruned)
 
static MATCH_STATUS partition_prune_list (PRUNING_CONTEXT *pinfo, const DB_VALUE *val, const PRUNING_OP op, PRUNING_BITSET *pruned)
 
static MATCH_STATUS partition_prune_hash (PRUNING_CONTEXT *pinfo, const DB_VALUE *val, const PRUNING_OP op, PRUNING_BITSET *pruned)
 
static int partition_find_partition_for_record (PRUNING_CONTEXT *pinfo, const OID *class_oid, RECDES *recdes, OID *partition_oid, HFID *partition_hfid)
 
static int partition_prune_heap_scan (PRUNING_CONTEXT *pinfo)
 
static int partition_prune_index_scan (PRUNING_CONTEXT *pinfo)
 
static int partition_find_inherited_btid (THREAD_ENTRY *thread_p, OID *src_class, OID *dest_class, BTID *src_btid, BTID *dest_btid)
 
static int partition_attrinfo_get_key (THREAD_ENTRY *thread_p, PRUNING_CONTEXT *pcontext, DB_VALUE *curr_key, OID *class_oid, BTID *btid, DB_VALUE *partition_key)
 
static bool partition_decrement_value (DB_VALUE *val)
 
int partition_cache_init (THREAD_ENTRY *thread_p)
 
void partition_cache_finalize (THREAD_ENTRY *thread_p)
 
void partition_decache_class (THREAD_ENTRY *thread_p, const OID *class_oid)
 
static bool partition_is_reguvar_const (const REGU_VARIABLE *regu_var)
 
void partition_init_pruning_context (PRUNING_CONTEXT *pinfo)
 
int partition_find_root_class_oid (THREAD_ENTRY *thread_p, const OID *class_oid, OID *super_oid)
 
int partition_load_pruning_context (THREAD_ENTRY *thread_p, const OID *class_oid, int pruning_type, PRUNING_CONTEXT *pinfo)
 
void partition_clear_pruning_context (PRUNING_CONTEXT *pinfo)
 
int partition_prune_spec (THREAD_ENTRY *thread_p, val_descr *vd, access_spec_node *spec)
 
int partition_prune_insert (THREAD_ENTRY *thread_p, const OID *class_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, PRUNING_CONTEXT *pcontext, int pruning_type, OID *pruned_class_oid, HFID *pruned_hfid, OID *superclass_oid)
 
int partition_prune_update (THREAD_ENTRY *thread_p, const OID *class_oid, RECDES *recdes, PRUNING_CONTEXT *pcontext, int pruning_type, OID *pruned_class_oid, HFID *pruned_hfid, OID *superclass_oid)
 
PRUNING_SCAN_CACHEpartition_get_scancache (PRUNING_CONTEXT *pcontext, const OID *partition_oid)
 
PRUNING_SCAN_CACHEpartition_new_scancache (PRUNING_CONTEXT *pcontext)
 
int partition_get_partition_oids (THREAD_ENTRY *thread_p, const OID *class_oid, OID **partition_oids, int *count)
 
int partition_prune_unique_btid (PRUNING_CONTEXT *pcontext, DB_VALUE *key, OID *class_oid, HFID *class_hfid, BTID *btid)
 
int partition_load_aggregate_helper (PRUNING_CONTEXT *pcontext, access_spec_node *spec, int pruned_count, BTID *root_btid, HIERARCHY_AGGREGATE_HELPER *helper)
 
int partition_prune_partition_index (PRUNING_CONTEXT *pcontext, DB_VALUE *key, OID *class_oid, BTID *btid, int *position)
 

Variables

static MHT_TABLEdb_Partition_Ht = NULL
 

Macro Definition Documentation

#define _WORDSIZE   8 * sizeof(int)

Definition at line 60 of file partition.c.

#define BITS_IN_WORD   (8 * BITSET_WORD_SIZE)
#define BITSET_LENGTH (   s)    ((((s)->count - 1) / BITS_IN_WORD)+1)
#define BITSET_WORD_COUNT   (MAX_ELEMENTS / BITS_IN_WORD)

Definition at line 65 of file partition.c.

Referenced by pruningset_init(), and pruningset_set_all().

#define BITSET_WORD_SIZE   sizeof (unsigned int)

Definition at line 63 of file partition.c.

Referenced by pruningset_init(), and pruningset_set_all().

#define MAX_ELEMENTS   1024

Definition at line 62 of file partition.c.

#define NELEMENTS   1024 /* maximum number of partitions */

Definition at line 59 of file partition.c.

#define PARTITION_CACHE_NAME   "Partitions_Cache"

Definition at line 84 of file partition.c.

Referenced by partition_cache_init().

#define PARTITION_CACHE_SIZE   200

Definition at line 85 of file partition.c.

Referenced by partition_cache_init().

Typedef Documentation

typedef enum match_status MATCH_STATUS

Definition at line 92 of file partition.c.

Definition at line 68 of file partition.c.

Definition at line 75 of file partition.c.

typedef enum pruning_op PRUNING_OP

Enumeration Type Documentation

Enumerator
MATCH_OK 
MATCH_NOT_FOUND 

Definition at line 39 of file partition.c.

enum pruning_op
Enumerator
PO_INVALID 
PO_LT 
PO_LE 
PO_GT 
PO_GE 
PO_EQ 
PO_NE 
PO_IN 
PO_NOT_IN 
PO_IS_NULL 

Definition at line 45 of file partition.c.

Function Documentation

void partition_cache_finalize ( THREAD_ENTRY thread_p)
int partition_cache_init ( THREAD_ENTRY thread_p)
void partition_decache_class ( THREAD_ENTRY thread_p,
const OID class_oid 
)

Definition at line 775 of file partition.c.

References csect_enter, csect_exit, CSECT_PARTITION_CACHE, INF_WAIT, mht_rem(), NO_ERROR, NULL, partition_free_cache_entry_kv(), and PARTITION_IS_CACHE_INITIALIZED.

Referenced by log_cleanup_modified_class().

Here is the caller graph for this function:

static bool partition_do_regu_variables_match ( PRUNING_CONTEXT pinfo,
const REGU_VARIABLE left,
const REGU_VARIABLE right 
)
static

Definition at line 968 of file partition.c.

References DB_EQ, val_descr::dbval_ptr, NULL, tp_value_compare(), TYPE_ATTR_ID, TYPE_CONSTANT, TYPE_DBVAL, TYPE_INARITH, TYPE_OUTARITH, TYPE_POS_VALUE, and pruning_context::vd.

Referenced by partition_match_pred_expr().

Here is the caller graph for this function:

static int partition_find_inherited_btid ( THREAD_ENTRY thread_p,
OID src_class,
OID dest_class,
BTID src_btid,
BTID dest_btid 
)
static
int partition_find_root_class_oid ( THREAD_ENTRY thread_p,
const OID class_oid,
OID super_oid 
)

Definition at line 2199 of file partition.c.

References ASSERT_ERROR, COPY_OID, error(), free_and_init, heap_get_class_supers(), NO_ERROR, NULL, and OID_SET_NULL.

Referenced by partition_load_pruning_context(), partition_prune_update(), and qexec_evaluate_aggregates_optimize().

Here is the caller graph for this function:

static int partition_free_cache_entry ( PARTITION_CACHE_ENTRY entry)
static
static int partition_free_cache_entry_kv ( const void *  key,
void *  data,
void *  args 
)
static

Definition at line 389 of file partition.c.

References partition_free_cache_entry().

Referenced by partition_cache_finalize(), and partition_decache_class().

Here is the caller graph for this function:

static void partition_free_partition_predicate ( PRUNING_CONTEXT pinfo)
static
static ATTR_ID partition_get_attribute_id ( REGU_VARIABLE regu_var)
static

Definition at line 2583 of file partition.c.

References assert, regu_variable_list_node::next, NULL, NULL_ATTRID, TYPE_ATTR_ID, TYPE_FUNC, TYPE_INARITH, TYPE_OUTARITH, and regu_variable_list_node::value.

Referenced by partition_load_pruning_context().

Here is the caller graph for this function:

static int partition_get_position_in_key ( PRUNING_CONTEXT pinfo,
BTID btid 
)
static
PRUNING_SCAN_CACHE* partition_get_scancache ( PRUNING_CONTEXT pcontext,
const OID partition_oid 
)
static int partition_get_value_from_inarith ( PRUNING_CONTEXT pinfo,
const REGU_VARIABLE src,
DB_VALUE value_p,
bool is_present 
)
static
static int partition_get_value_from_regu_var ( PRUNING_CONTEXT pinfo,
const REGU_VARIABLE key,
DB_VALUE value_p,
bool is_value 
)
static
static bool partition_is_reguvar_const ( const REGU_VARIABLE regu_var)
static
int partition_load_pruning_context ( THREAD_ENTRY thread_p,
const OID class_oid,
int  pruning_type,
PRUNING_CONTEXT pinfo 
)
static MATCH_STATUS partition_match_index_key ( PRUNING_CONTEXT pinfo,
const KEY_INFO key,
RANGE_TYPE  range_type,
PRUNING_BITSET pruned 
)
static
static MATCH_STATUS partition_prune ( PRUNING_CONTEXT pinfo,
const REGU_VARIABLE arg,
const PRUNING_OP  op,
PRUNING_BITSET pruned 
)
static
static PRUNING_OP partition_rel_op_to_pruning_op ( REL_OP  op)
static
static void partition_set_cache_info_for_expr ( REGU_VARIABLE regu_var,
ATTR_ID  attr_id,
HEAP_CACHE_ATTRINFO info 
)
static
static void partition_set_specified_partition ( PRUNING_CONTEXT pinfo,
const OID partition_oid 
)
static

Definition at line 2504 of file partition.c.

References assert_release, or_partition::class_oid, i, NULL, OID_EQ, pruning_context::partitions, PARTITIONS_COUNT, and pruning_context::selected_partition.

Referenced by partition_load_pruning_context().

Here is the caller graph for this function:

static void pruningset_add ( PRUNING_BITSET s,
int  i 
)
static

Definition at line 221 of file partition.c.

References BITS_IN_WORD, and pruning_bitset::set.

Referenced by partition_prune_hash(), partition_prune_list(), and partition_prune_range().

Here is the caller graph for this function:

static void pruningset_copy ( PRUNING_BITSET dest,
const PRUNING_BITSET src 
)
static

Definition at line 202 of file partition.c.

References BITSET_LENGTH, pruning_bitset::count, i, pruningset_init(), and pruning_bitset::set.

Referenced by partition_match_key_range(), and partition_match_pred_expr().

Here is the caller graph for this function:

static void pruningset_intersect ( PRUNING_BITSET left,
const PRUNING_BITSET right 
)
static

Definition at line 246 of file partition.c.

References BITSET_LENGTH, i, and pruning_bitset::set.

Referenced by partition_match_key_range(), and partition_match_pred_expr().

Here is the caller graph for this function:

static bool pruningset_is_set ( const PRUNING_BITSET s,
int  idx 
)
static

Definition at line 286 of file partition.c.

References BITS_IN_WORD, and pruning_bitset::set.

static void pruningset_iterator_init ( const PRUNING_BITSET set,
PRUNING_BITSET_ITERATOR i 
)
static

Definition at line 328 of file partition.c.

References pruning_bitset_iterator::next, and pruning_bitset_iterator::set.

Referenced by partition_find_partition_for_record(), partition_prune_partition_index(), and pruningset_to_spec_list().

Here is the caller graph for this function:

static int pruningset_iterator_next ( PRUNING_BITSET_ITERATOR it)
static
static int pruningset_popcount ( const PRUNING_BITSET s)
static

Definition at line 298 of file partition.c.

References BITSET_LENGTH, pruning_bitset::count, i, and pruning_bitset::set.

Referenced by partition_find_partition_for_record(), partition_prune_partition_index(), and pruningset_to_spec_list().

Here is the caller graph for this function:

static void pruningset_remove ( PRUNING_BITSET s,
int  i 
)
static

Definition at line 233 of file partition.c.

References BITS_IN_WORD, and pruning_bitset::set.

static void pruningset_set_all ( PRUNING_BITSET set)
static

Definition at line 190 of file partition.c.

References BITSET_WORD_COUNT, BITSET_WORD_SIZE, and pruning_bitset::set.

Referenced by partition_match_index_key(), partition_prune_heap_scan(), and partition_prune_index_scan().

Here is the caller graph for this function:

static void pruningset_union ( PRUNING_BITSET left,
const PRUNING_BITSET right 
)
static

Definition at line 263 of file partition.c.

References BITSET_LENGTH, i, max, and pruning_bitset::set.

Referenced by partition_match_index_key(), and partition_match_pred_expr().

Here is the caller graph for this function:

Variable Documentation

MHT_TABLE* db_Partition_Ht = NULL
static

Definition at line 88 of file partition.c.