MySQL 8.1.0
Source Code Documentation
completion_hash.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef _HASH_
24#define _HASH_
25
26#define SUCCESS 0
27#define FAILURE 1
28
29#include <sys/types.h>
30
31#include "my_alloc.h"
32#include "my_sys.h"
33
34typedef struct _entry {
35 const char *str;
36 struct _entry *pNext;
38
39typedef struct bucket {
40 uint h; /* Used for numeric indexing */
41 const char *arKey;
43 uint count;
45 struct bucket *pNext;
47
48typedef struct hashtable {
52 uint (*pHashFunction)(const char *arKey, uint nKeyLength);
55
56extern int completion_hash_init(HashTable *ht, uint nSize);
57extern int completion_hash_update(HashTable *ht, const char *arKey,
58 uint nKeyLength, const char *str);
59extern int hash_exists(HashTable *ht, char *arKey);
60extern Bucket *find_all_matches(HashTable *ht, const char *str, uint length,
61 uint *res_length);
62extern Bucket *find_longest_match(HashTable *ht, char *str, uint length,
63 uint *res_length);
64extern void add_word(HashTable *ht, const char *str);
66extern int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength);
68
69#endif /* _HASH_ */
int completion_hash_update(HashTable *ht, const char *arKey, uint nKeyLength, const char *str)
Definition: completion_hash.cc:63
int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength)
Definition: completion_hash.cc:131
int completion_hash_init(HashTable *ht, uint nSize)
Definition: completion_hash.cc:47
void completion_hash_free(HashTable *ht)
Definition: completion_hash.cc:199
Bucket * find_longest_match(HashTable *ht, char *str, uint length, uint *res_length)
Definition: completion_hash.cc:164
int hash_exists(HashTable *ht, char *arKey)
struct bucket Bucket
void completion_hash_clean(HashTable *ht)
Definition: completion_hash.cc:194
void add_word(HashTable *ht, const char *str)
Definition: completion_hash.cc:204
struct _entry entry
Bucket * find_all_matches(HashTable *ht, const char *str, uint length, uint *res_length)
Definition: completion_hash.cc:150
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:159
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1063
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:75
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
Definition: completion_hash.h:34
const char * str
Definition: completion_hash.h:35
struct _entry * pNext
Definition: completion_hash.h:36
Definition: completion_hash.h:39
const char * arKey
Definition: completion_hash.h:41
entry * pData
Definition: completion_hash.h:44
uint count
Definition: completion_hash.h:43
uint nKeyLength
Definition: completion_hash.h:42
uint h
Definition: completion_hash.h:40
struct bucket * pNext
Definition: completion_hash.h:45
Definition: completion_hash.h:48
uint nTableSize
Definition: completion_hash.h:49
Bucket ** arBuckets
Definition: completion_hash.h:53
MEM_ROOT mem_root
Definition: completion_hash.h:51
uint(* pHashFunction)(const char *arKey, uint nKeyLength)
Definition: completion_hash.h:52
uint initialized
Definition: completion_hash.h:50