CUBRID Engine  latest
query_hash_scan.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 //
20 // query_hash_scan - interface for hash list scan during queries
21 //
22 
23 #ifndef _QUERY_HASH_SCAN_H_
24 #define _QUERY_HASH_SCAN_H_
25 
26 #if !defined (SERVER_MODE) && !defined (SA_MODE)
27 #error Wrong module
28 #endif // not server and not SA mode
29 
30 #include "regu_var.hpp"
31 
32 #define MAKE_TUPLE_POSTION(tuple_pos, simple_pos, scan_id_p) \
33  do \
34  { \
35  tuple_pos.status = scan_id_p->status; \
36  tuple_pos.position = S_ON; \
37  tuple_pos.vpid = simple_pos->vpid; \
38  tuple_pos.offset = simple_pos->offset; \
39  tuple_pos.tpl = NULL; \
40  tuple_pos.tplno = 0; /* If tplno is needed, add it from scan_build_hash_list_scan() */ \
41  } \
42  while (0)
43 
44 /* kind of hash list scan method */
46 {
50  HASH_METH_HASH_FILE = 3 /* not used */
51 };
52 typedef enum hash_method HASH_METHOD;
53 
54 /* Tuple position structure for hash value */
57 {
58  VPID vpid; /* Real tuple page identifier */
59  int offset; /* Tuple offset inside the page */
60 };
61 
62 /* hash scan value */
65 {
66  void *data; /* for free() */
67  QFILE_TUPLE_SIMPLE_POS *pos; /* tuple position of temp file */
68  QFILE_TUPLE tuple; /* tuple data */
69 };
70 
71 /* hash scan key */
74 {
75  int val_count; /* key size */
76  bool free_values; /* true if values need to be freed */
77  db_value **values; /* value array */
78 };
79 
80 /* hash list scan */
83 {
84  regu_variable_list_node *build_regu_list; /* regulator variable list */
85  regu_variable_list_node *probe_regu_list; /* regulator variable list */
86  mht_hls_table *hash_table; /* memory hash table for hash list scan */
87  hash_scan_key *temp_key; /* temp probe key */
88  hash_scan_key *temp_new_key; /* temp probe key with db_value */
89  HENTRY_HLS_PTR curr_hash_entry; /* current hash entry */
90  int hash_list_scan_yn; /* Is hash list scan possible? */
91  bool need_coerce_type; /* Are the types of probe and build different? */
92 };
93 
94 HASH_SCAN_KEY *qdata_alloc_hscan_key (THREAD_ENTRY * thread_p, int val_cnt, bool alloc_vals);
97 
98 void qdata_free_hscan_key (THREAD_ENTRY * thread_p, HASH_SCAN_KEY * key, int val_count);
99 void qdata_free_hscan_value (THREAD_ENTRY * thread_p, HASH_SCAN_VALUE * value);
100 int qdata_free_hscan_entry (const void *key, void *data, void *args);
101 
102 int qdata_hscan_key_eq (const void *key1, const void *key2);
103 
104 int qdata_build_hscan_key (THREAD_ENTRY * thread_p, val_descr * vd, REGU_VARIABLE_LIST regu_list, HASH_SCAN_KEY * key);
105 unsigned int qdata_hash_scan_key (const void *key, unsigned int ht_size);
107  REGU_VARIABLE_LIST probe_regu_list, val_descr * vd);
109  REGU_VARIABLE_LIST probe_regu_list, HASH_SCAN_KEY * new_key);
110 
111 int qdata_print_hash_scan_entry (THREAD_ENTRY * thread_p, FILE * fp, const void *data, void *args);
112 
113 #endif /* _QUERY_HASH_SCAN_H_ */
db_value ** values
hash_method
HASH_SCAN_KEY * qdata_copy_hscan_key(THREAD_ENTRY *thread_p, HASH_SCAN_KEY *key, REGU_VARIABLE_LIST probe_regu_list, val_descr *vd)
QFILE_TUPLE_SIMPLE_POS * pos
HASH_SCAN_VALUE * qdata_alloc_hscan_value_OID(THREAD_ENTRY *thread_p, QFILE_LIST_SCAN_ID *scan_id_p)
unsigned int qdata_hash_scan_key(const void *key, unsigned int ht_size)
void THREAD_ENTRY
HASH_SCAN_KEY * qdata_copy_hscan_key_without_alloc(THREAD_ENTRY *thread_p, HASH_SCAN_KEY *key, REGU_VARIABLE_LIST probe_regu_list, HASH_SCAN_KEY *new_key)
mht_hls_table * hash_table
int qdata_print_hash_scan_entry(THREAD_ENTRY *thread_p, FILE *fp, const void *data, void *args)
enum hash_method HASH_METHOD
int qdata_hscan_key_eq(const void *key1, const void *key2)
HENTRY_HLS_PTR curr_hash_entry
hash_scan_key * temp_new_key
hash_scan_key * temp_key
HASH_SCAN_KEY * qdata_alloc_hscan_key(THREAD_ENTRY *thread_p, int val_cnt, bool alloc_vals)
void qdata_free_hscan_key(THREAD_ENTRY *thread_p, HASH_SCAN_KEY *key, int val_count)
void qdata_free_hscan_value(THREAD_ENTRY *thread_p, HASH_SCAN_VALUE *value)
char * QFILE_TUPLE
Definition: query_list.h:281
regu_variable_list_node * probe_regu_list
regu_variable_list_node * build_regu_list
int qdata_free_hscan_entry(const void *key, void *data, void *args)
int qdata_build_hscan_key(THREAD_ENTRY *thread_p, val_descr *vd, REGU_VARIABLE_LIST regu_list, HASH_SCAN_KEY *key)
QFILE_TUPLE tuple
HASH_SCAN_VALUE * qdata_alloc_hscan_value(THREAD_ENTRY *thread_p, QFILE_TUPLE tpl)