kccachedb.h   kccachedb.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Cache hash database * Cache hash database
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kccommon.h   kccommon.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Common symbols for the library * Common symbols for the library
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kccompare.h   kccompare.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Comparator functions * Comparator functions
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kccompress.h   kccompress.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Data compressor and decompressor * Data compressor and decompressor
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kcdb.h   kcdb.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Database interface * Database interface
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kcdbext.h   kcdbext.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Database extension * Database extension
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kcdirdb.h   kcdirdb.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Directory hash database * Directory hash database
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kcfile.h   kcfile.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Filesystem abstraction * Filesystem abstraction
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kchashdb.h   kchashdb.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* File hash database * File hash database
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kclangc.h   kclangc.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* C language binding * C language binding
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
skipping to change at line 223 skipping to change at line 223
/** /**
* Get the hash value by FNV hashing. * Get the hash value by FNV hashing.
* @param buf the source buffer. * @param buf the source buffer.
* @param size the size of the source buffer. * @param size the size of the source buffer.
* @return the hash value. * @return the hash value.
*/ */
uint64_t kchashfnv(const void* buf, size_t size); uint64_t kchashfnv(const void* buf, size_t size);
/** /**
* Calculate the levenshtein distance of two regions.
* @param abuf the pointer to the region of one buffer.
* @param asiz the size of the region of one buffer.
* @param bbuf the pointer to the region of the other buffer.
* @param bsiz the size of the region of the other buffer.
* @param utf flag to treat keys as UTF-8 strings.
* @return the levenshtein distance of two regions.
*/
size_t kclevdist(const void* abuf, size_t asiz, const void* bbuf, size_t bs
iz, int32_t utf);
/**
* Get the quiet Not-a-Number value. * Get the quiet Not-a-Number value.
* @return the quiet Not-a-Number value. * @return the quiet Not-a-Number value.
*/ */
double kcnan(); double kcnan();
/** /**
* Get the positive infinity value. * Get the positive infinity value.
* @return the positive infinity value. * @return the positive infinity value.
*/ */
double kcinf(); double kcinf();
skipping to change at line 728 skipping to change at line 739
* @param regex the regular expression string. * @param regex the regular expression string.
* @param strary an array to contain the result. Its size must be sufficie nt. * @param strary an array to contain the result. Its size must be sufficie nt.
* @param max the maximum number to retrieve. * @param max the maximum number to retrieve.
* @return the number of retrieved keys or -1 on failure. * @return the number of retrieved keys or -1 on failure.
* @note The region of each element of the result should be released with t he kcfree function * @note The region of each element of the result should be released with t he kcfree function
* when it is no longer in use. * when it is no longer in use.
*/ */
int64_t kcdbmatchregex(KCDB* db, const char* regex, char** strary, size_t m ax); int64_t kcdbmatchregex(KCDB* db, const char* regex, char** strary, size_t m ax);
/** /**
* Get keys similar to a string in terms of the levenshtein distance.
* @param db a database object.
* @param origin the origin string.
* @param range the maximum distance of keys to adopt.
* @param utf flag to treat keys as UTF-8 strings.
* @param strary an array to contain the result. Its size must be sufficie
nt.
* @param max the maximum number to retrieve.
* @return the number of retrieved keys or -1 on failure.
* @note The region of each element of the result should be released with t
he kcfree function
* when it is no longer in use.
*/
int64_t kcdbmatchsimilar(KCDB* db, const char* origin, uint32_t range, int3
2_t utf,
char** strary, size_t max);
/**
* Merge records from other databases. * Merge records from other databases.
* @param db a database object. * @param db a database object.
* @param srcary an array of the source detabase objects. * @param srcary an array of the source detabase objects.
* @param srcnum the number of the elements of the source array. * @param srcnum the number of the elements of the source array.
* @param mode the merge mode. KCMSET to overwrite the existing value, KCM ADD to keep the * @param mode the merge mode. KCMSET to overwrite the existing value, KCM ADD to keep the
* existing value, KCMREPLACE to modify the existing record only, KCMAPPEND to append the new * existing value, KCMREPLACE to modify the existing record only, KCMAPPEND to append the new
* value. * value.
* @return true on success, or false on failure. * @return true on success, or false on failure.
*/ */
int32_t kcdbmerge(KCDB* db, KCDB** srcary, size_t srcnum, uint32_t mode); int32_t kcdbmerge(KCDB* db, KCDB** srcary, size_t srcnum, uint32_t mode);
 End of changes. 3 change blocks. 
