transactd 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/BUILD_UNIX-JA +174 -0
- data/BUILD_WIN-JA +256 -0
- data/CMakeLists.txt +96 -0
- data/COPYING +339 -0
- data/README +406 -0
- data/README-JA +424 -0
- data/bin/common/tdclc_32_1_0.dll +0 -0
- data/bin/common/tdclc_64_1_0.dll +0 -0
- data/build/common/check_for_link_iconv.cmake +73 -0
- data/build/common/copyifgreater.cmd +30 -0
- data/build/common/copyifgreater.js +290 -0
- data/build/common/get_boost_libs.cmake +106 -0
- data/build/common/get_ruby_path.cmake +115 -0
- data/build/common/options.cmake +127 -0
- data/build/common/smart_install.cmake +263 -0
- data/build/common/system.cmake +122 -0
- data/build/common/transactd.rc.in +52 -0
- data/build/common/transactd_cl_common.cmake +101 -0
- data/build/common/transactd_cl_output.cmake +93 -0
- data/build/common/transactd_common.cmake +237 -0
- data/build/common/transactd_required.cmake +28 -0
- data/build/swig/ruby/generate.cmake.in +35 -0
- data/build/swig/ruby/generate.cmd.in +19 -0
- data/build/swig/ruby/ruby.swg +101 -0
- data/build/swig/tdcl.i +188 -0
- data/build/tdclc/BUILDNUMBER.txt +1 -0
- data/build/tdclc/CMakeLists.txt +170 -0
- data/build/tdclc/tdclc_32.cbproj +181 -0
- data/build/tdclc/tdclc_64.cbproj +205 -0
- data/build/tdclcpp/BUILDNUMBER.txt +1 -0
- data/build/tdclcpp/CMakeLists.txt +142 -0
- data/build/tdclcpp/tdclcpp_bcb_32.cbproj +239 -0
- data/build/tdclcpp/tdclcpp_bcb_64.cbproj +304 -0
- data/build/tdclrb/BUILDNUMBER.txt +1 -0
- data/build/tdclrb/CMakeLists.txt +258 -0
- data/build/tdclrb/GEM_VERSION +3 -0
- data/build/tdclrb/bldgem/extconf.rb +123 -0
- data/build/tdclrb/gem/INSTALLLOG.win32 +9 -0
- data/build/tdclrb/gem/Makefile.win32-VS +65 -0
- data/build/tdclrb/gem/Makefile.win32-prebuilt +48 -0
- data/build/tdclrb/gem/detect.rb +31 -0
- data/build/tdclrb/gem/helper.rb +113 -0
- data/build/tdclrb/gem/transactd.rb +22 -0
- data/build/tdclrb/gem_output.cmake +44 -0
- data/source/bzs/db/IBlobBuffer.h +51 -0
- data/source/bzs/db/blobBuffer.h +177 -0
- data/source/bzs/db/blobStructs.h +85 -0
- data/source/bzs/db/engine/mysql/IReadRecords.h +52 -0
- data/source/bzs/db/engine/mysql/bookmark.h +195 -0
- data/source/bzs/db/engine/mysql/database.cpp +1882 -0
- data/source/bzs/db/engine/mysql/database.h +465 -0
- data/source/bzs/db/engine/mysql/dbManager.cpp +303 -0
- data/source/bzs/db/engine/mysql/dbManager.h +143 -0
- data/source/bzs/db/engine/mysql/errorMessage.cpp +75 -0
- data/source/bzs/db/engine/mysql/errorMessage.h +43 -0
- data/source/bzs/db/engine/mysql/fieldAccess.h +158 -0
- data/source/bzs/db/engine/mysql/mydebuglog.cpp +349 -0
- data/source/bzs/db/engine/mysql/mydebuglog.h +89 -0
- data/source/bzs/db/engine/mysql/mysqlInternal.h +171 -0
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +169 -0
- data/source/bzs/db/engine/mysql/mysqlThd.h +35 -0
- data/source/bzs/db/engine/mysql/percentageKey.h +260 -0
- data/source/bzs/db/protocol/ICommandExecuter.h +49 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +689 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.h +228 -0
- data/source/bzs/db/protocol/tdap/btrDate.cpp +437 -0
- data/source/bzs/db/protocol/tdap/btrDate.h +227 -0
- data/source/bzs/db/protocol/tdap/client/bulkInsert.h +127 -0
- data/source/bzs/db/protocol/tdap/client/client.cpp +106 -0
- data/source/bzs/db/protocol/tdap/client/client.h +292 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.cpp +144 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.h +82 -0
- data/source/bzs/db/protocol/tdap/client/database.cpp +863 -0
- data/source/bzs/db/protocol/tdap/client/database.h +118 -0
- data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +100 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +1640 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.h +135 -0
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +434 -0
- data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +92 -0
- data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +98 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +174 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.h +91 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +140 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.h +86 -0
- data/source/bzs/db/protocol/tdap/client/filter.cpp +527 -0
- data/source/bzs/db/protocol/tdap/client/filter.h +154 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +137 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.h +84 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +724 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +123 -0
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +899 -0
- data/source/bzs/db/protocol/tdap/client/nsTable.h +199 -0
- data/source/bzs/db/protocol/tdap/client/request.h +198 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.cpp +58 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.h +56 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +574 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +53 -0
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +627 -0
- data/source/bzs/db/protocol/tdap/client/table.cpp +2613 -0
- data/source/bzs/db/protocol/tdap/client/table.h +221 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +1096 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +179 -0
- data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +40 -0
- data/source/bzs/db/protocol/tdap/client/trnsctcl.def +11 -0
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +500 -0
- data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +184 -0
- data/source/bzs/db/protocol/tdap/mysql/characterset.h +60 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +284 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +53 -0
- data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +383 -0
- data/source/bzs/db/protocol/tdap/mysql/debuglog.h +106 -0
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +680 -0
- data/source/bzs/db/protocol/tdap/mysql/request.h +202 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1020 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +141 -0
- data/source/bzs/db/protocol/tdap/tdapRequest.h +190 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +295 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.h +558 -0
- data/source/bzs/db/protocol/tdap/tdapcapi.h +423 -0
- data/source/bzs/db/transactd/appBuilderImple.h +55 -0
- data/source/bzs/db/transactd/appModule.cpp +183 -0
- data/source/bzs/db/transactd/appModule.h +80 -0
- data/source/bzs/db/transactd/connManager.cpp +201 -0
- data/source/bzs/db/transactd/connManager.h +60 -0
- data/source/bzs/db/transactd/connectionRecord.h +69 -0
- data/source/bzs/db/transactd/transactd.cpp +325 -0
- data/source/bzs/env/compiler.h +135 -0
- data/source/bzs/env/crosscompile.cpp +130 -0
- data/source/bzs/env/crosscompile.h +150 -0
- data/source/bzs/env/fileopen.h +36 -0
- data/source/bzs/env/mbcswchrLinux.cpp +40 -0
- data/source/bzs/env/mbcswchrLinux.h +88 -0
- data/source/bzs/env/tstring.h +183 -0
- data/source/bzs/example/changeSchema.cpp +117 -0
- data/source/bzs/example/changeSchema_c.cpp +78 -0
- data/source/bzs/example/connection_pool_c.cpp +171 -0
- data/source/bzs/example/createDatabase.cpp +305 -0
- data/source/bzs/example/createDatabase_c.cpp +202 -0
- data/source/bzs/example/deleteRecords.cpp +87 -0
- data/source/bzs/example/deleteRecords_c.cpp +57 -0
- data/source/bzs/example/dropDatabase.cpp +59 -0
- data/source/bzs/example/dropDatabase_c.cpp +34 -0
- data/source/bzs/example/insertRecords.cpp +212 -0
- data/source/bzs/example/insertRecords_c.cpp +153 -0
- data/source/bzs/example/readRecords.cpp +141 -0
- data/source/bzs/example/readRecords_c.cpp +107 -0
- data/source/bzs/example/updateRecords.cpp +99 -0
- data/source/bzs/example/updateRecords_c.cpp +71 -0
- data/source/bzs/example/update_with_transaction.cpp +104 -0
- data/source/bzs/example/update_with_transaction_c.cpp +80 -0
- data/source/bzs/netsvc/client/tcpClient.cpp +226 -0
- data/source/bzs/netsvc/client/tcpClient.h +489 -0
- data/source/bzs/netsvc/server/IAppModule.h +94 -0
- data/source/bzs/netsvc/server/iserver.h +65 -0
- data/source/bzs/netsvc/server/serverCpt.cpp +522 -0
- data/source/bzs/netsvc/server/serverCpt.h +88 -0
- data/source/bzs/netsvc/server/serverPipe.cpp +705 -0
- data/source/bzs/netsvc/server/serverPipe.h +96 -0
- data/source/bzs/netsvc/server/serverTpool.cpp +416 -0
- data/source/bzs/netsvc/server/serverTpool.h +84 -0
- data/source/bzs/rtl/benchmark.cpp +96 -0
- data/source/bzs/rtl/benchmark.h +65 -0
- data/source/bzs/rtl/datetime.cpp +375 -0
- data/source/bzs/rtl/datetime.h +53 -0
- data/source/bzs/rtl/debuglog.cpp +106 -0
- data/source/bzs/rtl/debuglog.h +97 -0
- data/source/bzs/rtl/exception.h +116 -0
- data/source/bzs/rtl/stl_uty.cpp +35 -0
- data/source/bzs/rtl/stl_uty.h +29 -0
- data/source/bzs/rtl/stringBuffers.cpp +101 -0
- data/source/bzs/rtl/stringBuffers.h +58 -0
- data/source/bzs/rtl/strtrim.cpp +135 -0
- data/source/bzs/rtl/strtrim.h +46 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +445 -0
- data/source/bzs/test/tdclrb/bench_tdclcpp.rb +375 -0
- data/source/bzs/test/tdclrb/prepare.rb +226 -0
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +172 -0
- data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +208 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +1536 -0
- data/source/bzs/test/transactdBench/transactdBench.cpp +430 -0
- data/source/bzs/test/transactdBench/transactdBench2.cpp +342 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +2030 -0
- data/source/global/tdclatl/Database.cpp +503 -0
- data/source/global/tdclatl/Database.h +139 -0
- data/source/global/tdclatl/DbDef.cpp +242 -0
- data/source/global/tdclatl/DbDef.h +79 -0
- data/source/global/tdclatl/Field.cpp +92 -0
- data/source/global/tdclatl/Field.h +59 -0
- data/source/global/tdclatl/FieldDef.cpp +238 -0
- data/source/global/tdclatl/FieldDef.h +87 -0
- data/source/global/tdclatl/Flags.cpp +111 -0
- data/source/global/tdclatl/Flags.h +55 -0
- data/source/global/tdclatl/KeyDef.cpp +51 -0
- data/source/global/tdclatl/KeyDef.h +55 -0
- data/source/global/tdclatl/KeySegment.cpp +55 -0
- data/source/global/tdclatl/Table.cpp +600 -0
- data/source/global/tdclatl/Table.h +144 -0
- data/source/global/tdclatl/TableDef.cpp +291 -0
- data/source/global/tdclatl/TableDef.h +86 -0
- data/source/global/tdclatl/TdVersion.cpp +74 -0
- data/source/global/tdclatl/TdVersion.h +54 -0
- data/source/global/tdclatl/_IDatabaseEvents_CP.h +113 -0
- data/source/global/tdclatl/dllmain.cpp +30 -0
- data/source/global/tdclatl/dllmain.h +27 -0
- data/source/global/tdclatl/keySegment.h +57 -0
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/stdafx.cpp +2 -0
- data/source/global/tdclatl/stdafx.h +25 -0
- data/source/global/tdclatl/targetver.h +4 -0
- data/source/global/tdclatl/tdclatl.cpp +68 -0
- data/source/global/tdclatl/tdclatl.def +10 -0
- data/source/global/tdclatl/tdclatl.idl +1035 -0
- data/source/linux/charsetConvert.h +112 -0
- data/source/linux/linuxTypes.h +33 -0
- data/source/linux/tchar.h +428 -0
- data/transactd.gemspec +97 -0
- metadata +267 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
#ifndef BZS_DB_BLOBSTRUCTS_H
|
2
|
+
#define BZS_DB_BLOBSTRUCTS_H
|
3
|
+
/*=================================================================
|
4
|
+
Copyright (C) 2013 BizStation Corp All rights reserved.
|
5
|
+
|
6
|
+
This program is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU General Public License
|
8
|
+
as published by the Free Software Foundation; either version 2
|
9
|
+
of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
19
|
+
02111-1307, USA.
|
20
|
+
=================================================================*/
|
21
|
+
#include <bzs/env/compiler.h>
|
22
|
+
|
23
|
+
namespace bzs
|
24
|
+
{
|
25
|
+
namespace db
|
26
|
+
{
|
27
|
+
|
28
|
+
#pragma option -a-
|
29
|
+
pragma_pack1
|
30
|
+
|
31
|
+
/** bolob buffer field
|
32
|
+
* size byte is allways 4byte.
|
33
|
+
* 2byte null
|
34
|
+
*/
|
35
|
+
struct blobField
|
36
|
+
{
|
37
|
+
unsigned int size;
|
38
|
+
unsigned short fieldNum;
|
39
|
+
inline const char* data()const{return (const char*)(this+1);}
|
40
|
+
inline const blobField* next()const{return (const blobField*)(data()+size+2);};
|
41
|
+
};
|
42
|
+
|
43
|
+
struct blob
|
44
|
+
{
|
45
|
+
inline blob(unsigned int size, unsigned short fnum, const unsigned char* dataptr)
|
46
|
+
:ptr(dataptr)
|
47
|
+
{
|
48
|
+
bf.fieldNum = fnum;
|
49
|
+
bf.size = size;
|
50
|
+
};
|
51
|
+
blobField bf;
|
52
|
+
const unsigned char* ptr;
|
53
|
+
};
|
54
|
+
|
55
|
+
/** blob buffer header
|
56
|
+
*
|
57
|
+
*/
|
58
|
+
struct blobHeader
|
59
|
+
{
|
60
|
+
unsigned short rows;
|
61
|
+
unsigned short fieldCount;
|
62
|
+
mutable unsigned short curRow;
|
63
|
+
mutable blobField* nextField;
|
64
|
+
#ifndef __x86_64__
|
65
|
+
blobField* dymmySpace32; //8byte size space for 32bit
|
66
|
+
#endif
|
67
|
+
|
68
|
+
inline void resetCur() const
|
69
|
+
{
|
70
|
+
curRow = 0;
|
71
|
+
nextField = (blobField*)(this+1);
|
72
|
+
}
|
73
|
+
};
|
74
|
+
|
75
|
+
#pragma option -a
|
76
|
+
pragma_pop
|
77
|
+
|
78
|
+
}//namespace db
|
79
|
+
}//namespace bzs
|
80
|
+
|
81
|
+
#endif //BZS_DB_BLOBSTRUCTS_H
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#ifndef IREADRECORDS_H
|
2
|
+
#define IREADRECORDS_H
|
3
|
+
/*=================================================================
|
4
|
+
Copyright (C) 2012 2013 BizStation Corp All rights reserved.
|
5
|
+
|
6
|
+
This program is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU General Public License
|
8
|
+
as published by the Free Software Foundation; either version 2
|
9
|
+
of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
19
|
+
02111-1307, USA.
|
20
|
+
=================================================================*/
|
21
|
+
|
22
|
+
|
23
|
+
namespace bzs
|
24
|
+
{
|
25
|
+
namespace db
|
26
|
+
{
|
27
|
+
namespace engine
|
28
|
+
{
|
29
|
+
namespace mysql
|
30
|
+
{
|
31
|
+
|
32
|
+
#define REC_MACTH 0
|
33
|
+
#define REC_NOMACTH 1
|
34
|
+
#define REC_NOMACTH_NOMORE 2
|
35
|
+
|
36
|
+
class IReadRecordsHandler
|
37
|
+
{
|
38
|
+
|
39
|
+
public:
|
40
|
+
virtual ~IReadRecordsHandler(){};
|
41
|
+
virtual int match(bool typeNext) const=0;
|
42
|
+
virtual short write(const unsigned char* bookmark, unsigned int bmlen)=0;
|
43
|
+
virtual unsigned short rejectCount() = 0;
|
44
|
+
virtual unsigned short maxRows() = 0;
|
45
|
+
};
|
46
|
+
|
47
|
+
}//namespace mysql
|
48
|
+
}//namespace engine
|
49
|
+
}//namespace db
|
50
|
+
}//namespace bzs
|
51
|
+
|
52
|
+
#endif //IREADRECORDS_H
|
@@ -0,0 +1,195 @@
|
|
1
|
+
#ifndef BOOKMARK_H
|
2
|
+
#define BOOKMARK_H
|
3
|
+
/*=================================================================
|
4
|
+
Copyright (C) 2012 2013 BizStation Corp All rights reserved.
|
5
|
+
|
6
|
+
This program is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU General Public License
|
8
|
+
as published by the Free Software Foundation; either version 2
|
9
|
+
of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
19
|
+
02111-1307, USA.
|
20
|
+
=================================================================*/
|
21
|
+
|
22
|
+
#include <vector>
|
23
|
+
#include <bzs/rtl/exception.h>
|
24
|
+
#include "mysqlInternal.h"
|
25
|
+
|
26
|
+
#ifdef BOOKMARK_USE_MULTIMAP
|
27
|
+
#include <boost/multi_index_container.hpp>
|
28
|
+
#include <boost/multi_index/member.hpp>
|
29
|
+
#include <boost/multi_index/ordered_index.hpp>
|
30
|
+
using namespace boost::multi_index;
|
31
|
+
|
32
|
+
#endif
|
33
|
+
|
34
|
+
namespace bzs
|
35
|
+
{
|
36
|
+
namespace db
|
37
|
+
{
|
38
|
+
namespace engine
|
39
|
+
{
|
40
|
+
namespace mysql
|
41
|
+
{
|
42
|
+
|
43
|
+
#ifdef BOOKMARK_USE_MULTIMAP
|
44
|
+
/** The version which can reverse-refer to bookmark from raw ref using multi map
|
45
|
+
* In order that this system may use a lot of memories
|
46
|
+
, there is a problem in which the fall of performance occurs.
|
47
|
+
*/
|
48
|
+
|
49
|
+
typedef std::vector<unsigned char> charArray;
|
50
|
+
struct bookmark
|
51
|
+
{
|
52
|
+
unsigned int id;
|
53
|
+
charArray ref;
|
54
|
+
bookmark(unsigned int id, const charArray& ref):id(id), ref(ref){}
|
55
|
+
|
56
|
+
};
|
57
|
+
|
58
|
+
struct id {};
|
59
|
+
struct ref {};
|
60
|
+
|
61
|
+
typedef multi_index_container< bookmark,
|
62
|
+
indexed_by<ordered_unique<tag<id>, member<bookmark, unsigned int, &bookmark::id> >
|
63
|
+
,ordered_unique<tag<ref>, member<bookmark, charArray, &bookmark::ref> > > > bookmarkContainer;
|
64
|
+
|
65
|
+
typedef bookmarkContainer::index<id>::type id_map;
|
66
|
+
typedef bookmarkContainer::index<ref>::type ref_map;
|
67
|
+
|
68
|
+
class bookmarks
|
69
|
+
{
|
70
|
+
int m_refLen;
|
71
|
+
int m_lastbm;
|
72
|
+
bookmarkContainer m_bms;
|
73
|
+
charArray m_tmpRef;
|
74
|
+
|
75
|
+
public:
|
76
|
+
bookmarks(int refLen):m_refLen(refLen),m_tmpRef(refLen),m_lastbm(0)
|
77
|
+
{
|
78
|
+
}
|
79
|
+
|
80
|
+
/** get integer bookmark pointer by raw ref pointer
|
81
|
+
*/
|
82
|
+
const unsigned char* getBookmarkPtr(unsigned char* rawRefPtr)
|
83
|
+
{
|
84
|
+
m_tmpRef.clear();
|
85
|
+
m_tmpRef.insert(m_tmpRef.end(), rawRefPtr, rawRefPtr+m_refLen);
|
86
|
+
ref_map& m = m_bms.get<ref>();
|
87
|
+
ref_map::iterator it = m.find(m_tmpRef);
|
88
|
+
if (it == m.end())
|
89
|
+
{
|
90
|
+
m_bms.insert(m_bms.end(), bookmark(++m_lastbm, m_tmpRef));
|
91
|
+
it = m.find(m_tmpRef);
|
92
|
+
}
|
93
|
+
return (const unsigned char*)&it->id;
|
94
|
+
}
|
95
|
+
|
96
|
+
unsigned int getBookmark(unsigned char* rawRefPtr)
|
97
|
+
{
|
98
|
+
return *((unsigned int*)getBookmarkPtr(rawRefPtr));
|
99
|
+
}
|
100
|
+
/** get raw ref pointer by integer bookmark
|
101
|
+
*/
|
102
|
+
const unsigned char* getRefByBm(unsigned int bm)
|
103
|
+
{
|
104
|
+
id_map& m = m_bms.get<id>();
|
105
|
+
id_map::iterator it = m.find(bm);
|
106
|
+
if (it != m.end())
|
107
|
+
return &(it->ref[0]);
|
108
|
+
THROW_BZS_ERROR_WITH_CODEMSG(STATUS_INVALID_BOOKMARK ,"invalid bookmark.");
|
109
|
+
}
|
110
|
+
|
111
|
+
};
|
112
|
+
#else //BOOKMARK_USE_MULTIMAP
|
113
|
+
|
114
|
+
/** The version which returns raw ref to bookmark in simple arrangement
|
115
|
+
* The maximum memory size is specified in MAX_BOOKMARK_MEM_SIZE.
|
116
|
+
* When the memory exceeding it is required, it is considered as an error.
|
117
|
+
*/
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
#define MAX_BOOKMARK_MEM_SIZE 500*1024*1024 //500MB
|
122
|
+
#define UNIT_OF_ALLOCCOUNT 10000
|
123
|
+
|
124
|
+
class bookmarks
|
125
|
+
{
|
126
|
+
size_t m_refLen;
|
127
|
+
size_t m_allocatedCount;
|
128
|
+
size_t m_usedCount;
|
129
|
+
unsigned char* m_ptr;
|
130
|
+
unsigned int m_bookmark;
|
131
|
+
|
132
|
+
void allocBuffer(size_t count)
|
133
|
+
{
|
134
|
+
if (MAX_BOOKMARK_MEM_SIZE < count*m_refLen)
|
135
|
+
THROW_BZS_ERROR_WITH_CODEMSG(STATUS_INVALID_BOOKMARK ,"invalid bookmark.");
|
136
|
+
void* tmp;
|
137
|
+
if (m_ptr == NULL)
|
138
|
+
tmp = (unsigned char*)my_malloc(count*m_refLen, 0);
|
139
|
+
else
|
140
|
+
tmp = my_realloc(m_ptr, count*m_refLen, 0);
|
141
|
+
if (tmp)
|
142
|
+
m_ptr = (unsigned char*)tmp;
|
143
|
+
else
|
144
|
+
THROW_BZS_ERROR_WITH_CODEMSG(STATUS_INVALID_BOOKMARK ,"invalid bookmark.");
|
145
|
+
m_allocatedCount = count;
|
146
|
+
}
|
147
|
+
|
148
|
+
public:
|
149
|
+
bookmarks(size_t refLen):m_refLen(refLen),m_usedCount(0),m_ptr(NULL)
|
150
|
+
{
|
151
|
+
allocBuffer(UNIT_OF_ALLOCCOUNT);
|
152
|
+
}
|
153
|
+
|
154
|
+
~bookmarks()
|
155
|
+
{
|
156
|
+
my_free(m_ptr);
|
157
|
+
}
|
158
|
+
|
159
|
+
/** get integer bookmark pointer by raw ref pointer
|
160
|
+
*/
|
161
|
+
const unsigned char* getBookmarkPtr(unsigned char* rawRefPtr)
|
162
|
+
{
|
163
|
+
if (m_usedCount == m_allocatedCount)
|
164
|
+
allocBuffer(m_usedCount+UNIT_OF_ALLOCCOUNT);
|
165
|
+
|
166
|
+
memcpy(m_ptr+m_usedCount*m_refLen, rawRefPtr, m_refLen);
|
167
|
+
m_bookmark = (unsigned int)(++m_usedCount);
|
168
|
+
return (const unsigned char*)&m_bookmark;
|
169
|
+
}
|
170
|
+
|
171
|
+
unsigned int getBookmark(unsigned char* rawRefPtr)
|
172
|
+
{
|
173
|
+
return *((unsigned int*)getBookmarkPtr(rawRefPtr));
|
174
|
+
}
|
175
|
+
|
176
|
+
/** get raw ref pointer by integer bookmark
|
177
|
+
*/
|
178
|
+
const unsigned char* getRefByBm(unsigned int bm)
|
179
|
+
{
|
180
|
+
if ((0==bm) || bm > m_usedCount)
|
181
|
+
THROW_BZS_ERROR_WITH_CODEMSG(STATUS_INVALID_BOOKMARK ,"invalid bookmark.");
|
182
|
+
return m_ptr+(bm-1)*m_refLen;
|
183
|
+
}
|
184
|
+
|
185
|
+
};
|
186
|
+
|
187
|
+
#endif
|
188
|
+
|
189
|
+
}//namespace mysql
|
190
|
+
}//namespace engine
|
191
|
+
}//namespace db
|
192
|
+
}//namespace bzs
|
193
|
+
|
194
|
+
#endif //BOOKMARK_H
|
195
|
+
|