From 8e989e909a2a43f5003ed66c3fa9e59602c242d8 Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 28 May 2013 22:39:37 +0700 Subject: [PATCH] #56 and copyright lines --- pyejdb/pyejdb/bson.py | 27 +++++--- tcejdb/Changelog | 189 -------------------------------------------------- tcejdb/basedefs.h | 20 ++++-- tcejdb/configure.ac | 4 +- tcejdb/myconf.c | 1 + tcejdb/myconf.h | 1 + tcejdb/platform.c | 15 ++++ tcejdb/tcadb.c | 1 + tcejdb/tcadb.h | 1 + tcejdb/tcbdb.c | 1 + tcejdb/tcbdb.h | 1 + tcejdb/tcfdb.c | 3 +- tcejdb/tcfdb.h | 1 + tcejdb/tchdb.c | 1 + tcejdb/tchdb.h | 1 + tcejdb/tctdb.c | 1 + tcejdb/tctdb.h | 1 + tcejdb/tcutil.c | 1 + tcejdb/tcutil.h | 1 + 19 files changed, 62 insertions(+), 209 deletions(-) delete mode 100644 tcejdb/Changelog diff --git a/pyejdb/pyejdb/bson.py b/pyejdb/pyejdb/bson.py index 85eb182..b7e42b0 100644 --- a/pyejdb/pyejdb/bson.py +++ b/pyejdb/pyejdb/bson.py @@ -364,7 +364,8 @@ class BSON_Binary_Generic(BSON_Binary): self._value = value def _py_value(self): - return self._value + return self._value if PY3 else self + BSON_Binary._register_subtype(BSON_Binary_Generic) BSON_Binary._register_subtype(BSON_Binary_Generic, b"\x02") # deprecated alternative @@ -428,7 +429,6 @@ class BSON_ObjectId(BSON_Value): hexlify(self._value).decode("ascii")) def _py_value(self): - print(self._value) return hexlify(self._value).decode("ascii") def serialize(self, stream): @@ -680,6 +680,7 @@ if PY3: list: lambda l: BSON_Array([py_to_bs(v) for v in l]), int: lambda i: BSON_Int32(i) if -2 ** 31 <= i <= 2 ** 31 - 1 else BSON_Int64(i) if -2 ** 63 <= i <= 2 ** 63 - 1 else _py_no_bs(i), bytes: lambda b: BSON_Binary_Generic(b), + BytesIO: lambda b: BSON_Binary_Generic(b.getvalue()), bool: lambda b: BSON_Boolean(b), datetime: lambda dt: BSON_Datetime(dt), type(None): lambda n: BSON_Null(n), @@ -689,9 +690,11 @@ else: { float: lambda f: BSON_Double(f), str: lambda s: BSON_String(s), + unicode: lambda s: BSON_String(s), dict: lambda d: BSON_Document(odict((str(k), py_to_bs(v)) for k, v in d.items())), list: lambda l: BSON_Array([py_to_bs(v) for v in l]), int: lambda i: BSON_Int32(i) if -2 ** 31 <= i <= 2 ** 31 - 1 else BSON_Int64(i) if -2 ** 63 <= i <= 2 ** 63 - 1 else _py_no_bs(i), + long: lambda i: BSON_Int32(i) if -2 ** 31 <= i <= 2 ** 31 - 1 else BSON_Int64(i) if -2 ** 63 <= i <= 2 ** 63 - 1 else _py_no_bs(i), BytesIO: lambda b: BSON_Binary_Generic(b.getvalue()), bool: lambda b: BSON_Boolean(b), datetime: lambda dt: BSON_Datetime(dt), @@ -764,10 +767,7 @@ if __name__ == "__main__": # self-test assert cstrify("") == b"\x00" assert cstrify("foo") == b"foo\x00" - if PY3: - assert cstrify("абв") == b"\xd0\xb0\xd0\xb1\xd0\xb2\x00" - else: - assert cstrify(u"абв") == b"\xd0\xb0\xd0\xb1\xd0\xb2\x00" + assert cstrify(u"абв") == b"\xd0\xb0\xd0\xb1\xd0\xb2\x00" print("ok") @@ -873,10 +873,11 @@ if __name__ == "__main__": # self-test assert py_to_bs_same(BSON_JavaScriptWithScope(("var i = j;", BSON_Document({ "j": BSON_Int32(10) })))) assert py_to_bs_same(BSON_Timestamp(0x7fffffffffffffff)) + assert py_to_bs([]) == BSON_Array([]) assert py_to_bs( [ - b"implicit", + b"implicit" if PY3 else BytesIO("implicit"), BSON_Binary_Generic(b"generic"), BSON_Binary_Function(b"function"), BSON_Binary_UUID(b"uuid"), @@ -945,7 +946,9 @@ if __name__ == "__main__": # self-test def bs_to_py_same(v): return bs_to_py(v) is v - assert isinstance(BSON_ObjectId(b"\x00" * 12)._py_value(), str) + #assert isinstance(BSON_ObjectId(b"\x00" * 12)._py_value(), str if PY3 else basestring) + #assert isinstance(BSON_ObjectId(b"\x00" * 12)._py_value(), str) + assert bs_to_py_same(BSON_Regex(("^$", ""))) assert bs_to_py_same(BSON_JavaScript("var i = 0;")) assert bs_to_py_same(BSON_Symbol("class")) @@ -953,6 +956,8 @@ if __name__ == "__main__": # self-test assert bs_to_py_same(BSON_Timestamp(0x7fffffffffffffff)) assert bs_to_py(BSON_Array([])) == [] + + assert bs_to_py(BSON_Array( [ BSON_Binary_Generic(b"generic"), @@ -962,7 +967,7 @@ if __name__ == "__main__": # self-test BSON_Binary_UserDefined(b"userdefined"), ])) == \ [ - b"generic", + b"generic" if PY3 else BSON_Binary_Generic(b"generic"), BSON_Binary_Function(b"function"), BSON_Binary_UUID(b"uuid"), BSON_Binary_MD5(b"md5"), @@ -1054,9 +1059,9 @@ if __name__ == "__main__": # self-test assert parse_bytes(b) == { "int64": 2**63-1 } bin = bytes([ i for i in range(256) ]) - b = serialize_to_bytes({ "bytes": bin }) + b = serialize_to_bytes({ "bytes": BytesIO(bin) }) assert b == serialize_to_bytes({ "bytes": BSON_Binary_Generic(bin) }) - assert parse_bytes(b) == { "bytes": bin } + assert parse_bytes(b) == { "bytes": bin if PY3 else BSON_Binary_Generic(bin)} b = serialize_to_bytes({ "function": BSON_Binary_Function(b"function") }) assert parse_bytes(b) == { "function": BSON_Binary_Function(b"function") } diff --git a/tcejdb/Changelog b/tcejdb/Changelog deleted file mode 100644 index 9e7c349..0000000 --- a/tcejdb/Changelog +++ /dev/null @@ -1,189 +0,0 @@ -2013-04-25 Anton Adamansky. - * EJDB and TokyoCabinet API ported to Windows (ticket #12) - - Release 1.1.0 - -2013-03-22 Anton Adamansky. - * Fixed number index crash #54 - - Release 1.0.68 - -2013-03-20 Anton Adamansky. - * Python3 binding - * Lua binding - * Minor bug fixes - - Release 1.0.66 - -2013-01-22 Anton Adamansky. - * Collection joins now supported (ticket #43) - - Release 1.0.55 - -2013-01-16 Anton Adamansky. - * Crash fix #44 - - Release 1.0.54 - -2013-01-15 Anton Adamansky. - * Minor fix in ejdb.js (merged pull #42) - * Result set fields can be excluded (ticket #34) - - Release 1.0.53 - -2013-01-14 Anton Adamansky. - * $addToSetAll and $pullAll operations implemented. - - Release 1.0.51 - -2013-01-13 Anton Adamansky. - * Fixed #35 - * Fixed incorrect handling of query error codes. - - Release 1.0.50 - -2013-01-11 Anton Adamansky. - * Fixed crash if null fields presented in queries. - - Release 1.0.48 - -2013-01-10 Anton Adamansky. - * Removed cunit library dependency for production builds. - - Release 1.0.47 - -2013-01-09 Anton Adamansky. - * Critical fixes in ejdb cli console - * Fix count(*) query optimization when OR predicates used - * Collection should be automatically created for $upsert queries (ticket #32) - * Test cases are not executed during npm installation - - Release 1.0.46 - -2013-01-09 Anton Adamansky. - * Fixed crash on sorting (ticket #31) - - Release 1.0.44 - -2013-01-08 Anton Adamansky. - * Fixed #28 - * Deprecated node.js API removeCollection() use dropCollection() instead. - - Release 1.0.43 - -2013-01-07 Anton Adamansky. - * Fixed #29 - - Release 1.0.42 - -2013-01-05 Anton Adamansky. - * Optimized count(*) on whole collection (ticket #27) - * Optimized $dropall on whole collection (ticket #26) - * Database files can be opened directly from CLI command line - * Fixed minor bug in $upsert operation - - Release 1.0.41 - -2012-12-31 Anton Adamansky. - * Added `$upsert` opration (ticket #25) - * Expose ejdb transactions API in Nodejs binding (ticket #22) - - Release 1.0.38 - -2012-12-28 Anton Adamansky. - * Performance enhancements, memory allocs reduced to %20-30% - - Release 1.0.37 - -2012-12-27 Anton Adamansky. - * Fixed crash when using update qry with single indexed field(ticket: #23) - - Release 1.0.36 - -2012-12-26 Anton Adamansky. - * Fixed crash on collection remove (ticket: #18) - * Incorrect dropping of all field indexes (ticket: #16) - - Release 1.0.35 - -2012-12-25 Anton Adamansky. - * Nodejs database cursors more GC friendly - - Release 1.0.34 - -2012-12-24 Anton Adamansky. - * Better array query matching - * $elemMatch support in queries (ticket: #13) - - Release 1.0.33 - -2012-12-20 Anton Adamansky. - * Initial version of EJDB CLI console - * All db methods are synchronous if no callback provided - - Release 1.0.30 - -2012-12-15 Anton Adamansky. - * Added EJDB.isValidOID() into nodejs API - - Release 1.0.28 - -2012-12-14 Anton Adamansky. - * Added `$addToSet` and `$pull` operations. - - Release 1.0.27 - -2012-12-04 Anton Adamansky. - * Allows multiple matching conditions for single query field. Eg: {'age' : {'$lt' : '60', '$gt' : '30'}} - - Release 1.0.25 - -2012-12-01 Anton Adamansky. - * Fixed various threading issues - - Release 1.0.24 - -2012-11-30 Anton Adamansky. - * Fix crash when using `$strand` and `$stror` operations - - Release 1.0.22 - -2012-11-30 Anton Adamansky. - * Query optimization in the case of many arguments (>16) in `$in` operator - - Release 1.0.21 - -2012-11-29 Anton Adamansky. - * More strict `_id` field checking on saving bsons - * Fixed bug if `_id` used with `$nin` operator - - Release 1.0.20 - -2012-11-28 Anton Adamansky. - * The $begin query operation now works with tokens. Eg: {'name' : {'$begin' : ['token1', 'token2', ...]}} - - Release 1.0.18 - -2012-11-27 Anton Adamansky. - * Added $dropall query operation in order to remove matched records - * Better boolean type support, boolean values treated as numbers. - * Various bugfixes - - Release 1.0.17 - -2012-11-26 Anton Adamansky. - * NodeJS: Added merge json object option ($merge) in save() method - * Added ejdbsavebson2() with merge option. - - Release 1.0.14 - -2012-11-25 Anton Adamansky. - * Fixed assertion error in nodejs binding when using update queries - * Write lock acquired on each collection when closing database by 'ejdbclose()' - * Synchronous versions of setIndex and sync function was provided - - Release 1.0.13 - -2012-11-20 Anton Adamansky. - * #9 In-place update operations `$set` and `$inc` - - Release 1.0.11 - -2012-11-16 Anton Adamansky. - * #8 Field subset selection in queries - - Release 1.0.9 - -2012-11-15 Anton Adamansky. - * #7 Support PK hash index for $in operation if '_id' field is used in matching - - Release 1.0.8 - -2012-11-14 Anton Adamansky. - * New case insensitive field matching query operand: $icase - * Case insensitive string indexes support - - Release 1.0.7 - -2012-11-08 Anton Adamansky. - * Correct query matching of _id field - - Release 1.0.6 - -2012-11-08 Anton Adamansky. - * Better bson checking in query API - - Release 1.0.5 - -2012-11-08 Anton Adamansky. - * OSX build fixes - - Release 1.0.3 - -2012-11-06 Anton Adamansky. - * Node.js binding - - Release 1.0.1 - -2012-10-27 Anton Adamansky. - * Initial release based on Tokyo Cabinet v1.4.48 - - Release 1.0.0 diff --git a/tcejdb/basedefs.h b/tcejdb/basedefs.h index 637b90d..90d3eb0 100644 --- a/tcejdb/basedefs.h +++ b/tcejdb/basedefs.h @@ -1,9 +1,17 @@ -/* - * File: basic.h - * Author: adam - * - * Created on April 1, 2013, 6:21 PM - */ +/************************************************************************************************* + * The abstract database API of EJDB + * Copyright (C) 2012-2013 Softmotions Ltd + * This file is part of EJDB. + * EJDB is free software; you can redistribute it and/or modify it under the terms of + * the GNU Lesser General Public License as published by the Free Software Foundation; either + * version 2.1 of the License or any later version. EJDB is distributed in the hope + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * You should have received a copy of the GNU Lesser General Public License along with Tokyo + * Cabinet; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA. + *************************************************************************************************/ #ifndef BASIC_H #define BASIC_H diff --git a/tcejdb/configure.ac b/tcejdb/configure.ac index 2afef08..1ca9b92 100644 --- a/tcejdb/configure.ac +++ b/tcejdb/configure.ac @@ -1,4 +1,4 @@ -# Source of configuration for Tokyo Cabinet +# Source of configuration for EJDB #================================================================ @@ -32,7 +32,7 @@ MYCGIFILES="tcawmgr.cgi" MYMAN1FILES="" MYMAN3FILES="libtcejdb.3" #MYDOCUMENTFILES="COPYING ChangeLog doc tokyocabinet.idl" -MYDOCUMENTFILES="COPYING Changelog" +MYDOCUMENTFILES="COPYING" MYPCFILES="tcejdb.pc" #C compiler diff --git a/tcejdb/myconf.c b/tcejdb/myconf.c index 2b95457..3c4a6ea 100644 --- a/tcejdb/myconf.c +++ b/tcejdb/myconf.c @@ -1,6 +1,7 @@ /************************************************************************************************* * System-dependent configurations of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/myconf.h b/tcejdb/myconf.h index 33de160..02db1d8 100644 --- a/tcejdb/myconf.h +++ b/tcejdb/myconf.h @@ -1,6 +1,7 @@ /************************************************************************************************* * System-dependent configurations of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/platform.c b/tcejdb/platform.c index cc138d7..8c99a23 100644 --- a/tcejdb/platform.c +++ b/tcejdb/platform.c @@ -1,3 +1,18 @@ +/************************************************************************************************* + * The abstract database API of EJDB + * Copyright (C) 2012-2013 Softmotions Ltd + * This file is part of EJDB. + * EJDB is free software; you can redistribute it and/or modify it under the terms of + * the GNU Lesser General Public License as published by the Free Software Foundation; either + * version 2.1 of the License or any later version. EJDB is distributed in the hope + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * You should have received a copy of the GNU Lesser General Public License along with Tokyo + * Cabinet; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA. + *************************************************************************************************/ + #ifdef _WIN32 #include "win32/platform.c" #endif diff --git a/tcejdb/tcadb.c b/tcejdb/tcadb.c index 793f56f..63d33a5 100644 --- a/tcejdb/tcadb.c +++ b/tcejdb/tcadb.c @@ -1,6 +1,7 @@ /************************************************************************************************* * The abstract database API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/tcadb.h b/tcejdb/tcadb.h index 73eb7aa..abac4db 100644 --- a/tcejdb/tcadb.h +++ b/tcejdb/tcadb.h @@ -1,6 +1,7 @@ /************************************************************************************************* * The abstract database API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/tcbdb.c b/tcejdb/tcbdb.c index 6b6f4d1..104df2f 100644 --- a/tcejdb/tcbdb.c +++ b/tcejdb/tcbdb.c @@ -1,6 +1,7 @@ /************************************************************************************************* * The B+ tree database API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/tcbdb.h b/tcejdb/tcbdb.h index 2da2b54..3291020 100644 --- a/tcejdb/tcbdb.h +++ b/tcejdb/tcbdb.h @@ -1,6 +1,7 @@ /************************************************************************************************* * The B+ tree database API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/tcfdb.c b/tcejdb/tcfdb.c index 9102fb2..c6c6762 100644 --- a/tcejdb/tcfdb.c +++ b/tcejdb/tcfdb.c @@ -1,6 +1,7 @@ /************************************************************************************************* * The fixed-length database API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -3125,7 +3126,7 @@ void tcfdbprintmeta(TCFDB *fdb) { wp += sprintf(wp, " fd=%d", fdb->fd); wp += sprintf(wp, " walfd=%d", fdb->walfd); wp += sprintf(wp, " dbgfd=%d", fdb->dbgfd); -#endif +#endif #ifndef NDEBUG wp += sprintf(wp, " cnt_writerec=%" PRIdMAX "", (int64_t) fdb->cnt_writerec); wp += sprintf(wp, " cnt_readrec=%" PRIdMAX "", (int64_t) fdb->cnt_readrec); diff --git a/tcejdb/tcfdb.h b/tcejdb/tcfdb.h index 0496bb0..e83259f 100644 --- a/tcejdb/tcfdb.h +++ b/tcejdb/tcfdb.h @@ -1,6 +1,7 @@ /************************************************************************************************* * The fixed-length database API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/tchdb.c b/tcejdb/tchdb.c index 0c75abc..b571b34 100644 --- a/tcejdb/tchdb.c +++ b/tcejdb/tchdb.c @@ -1,6 +1,7 @@ /************************************************************************************************* * The hash database API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/tchdb.h b/tcejdb/tchdb.h index 4e30d6c..4cd1e16 100644 --- a/tcejdb/tchdb.h +++ b/tcejdb/tchdb.h @@ -1,6 +1,7 @@ /************************************************************************************************* * The hash database API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/tctdb.c b/tcejdb/tctdb.c index f12d264..d8d1221 100644 --- a/tcejdb/tctdb.c +++ b/tcejdb/tctdb.c @@ -1,6 +1,7 @@ /************************************************************************************************* * The table database API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/tctdb.h b/tcejdb/tctdb.h index 3774235..11fc4c5 100644 --- a/tcejdb/tctdb.h +++ b/tcejdb/tctdb.h @@ -1,6 +1,7 @@ /************************************************************************************************* * The table database API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/tcutil.c b/tcejdb/tcutil.c index b621507..70ff9da 100644 --- a/tcejdb/tcutil.c +++ b/tcejdb/tcutil.c @@ -1,6 +1,7 @@ /************************************************************************************************* * The utility API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/tcejdb/tcutil.h b/tcejdb/tcutil.h index 8c9b8bf..18effa0 100644 --- a/tcejdb/tcutil.h +++ b/tcejdb/tcutil.h @@ -1,6 +1,7 @@ /************************************************************************************************* * The utility API of Tokyo Cabinet * Copyright (C) 2006-2012 FAL Labs + * Copyright (C) 2012-2013 Softmotions Ltd * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either -- 2.7.4