1 lines changed or deleted 31 lines changed or added


 kcmap.h   kcmap.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Data mapping structures * Data mapping structures
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kcplantdb.h   kcplantdb.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Plant database * Plant database
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kcpolydb.h   kcpolydb.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Polymorphic database * Polymorphic database
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
skipping to change at line 53 skipping to change at line 53
* is important to close every database file by the PolyDB::close method wh en the database is no * is important to close every database file by the PolyDB::close method wh en the database is no
* longer in use. It is forbidden for multible database objects in a proce ss to open the same * longer in use. It is forbidden for multible database objects in a proce ss to open the same
* database at the same time. It is forbidden to share a database object w ith child processes. * database at the same time. It is forbidden to share a database object w ith child processes.
*/ */
class PolyDB : public BasicDB { class PolyDB : public BasicDB {
public: public:
class Cursor; class Cursor;
private: private:
class StreamLogger; class StreamLogger;
class StreamMetaTrigger; class StreamMetaTrigger;
struct SimilarKey;
struct MergeLine; struct MergeLine;
public: public:
/** /**
* Cursor to indicate a record. * Cursor to indicate a record.
*/ */
class Cursor : public BasicDB::Cursor { class Cursor : public BasicDB::Cursor {
friend class PolyDB; friend class PolyDB;
public: public:
/** /**
* Constructor. * Constructor.
skipping to change at line 1262 skipping to change at line 1263
err = true; err = true;
} }
if (checker && !checker->check("match_regex", "ending", strvec->size(), allcnt)) { if (checker && !checker->check("match_regex", "ending", strvec->size(), allcnt)) {
set_error(_KCCODELINE_, Error::LOGIC, "checker failed"); set_error(_KCCODELINE_, Error::LOGIC, "checker failed");
err = true; err = true;
} }
delete cur; delete cur;
return err ? -1 : strvec->size(); return err ? -1 : strvec->size();
} }
/** /**
* Get keys similar to a string in terms of the levenshtein distance.
* @param origin the origin string.
* @param range the maximum distance of keys to adopt.
* @param utf flag to treat keys as UTF-8 strings.
* @param strvec a string vector to contain the result.
* @param max the maximum number to retrieve. If it is negative, no limi
t is specified.
* @param checker a progress checker object. If it is NULL, no checking
is performed.
* @return the number of retrieved keys or -1 on failure.
*/
int64_t match_similar(const std::string& origin, size_t range, bool utf,
std::vector<std::string>* strvec,
int64_t max = -1, ProgressChecker* checker = NULL)
{
_assert_(strvec);
if (max < 0) max = INT64MAX;
bool err = false;
int64_t allcnt = count();
if (checker && !checker->check("match_similar", "beginning", 0, allcnt)
) {
set_error(_KCCODELINE_, Error::LOGIC, "checker failed");
err = true;
}
strvec->clear();
uint32_t ostack[128];
uint32_t* oary = NULL;
size_t onum = 0;
if (utf) {
const char* ostr = origin.c_str();
onum = strutflen(ostr);
oary = onum > sizeof(ostack) / sizeof(*ostack) ? new uint32_t[onum] :
ostack;
strutftoucs(ostr, oary, &onum);
}
Cursor* cur = cursor();
int64_t curcnt = 0;
std::priority_queue<SimilarKey> queue;
if (cur->jump()) {
if (max > 0) {
while (true) {
size_t ksiz;
char* kbuf = cur->get_key(&ksiz, true);
if (kbuf) {
size_t kdist;
if (oary) {
uint32_t kstack[128];
uint32_t* kary = ksiz > sizeof(kstack) / sizeof(*kstack) ?
new uint32_t[ksiz] : kstack;
size_t knum;
strutftoucs(kbuf, ksiz, kary, &knum);
kdist = std::labs((long)onum - (long)knum) > range ?
UINT32MAX : strucsdist(oary, onum, kary, knum);
if (kary != kstack) delete[] kary;
} else {
kdist = std::labs((long)origin.size() - (long)ksiz) > range ?
UINT32MAX : memdist(origin.data(), origin.size(), kbuf, k
siz);
}
if (kdist <= range) {
std::string key(kbuf, ksiz);
if ((int64_t)queue.size() < max) {
SimilarKey skey = { kdist, key, curcnt };
queue.push(skey);
} else {
const SimilarKey& top = queue.top();
if (!top.less(kdist, key, curcnt)) {
queue.pop();
SimilarKey skey = { kdist, key, curcnt };
queue.push(skey);
}
}
}
delete[] kbuf;
} else {
if (cur->error() != Error::NOREC) err = true;
break;
}
curcnt++;
if (checker && !checker->check("match_similar", "processing", cur
cnt, allcnt)) {
set_error(_KCCODELINE_, Error::LOGIC, "checker failed");
err = true;
}
}
while (!queue.empty()) {
const SimilarKey& top = queue.top();
strvec->push_back(top.key);
queue.pop();
}
size_t end = strvec->size() - 1;
size_t mid = strvec->size() / 2;
for (size_t i = 0; i < mid; i++) {
(*strvec)[i].swap((*strvec)[end-i]);
}
}
} else if (cur->error() != Error::NOREC) {
err = true;
}
if (checker && !checker->check("match_similar", "ending", strvec->size(
), allcnt)) {
set_error(_KCCODELINE_, Error::LOGIC, "checker failed");
err = true;
}
delete cur;
if (oary && oary != ostack) delete[] oary;
return err ? -1 : strvec->size();
}
/**
* Merge records from other databases. * Merge records from other databases.
* @param srcary an array of the source detabase objects. * @param srcary an array of the source detabase objects.
* @param srcnum the number of the elements of the source array. * @param srcnum the number of the elements of the source array.
* @param mode the merge mode. PolyDB::MSET to overwrite the existing va lue, PolyDB::MADD to * @param mode the merge mode. PolyDB::MSET to overwrite the existing va lue, PolyDB::MADD to
* keep the existing value, PolyDB::MREPLACE to modify the existing recor d only, * keep the existing value, PolyDB::MREPLACE to modify the existing recor d only,
* PolyDB::MAPPEND to append the new value. * PolyDB::MAPPEND to append the new value.
* @param checker a progress checker object. If it is NULL, no checking is performed. * @param checker a progress checker object. If it is NULL, no checking is performed.
* @return true on success, or false on failure. * @return true on success, or false on failure.
*/ */
bool merge(BasicDB** srcary, size_t srcnum, MergeMode mode = MSET, bool merge(BasicDB** srcary, size_t srcnum, MergeMode mode = MSET,
skipping to change at line 1487 skipping to change at line 1589
case MetaTrigger::MISC: kstr = "MISC"; break; case MetaTrigger::MISC: kstr = "MISC"; break;
} }
if (!prefix_.empty()) *strm_ << prefix_ << ": "; if (!prefix_.empty()) *strm_ << prefix_ << ": ";
*strm_ << "[" << kstr << "]: " << message << std::endl; *strm_ << "[" << kstr << "]: " << message << std::endl;
} }
private: private:
std::ostream* strm_; ///< output stream std::ostream* strm_; ///< output stream
std::string prefix_; ///< prefix of each message std::string prefix_; ///< prefix of each message
}; };
/** /**
* Key for similarity search.
*/
struct SimilarKey {
size_t dist;
std::string key;
uint32_t order;
bool operator <(const SimilarKey& right) const {
if (dist != right.dist) return dist < right.dist;
if (key != right.key) return key < right.key;
return order < right.order;
}
bool less(size_t rdist, const std::string& rkey, uint32_t rorder) const
{
if (dist != rdist) return dist < rdist;
if (key != rkey) return key < rkey;
return order < rorder;
}
};
/**
* Front line of a merging list. * Front line of a merging list.
*/ */
struct MergeLine { struct MergeLine {
BasicDB::Cursor* cur; ///< cursor BasicDB::Cursor* cur; ///< cursor
Comparator* comp; ///< comparator Comparator* comp; ///< comparator
char* kbuf; ///< pointer to the key char* kbuf; ///< pointer to the key
size_t ksiz; ///< size of the key size_t ksiz; ///< size of the key
const char* vbuf; ///< pointer to the value const char* vbuf; ///< pointer to the value
size_t vsiz; ///< size of the value size_t vsiz; ///< size of the value
/** comparing operator */ /** comparing operator */
 End of changes. 4 change blocks. 
1 lines changed or deleted 130 lines changed or added


