Drizzled Public API Documentation

hp_record.cc
00001 /* Copyright (C) 2000-2002 MySQL AB
00002    Copyright (C) 2008 eBay, Inc
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; version 2 of the License.
00007 
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012 
00013    You should have received a copy of the GNU General Public License
00014    along with this program; if not, write to the Free Software
00015    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00016 
00017 /* Implements various base record-related functions, such as encode and decode into chunks */
00018 
00019 #include "heap_priv.h"
00020 
00021 #include <drizzled/common.h>
00022 
00023 #include <string.h>
00024 #include <algorithm>
00025 
00026 using namespace std;
00027 using namespace drizzled;
00028 
00042 uint32_t hp_get_encoded_data_length(HP_SHARE *info, const unsigned char *, uint32_t *chunk_count)
00043 {
00044   uint32_t dst_offset= info->fixed_data_length;
00045 
00046   /* Nothing more to copy */
00047   *chunk_count= 1;
00048   return dst_offset;
00049 }
00050 
00051 bool hp_compare_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos)
00052 {
00053   unsigned char* curr_chunk= pos;
00054 
00055   if (memcmp(curr_chunk, record, (size_t) info->fixed_data_length))
00056   {
00057     return 1;
00058   }
00059 
00060   return 0;
00061 }
00062 
00073 void hp_copy_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos)
00074 {
00075   unsigned char* curr_chunk= pos;
00076 
00077   memcpy(curr_chunk, record, (size_t) info->fixed_data_length);
00078 }
00079 
00090 void hp_extract_record(HP_SHARE *info, unsigned char *record, const unsigned char *pos)
00091 {
00092   const unsigned char* curr_chunk= pos;
00093 
00094   memcpy(record, curr_chunk, (size_t) info->fixed_data_length);
00095 }