Drizzled Public API Documentation

hp_record.cc
1 /* Copyright (C) 2000-2002 MySQL AB
2  Copyright (C) 2008 eBay, Inc
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16 
17 /* Implements various base record-related functions, such as encode and decode into chunks */
18 
19 #include "heap_priv.h"
20 
21 #include <drizzled/common.h>
22 
23 #include <string.h>
24 #include <algorithm>
25 
26 using namespace std;
27 using namespace drizzled;
28 
42 uint32_t hp_get_encoded_data_length(HP_SHARE *info, const unsigned char *, uint32_t *chunk_count)
43 {
44  uint32_t dst_offset= info->fixed_data_length;
45 
46  /* Nothing more to copy */
47  *chunk_count= 1;
48  return dst_offset;
49 }
50 
51 bool hp_compare_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos)
52 {
53  unsigned char* curr_chunk= pos;
54 
55  if (memcmp(curr_chunk, record, (size_t) info->fixed_data_length))
56  {
57  return 1;
58  }
59 
60  return 0;
61 }
62 
73 void hp_copy_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos)
74 {
75  unsigned char* curr_chunk= pos;
76 
77  memcpy(curr_chunk, record, (size_t) info->fixed_data_length);
78 }
79 
90 void hp_extract_record(HP_SHARE *info, unsigned char *record, const unsigned char *pos)
91 {
92  const unsigned char* curr_chunk= pos;
93 
94  memcpy(record, curr_chunk, (size_t) info->fixed_data_length);
95 }