 kcprotodb.h   kcprotodb.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Prototype database * Prototype database
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kcregex.h   kcregex.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Regular expression * Regular expression
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kcstashdb.h   kcstashdb.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Stash database * Stash database
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kctextdb.h   kctextdb.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Plain text database * Plain text database
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kcthread.h   kcthread.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Threading devices * Threading devices
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 kcutil.h   kcutil.h 
/************************************************************************** *********************** /************************************************************************** ***********************
* Utility functions * Utility functions
* Copyright (C) 2009-2011 FAL Labs * Copyright (C) 2009-2012 FAL Labs
* This file is part of Kyoto Cabinet. * This file is part of Kyoto Cabinet.
* This program is free software: you can redistribute it and/or modify it under the terms of * This program is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundat ion, either version * the GNU General Public License as published by the Free Software Foundat ion, either version
* 3 of the License, or any later version. * 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY; * This program is distributed in the hope that it will be useful, but WITH OUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PA RTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
************************************************************************** ***********************/ ************************************************************************** ***********************/
skipping to change at line 562 skipping to change at line 562
* @param hbuf the target pattern buffer. * @param hbuf the target pattern buffer.
* @param hsiz the size of the target pattern buffer. * @param hsiz the size of the target pattern buffer.
* @param nbuf the sub pattern buffer. * @param nbuf the sub pattern buffer.
* @param nsiz the size of the sub pattern buffer. * @param nsiz the size of the sub pattern buffer.
* @return the pointer to the beginning of the sub pattern in the target pa ttern buffer, or NULL * @return the pointer to the beginning of the sub pattern in the target pa ttern buffer, or NULL
* if the sub pattern is not found. * if the sub pattern is not found.
*/ */
void* memimem(const void* hbuf, size_t hsiz, const void* nbuf, size_t nsiz) ; void* memimem(const void* hbuf, size_t hsiz, const void* nbuf, size_t nsiz) ;
/** /**
* Calculate the levenshtein distance of two regions in bytes.
* @param abuf the pointer to the region of one buffer.
* @param asiz the size of the region of one buffer.
* @param bbuf the pointer to the region of the other buffer.
* @param bsiz the size of the region of the other buffer.
* @return the levenshtein distance of two regions.
*/
size_t memdist(const void* abuf, size_t asiz, const void* bbuf, size_t bsiz
);
/**
* Duplicate a string on memory. * Duplicate a string on memory.
* @param str the source string. * @param str the source string.
* @note Because the region of the return value is allocated with the the n ew[] operator, it * @note Because the region of the return value is allocated with the the n ew[] operator, it
* should be released with the delete[] operator when it is no longer in us e. * should be released with the delete[] operator when it is no longer in us e.
*/ */
char* strdup(const char* str); char* strdup(const char* str);
/** /**
* Convert the letters of a string into upper case. * Convert the letters of a string into upper case.
* @param str the string to convert. * @param str the string to convert.
skipping to change at line 671 skipping to change at line 681
/** /**
* Convert a UTF-8 string into a UCS-4 array. * Convert a UTF-8 string into a UCS-4 array.
* @param src the source object. * @param src the source object.
* @param dest the destination object. It must have enough size. * @param dest the destination object. It must have enough size.
* @param np the pointer to the variable into which the number of elements in the destination * @param np the pointer to the variable into which the number of elements in the destination
* object is assgined. * object is assgined.
*/ */
void strutftoucs(const char* src, uint32_t* dest, size_t* np); void strutftoucs(const char* src, uint32_t* dest, size_t* np);
/** /**
* Convert a UTF-8 string into a UCS-4 array.
* @param src the source object which does not have to be trailed by zero c
ode.
* @param slen the length of the source object.
* @param dest the destination object. It must have enough size.
* @param np the pointer to the variable into which the number of elements
in the destination
* object is assgined.
*/
void strutftoucs(const char* src, size_t slen, uint32_t* dest, size_t* np);
/**
* Convert a UCS-4 array into a UTF-8 string. * Convert a UCS-4 array into a UTF-8 string.
* @param src the source object. * @param src the source object.
* @param snum the number of elements in the source object. * @param snum the number of elements in the source object.
* @param dest the destination object. It must have enough size. * @param dest the destination object. It must have enough size.
* @return the size of the result string. * @return the size of the result string.
*/ */
size_t strucstoutf(const uint32_t* src, size_t snum, char* dest); size_t strucstoutf(const uint32_t* src, size_t snum, char* dest);
/** /**
* Calculate the levenshtein distance of two UTF-8 strings.
* @param astr one UTF-8 string.
* @param bstr the other UTF-8 string.
* @return the levenshtein distance of two arrays.
*/
size_t strutfdist(const char* astr, const char* bstr);
/**
* Calculate the levenshtein distance of two UCS-4 arrays.
* @param aary one UCS-4 array.
* @param anum the number of elements of one array.
* @param bary the other UCS-4 array.
* @param bnum the number of elements of the other array.
* @return the levenshtein distance of two arrays.
*/
size_t strucsdist(const uint32_t* aary, size_t anum, const uint32_t* bary,
size_t bnum);
/**
* Allocate a region on memory. * Allocate a region on memory.
* @param size the size of the region. * @param size the size of the region.
* @return the pointer to the allocated region. * @return the pointer to the allocated region.
*/ */
void* xmalloc(size_t size); void* xmalloc(size_t size);
/** /**
* Allocate a nullified region on memory. * Allocate a nullified region on memory.
* @param nmemb the number of elements. * @param nmemb the number of elements.
* @param size the size of each element. * @param size the size of each element.
skipping to change at line 2510 skipping to change at line 2548
uint32_t c = *rp; uint32_t c = *rp;
if (c < 0x80) { if (c < 0x80) {
dest[dnum++] = c; dest[dnum++] = c;
} else if (c < 0xe0) { } else if (c < 0xe0) {
if (rp[1] != '\0') { if (rp[1] != '\0') {
c = ((c & 0x1f) << 6) | (rp[1] & 0x3f); c = ((c & 0x1f) << 6) | (rp[1] & 0x3f);
if (c >= 0x80) dest[dnum++] = c; if (c >= 0x80) dest[dnum++] = c;
rp++; rp++;
} }
} else if (c < 0xf0) { } else if (c < 0xf0) {
if (rp[1] != '\0' && rp[2] != '\0') {
c = ((c & 0x0f) << 12) | ((rp[1] & 0x3f) << 6) | (rp[2] & 0x3f);
if (c >= 0x800) dest[dnum++] = c;
rp += 2;
}
} else if (c < 0xf8) {
if (rp[1] != '\0' && rp[2] != '\0' && rp[3] != '\0') {
c = ((c & 0x07) << 18) | ((rp[1] & 0x3f) << 12) | ((rp[2] & 0x3f) <
< 6) |
(rp[3] & 0x3f);
if (c >= 0x10000) dest[dnum++] = c;
rp += 3;
}
} else if (c < 0xfc) {
if (rp[1] != '\0' && rp[2] != '\0' && rp[3] != '\0' && rp[4] != '\0')
{
c = ((c & 0x03) << 24) | ((rp[1] & 0x3f) << 18) | ((rp[2] & 0x3f) <
< 12) |
((rp[3] & 0x3f) << 6) | (rp[4] & 0x3f);
if (c >= 0x200000) dest[dnum++] = c;
rp += 4;
}
} else if (c < 0xfe) {
if (rp[1] != '\0' && rp[2] != '\0' && rp[3] != '\0' && rp[4] != '\0'
&& rp[5] != '\0') {
c = ((c & 0x01) << 30) | ((rp[1] & 0x3f) << 24) | ((rp[2] & 0x3f) <
< 18) |
((rp[3] & 0x3f) << 12) | ((rp[4] & 0x3f) << 6) | (rp[5] & 0x3f)
;
if (c >= 0x4000000) dest[dnum++] = c;
rp += 5;
}
}
rp++;
}
*np = dnum;
}
/**
* Convert a UTF-8 string into a UCS-4 array.
*/
inline void strutftoucs(const char* src, size_t slen, uint32_t* dest, size_
t* np) {
_assert_(src && slen <= MEMMAXSIZ && dest && np);
const unsigned char* rp = (unsigned char*)src;
const unsigned char* ep = rp + slen;
size_t dnum = 0;
while (rp < ep) {
uint32_t c = *rp;
if (c < 0x80) {
dest[dnum++] = c;
} else if (c < 0xe0) {
if (rp[1] != '\0') {
c = ((c & 0x1f) << 6) | (rp[1] & 0x3f);
if (c >= 0x80) dest[dnum++] = c;
rp++;
}
} else if (c < 0xf0) {
if (rp[1] != '\0' && rp[2] != '\0') { if (rp[1] != '\0' && rp[2] != '\0') {
c = ((c & 0x0f) << 12) | ((rp[1] & 0x3f) << 6) | (rp[2] & 0x3f); c = ((c & 0x0f) << 12) | ((rp[1] & 0x3f) << 6) | (rp[2] & 0x3f);
if (c >= 0x800) dest[dnum++] = c; if (c >= 0x800) dest[dnum++] = c;
rp += 2; rp += 2;
} }
} else if (c < 0xf8) { } else if (c < 0xf8) {
if (rp[1] != '\0' && rp[2] != '\0' && rp[3] != '\0') { if (rp[1] != '\0' && rp[2] != '\0' && rp[3] != '\0') {
c = ((c & 0x07) << 18) | ((rp[1] & 0x3f) << 12) | ((rp[2] & 0x3f) < < 6) | c = ((c & 0x07) << 18) | ((rp[1] & 0x3f) << 12) | ((rp[2] & 0x3f) < < 6) |
(rp[3] & 0x3f); (rp[3] & 0x3f);
if (c >= 0x10000) dest[dnum++] = c; if (c >= 0x10000) dest[dnum++] = c;
 End of changes. 5 change blocks. 
1 lines changed or deleted 101 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/