MySQL 8.4.0
Source Code Documentation
completion_hash.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef _HASH_
25#define _HASH_
26
27#define SUCCESS 0
28#define FAILURE 1
29
30#include <sys/types.h>
31
32#include "my_alloc.h"
33#include "my_sys.h"
34
35typedef struct _entry {
36 const char *str;
37 struct _entry *pNext;
39
40typedef struct bucket {
41 uint h; /* Used for numeric indexing */
42 const char *arKey;
44 uint count;
46 struct bucket *pNext;
48
49typedef struct hashtable {
53 uint (*pHashFunction)(const char *arKey, uint nKeyLength);
56
57extern int completion_hash_init(HashTable *ht, uint nSize);
58extern int completion_hash_update(HashTable *ht, const char *arKey,
59 uint nKeyLength, const char *str);
60extern int hash_exists(HashTable *ht, char *arKey);
61extern Bucket *find_all_matches(HashTable *ht, const char *str, uint length,
62 uint *res_length);
63extern Bucket *find_longest_match(HashTable *ht, char *str, uint length,
64 uint *res_length);
65extern void add_word(HashTable *ht, const char *str);
67extern int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength);
69
70#endif /* _HASH_ */
int completion_hash_update(HashTable *ht, const char *arKey, uint nKeyLength, const char *str)
Definition: completion_hash.cc:64
int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength)
Definition: completion_hash.cc:132
int completion_hash_init(HashTable *ht, uint nSize)
Definition: completion_hash.cc:48
void completion_hash_free(HashTable *ht)
Definition: completion_hash.cc:200
Bucket * find_longest_match(HashTable *ht, char *str, uint length, uint *res_length)
Definition: completion_hash.cc:165
int hash_exists(HashTable *ht, char *arKey)
struct bucket Bucket
void completion_hash_clean(HashTable *ht)
Definition: completion_hash.cc:195
void add_word(HashTable *ht, const char *str)
Definition: completion_hash.cc:205
struct _entry entry
Bucket * find_all_matches(HashTable *ht, const char *str, uint length, uint *res_length)
Definition: completion_hash.cc:151
struct hashtable HashTable
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Common header for many mysys elements.
static HashTable ht
Definition: mysql.cc:161
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1073
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: completion_hash.h:35
const char * str
Definition: completion_hash.h:36
struct _entry * pNext
Definition: completion_hash.h:37
Definition: completion_hash.h:40
const char * arKey
Definition: completion_hash.h:42
entry * pData
Definition: completion_hash.h:45
uint count
Definition: completion_hash.h:44
uint nKeyLength
Definition: completion_hash.h:43
uint h
Definition: completion_hash.h:41
struct bucket * pNext
Definition: completion_hash.h:46
Definition: completion_hash.h:49
uint nTableSize
Definition: completion_hash.h:50
Bucket ** arBuckets
Definition: completion_hash.h:54
MEM_ROOT mem_root
Definition: completion_hash.h:52
uint(* pHashFunction)(const char *arKey, uint nKeyLength)
Definition: completion_hash.h:53
uint initialized
Definition: completion_hash.h:51