851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
19 |
||
20 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
21 |
#pragma once
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
22 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
23 |
#include <drizzled/tree.h> |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
24 |
/*
|
25 |
Unique -- class for unique (removing of duplicates).
|
|
26 |
Puts all values to the TREE. If the tree becomes too big,
|
|
27 |
it's dumped to the file. User can request sorted values, or
|
|
28 |
just iterate through them. In the last case tree merging is performed in
|
|
29 |
memory simultaneously with iteration, so it should be ~2-3x faster.
|
|
30 |
*/
|
|
31 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
32 |
namespace drizzled |
33 |
{
|
|
34 |
||
35 |
namespace internal |
|
36 |
{
|
|
2296.1.1
by Mark Atwood
Merge in Fixes of Brian's IOCACHE. |
37 |
struct st_io_cache; |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
38 |
}
|
1241.9.50
by Monty Taylor
Removed last non-pointer public IO_CACHE from drizzled/ |
39 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
40 |
class Unique : public memory::SqlAlloc |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
41 |
{
|
42 |
size_t max_in_memory_size; |
|
2455.1.1
by Ivo Roper
refactoring of TREE and TREE_ELEMENT structs into Tree and Tree_Element classes |
43 |
Tree tree; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
44 |
unsigned char *record_pointers; |
45 |
uint32_t size; |
|
46 |
||
47 |
public: |
|
48 |
ulong elements; |
|
49 |
Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg, |
|
50 |
uint32_t size_arg, size_t max_in_memory_size_arg); |
|
51 |
~Unique(); |
|
2455.1.5
by Ivo Roper
switched global TREE function calls over to Tree method calls |
52 |
ulong elements_in_tree() { return tree.getElementsInTree(); } |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
53 |
inline bool unique_add(void *ptr) |
54 |
{
|
|
2455.1.5
by Ivo Roper
switched global TREE function calls over to Tree method calls |
55 |
return (not tree.tree_insert(ptr, 0, tree.getCustomArg())); |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
56 |
}
|
57 |
||
58 |
bool get(Table *table); |
|
59 |
static double get_use_cost(uint32_t *buffer, uint32_t nkeys, uint32_t key_size, |
|
60 |
size_t max_in_memory_size); |
|
61 |
inline static int get_cost_calc_buff_size(ulong nkeys, uint32_t key_size, |
|
1891.2.1
by Monty Taylor
Fixed things to make things compile with clang |
62 |
size_t sortbuff_size) |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
63 |
{
|
64 |
register size_t max_elems_in_tree= |
|
2455.1.1
by Ivo Roper
refactoring of TREE and TREE_ELEMENT structs into Tree and Tree_Element classes |
65 |
(1 + sortbuff_size / ALIGN_SIZE(sizeof(Tree_Element)+key_size)); |
895
by Brian Aker
Completion (?) of uint conversion. |
66 |
return (int) (sizeof(uint32_t)*(1 + nkeys/max_elems_in_tree)); |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
67 |
}
|
68 |
||
69 |
void reset(); |
|
70 |
bool walk(tree_walk_action action, void *walk_action_arg); |
|
71 |
||
1241.9.46
by Monty Taylor
Removed some more evil. |
72 |
friend int unique_write_to_file(unsigned char* key, uint32_t count, Unique *unique); |
73 |
friend int unique_write_to_ptrs(unsigned char* key, uint32_t count, Unique *unique); |
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
74 |
};
|
75 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
76 |
} /* namespace drizzled */ |
77 |