susumu.yata
null+****@clear*****
Wed Jun 5 13:50:54 JST 2013
susumu.yata 2013-06-05 13:50:54 +0900 (Wed, 05 Jun 2013) New Revision: 51ebf869354d53ab4f68b47276351983c8cecb9c https://github.com/groonga/grnxx/commit/51ebf869354d53ab4f68b47276351983c8cecb9c Message: Create directories for DoubleArray and Patricia. Added files: lib/grnxx/map/double_array/Makefile.am lib/grnxx/map/double_array/dummy.cpp lib/grnxx/map/double_array/dummy.hpp lib/grnxx/map/double_array/header.cpp lib/grnxx/map/double_array/header.hpp lib/grnxx/map/patricia/Makefile.am lib/grnxx/map/patricia/dummy.cpp lib/grnxx/map/patricia/dummy.hpp lib/grnxx/map/patricia/header.cpp lib/grnxx/map/patricia/header.hpp Modified files: configure.ac lib/grnxx/map/Makefile.am lib/grnxx/map/double_array.cpp lib/grnxx/map/double_array.hpp lib/grnxx/map/patricia.cpp lib/grnxx/map/patricia.hpp Modified: configure.ac (+2 -0) =================================================================== --- configure.ac 2013-06-05 13:36:17 +0900 (1736eac) +++ configure.ac 2013-06-05 13:50:54 +0900 (58cfc35) @@ -67,7 +67,9 @@ AC_CONFIG_FILES([Makefile lib/grnxx/io/Makefile lib/grnxx/map/Makefile lib/grnxx/map/array_map/Makefile + lib/grnxx/map/double_array/Makefile lib/grnxx/map/hash_table/Makefile + lib/grnxx/map/patricia/Makefile lib/grnxx/storage/Makefile src/Makefile test/Makefile]) Modified: lib/grnxx/map/Makefile.am (+28 -24) =================================================================== --- lib/grnxx/map/Makefile.am 2013-06-05 13:36:17 +0900 (fb287f2) +++ lib/grnxx/map/Makefile.am 2013-06-05 13:50:54 +0900 (dc6195f) @@ -1,34 +1,38 @@ -SUBDIRS = \ - array_map \ - hash_table +SUBDIRS = \ + array_map \ + double_array \ + hash_table \ + patricia noinst_LTLIBRARIES = libgrnxx_map.la -libgrnxx_map_la_LIBADD = \ - array_map/libgrnxx_map_array_map.la \ - hash_table/libgrnxx_map_hash_table.la +libgrnxx_map_la_LIBADD = \ + array_map/libgrnxx_map_array_map.la \ + double_array/libgrnxx_map_double_array.la \ + hash_table/libgrnxx_map_hash_table.la \ + patricia/libgrnxx_map_patricia.la libgrnxx_map_la_LDFLAGS = @AM_LTLDFLAGS@ -libgrnxx_map_la_SOURCES = \ - array_map.cpp \ - bytes_array.cpp \ - bytes_store.cpp \ - cursor_impl.cpp \ - double_array.cpp \ - hash_table.cpp \ - patricia.cpp \ +libgrnxx_map_la_SOURCES = \ + array_map.cpp \ + bytes_array.cpp \ + bytes_store.cpp \ + cursor_impl.cpp \ + double_array.cpp \ + hash_table.cpp \ + patricia.cpp \ scanner_impl.cpp libgrnxx_map_includedir = ${includedir}/grnxx/map -libgrnxx_map_include_HEADERS = \ - array_map.hpp \ - bytes_array.hpp \ - bytes_store.hpp \ - cursor_impl.hpp \ - double_array.hpp \ - hash_table.hpp \ - header.hpp \ - helper.hpp \ - patricia.hpp \ +libgrnxx_map_include_HEADERS = \ + array_map.hpp \ + bytes_array.hpp \ + bytes_store.hpp \ + cursor_impl.hpp \ + double_array.hpp \ + hash_table.hpp \ + header.hpp \ + helper.hpp \ + patricia.hpp \ scanner_impl.hpp Modified: lib/grnxx/map/double_array.cpp (+7 -18) =================================================================== --- lib/grnxx/map/double_array.cpp 2013-06-05 13:36:17 +0900 (38cfa9b) +++ lib/grnxx/map/double_array.cpp 2013-06-05 13:50:54 +0900 (c6465c2) @@ -22,24 +22,13 @@ #include "grnxx/bytes.hpp" #include "grnxx/geo_point.hpp" #include "grnxx/logger.hpp" +#include "grnxx/map/double_array/header.hpp" #include "grnxx/map/helper.hpp" #include "grnxx/storage.hpp" namespace grnxx { namespace map { -struct DoubleArrayHeader { - // TODO - int64_t max_key_id; - uint64_t num_keys; - - DoubleArrayHeader(); -}; - -DoubleArrayHeader::DoubleArrayHeader() - : max_key_id(MAP_MIN_KEY_ID - 1), - num_keys(0) {} - template <typename T> Map<T> *DoubleArray<T>::create(Storage *, uint32_t, const MapOptions &) { GRNXX_ERROR() << "invalid combination"; @@ -117,13 +106,13 @@ bool DoubleArray<Bytes>::create_map(Storage *storage, uint32_t storage_node_id, const MapOptions &) { storage_ = storage; StorageNode storage_node = - storage->create_node(storage_node_id, sizeof(DoubleArrayHeader)); + storage->create_node(storage_node_id, sizeof(Header)); if (!storage_node) { return false; } storage_node_id_ = storage_node.id(); - header_ = static_cast<DoubleArrayHeader *>(storage_node.body()); - *header_ = DoubleArrayHeader(); + header_ = static_cast<Header *>(storage_node.body()); + *header_ = Header(); // TODO return false; } @@ -134,13 +123,13 @@ bool DoubleArray<Bytes>::open_map(Storage *storage, uint32_t storage_node_id) { if (!storage_node) { return false; } - if (storage_node.size() < sizeof(DoubleArrayHeader)) { + if (storage_node.size() < sizeof(Header)) { GRNXX_ERROR() << "invalid format: size = " << storage_node.size() - << ", header_size = " << sizeof(DoubleArrayHeader); + << ", header_size = " << sizeof(Header); return false; } storage_node_id_ = storage_node_id; - header_ = static_cast<DoubleArrayHeader *>(storage_node.body()); + header_ = static_cast<Header *>(storage_node.body()); // TODO return false; } Modified: lib/grnxx/map/double_array.hpp (+9 -2) =================================================================== --- lib/grnxx/map/double_array.hpp 2013-06-05 13:36:17 +0900 (11cdcd2) +++ lib/grnxx/map/double_array.hpp 2013-06-05 13:50:54 +0900 (b01b9f8) @@ -29,9 +29,15 @@ #include "grnxx/types.hpp" namespace grnxx { + +class Storage; + namespace map { +namespace double_array { + +struct Header; -struct DoubleArrayHeader; +} // namespace double_array template <typename T> class DoubleArray { @@ -44,6 +50,7 @@ class DoubleArray { template <> class DoubleArray<Bytes> : public Map<Bytes> { public: + using Header = double_array::Header; using Key = typename Map<Bytes>::Key; using KeyArg = typename Map<Bytes>::KeyArg; using Cursor = typename Map<Bytes>::Cursor; @@ -90,7 +97,7 @@ class DoubleArray<Bytes> : public Map<Bytes> { private: Storage *storage_; uint32_t storage_node_id_; - DoubleArrayHeader *header_; + Header *header_; bool create_map(Storage *storage, uint32_t storage_node_id, const MapOptions &options); Added: lib/grnxx/map/double_array/Makefile.am (+12 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/double_array/Makefile.am 2013-06-05 13:50:54 +0900 (5e79c12) @@ -0,0 +1,12 @@ +noinst_LTLIBRARIES = libgrnxx_map_double_array.la + +libgrnxx_map_double_array_la_LDFLAGS = @AM_LTLDFLAGS@ + +libgrnxx_map_double_array_la_SOURCES = \ + dummy.cpp \ + header.cpp + +libgrnxx_map_double_array_includedir = ${includedir}/grnxx/map/double_array +libgrnxx_map_double_array_include_HEADERS = \ + dummy.hpp \ + header.hpp Added: lib/grnxx/map/double_array/dummy.cpp (+28 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/double_array/dummy.cpp 2013-06-05 13:50:54 +0900 (852d43d) @@ -0,0 +1,28 @@ +/* + Copyright (C) 2012-2013 Brazil, Inc. + + This library 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 (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include "grnxx/map/double_array/dummy.hpp" + +#include "grnxx/map/double_array/header.hpp" + +namespace grnxx { +namespace map { +namespace double_array { + +} // namespace double_array +} // namespace map +} // namespace grnxx Added: lib/grnxx/map/double_array/dummy.hpp (+31 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/double_array/dummy.hpp 2013-06-05 13:50:54 +0900 (5be71a0) @@ -0,0 +1,31 @@ +/* + Copyright (C) 2012-2013 Brazil, Inc. + + This library 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 (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef GRNXX_MAP_DOUBLE_ARRAY_DUMMY_HPP +#define GRNXX_MAP_DOUBLE_ARRAY_DUMMY_HPP + +#include "grnxx/features.hpp" + +namespace grnxx { +namespace map { +namespace double_array { + +} // namespace double_array +} // namespace map +} // namespace grnxx + +#endif // GRNXX_MAP_DOUBLE_ARRAY_DUMMY_HPP Added: lib/grnxx/map/double_array/header.cpp (+33 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/double_array/header.cpp 2013-06-05 13:50:54 +0900 (274581b) @@ -0,0 +1,33 @@ +/* + Copyright (C) 2012-2013 Brazil, Inc. + + This library 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 (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include "grnxx/map/double_array/header.hpp" + +#include "grnxx/storage.hpp" + +namespace grnxx { +namespace map { +namespace double_array { + +Header::Header() + : map_type(MAP_ARRAY), + max_key_id(MAP_MIN_KEY_ID - 1), + num_keys(0) {} + +} // namespace double_array +} // namespace map +} // namespace grnxx Added: lib/grnxx/map/double_array/header.hpp (+42 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/double_array/header.hpp 2013-06-05 13:50:54 +0900 (b3b035a) @@ -0,0 +1,42 @@ +/* + Copyright (C) 2012-2013 Brazil, Inc. + + This library 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 (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef GRNXX_MAP_DOUBLE_ARRAY_HEADER_HPP +#define GRNXX_MAP_DOUBLE_ARRAY_HEADER_HPP + +#include "grnxx/features.hpp" + +#include "grnxx/map.hpp" +#include "grnxx/types.hpp" + +namespace grnxx { +namespace map { +namespace double_array { + +struct Header { + MapType map_type; + int64_t max_key_id; + uint64_t num_keys; + + Header(); +}; + +} // namespace double_array +} // namespace map +} // namespace grnxx + +#endif // GRNXX_MAP_DOUBLE_ARRAY_HEADER_HPP Modified: lib/grnxx/map/patricia.cpp (+7 -18) =================================================================== --- lib/grnxx/map/patricia.cpp 2013-06-05 13:36:17 +0900 (19edc88) +++ lib/grnxx/map/patricia.cpp 2013-06-05 13:50:54 +0900 (0267615) @@ -23,23 +23,12 @@ #include "grnxx/geo_point.hpp" #include "grnxx/logger.hpp" #include "grnxx/map/helper.hpp" +#include "grnxx/map/patricia/header.hpp" #include "grnxx/storage.hpp" namespace grnxx { namespace map { -struct PatriciaHeader { - // TODO - int64_t max_key_id; - uint64_t num_keys; - - PatriciaHeader(); -}; - -PatriciaHeader::PatriciaHeader() - : max_key_id(MAP_MIN_KEY_ID - 1), - num_keys(0) {} - template <typename T> Patricia<T>::Patricia() : storage_(nullptr), @@ -103,13 +92,13 @@ bool Patricia<T>::create_map(Storage *storage, uint32_t storage_node_id, const MapOptions &) { storage_ = storage; StorageNode storage_node = - storage->create_node(storage_node_id, sizeof(PatriciaHeader)); + storage->create_node(storage_node_id, sizeof(Header)); if (!storage_node) { return false; } storage_node_id_ = storage_node.id(); - header_ = static_cast<PatriciaHeader *>(storage_node.body()); - *header_ = PatriciaHeader(); + header_ = static_cast<Header *>(storage_node.body()); + *header_ = Header(); // TODO return false; } @@ -121,13 +110,13 @@ bool Patricia<T>::open_map(Storage *storage, uint32_t storage_node_id) { if (!storage_node) { return false; } - if (storage_node.size() < sizeof(PatriciaHeader)) { + if (storage_node.size() < sizeof(Header)) { GRNXX_ERROR() << "invalid format: size = " << storage_node.size() - << ", header_size = " << sizeof(PatriciaHeader); + << ", header_size = " << sizeof(Header); return false; } storage_node_id_ = storage_node_id; - header_ = static_cast<PatriciaHeader *>(storage_node.body()); + header_ = static_cast<Header *>(storage_node.body()); // TODO return false; } Modified: lib/grnxx/map/patricia.hpp (+9 -2) =================================================================== --- lib/grnxx/map/patricia.hpp 2013-06-05 13:36:17 +0900 (7ae45f4) +++ lib/grnxx/map/patricia.hpp 2013-06-05 13:50:54 +0900 (207da4a) @@ -26,13 +26,20 @@ #include "grnxx/types.hpp" namespace grnxx { + +class Storage; + namespace map { +namespace patricia { + +struct Header; -struct PatriciaHeader; +} // namespace patricia template <typename T> class Patricia : public Map<T> { public: + using Header = patricia::Header; using Key = typename Map<T>::Key; using KeyArg = typename Map<T>::KeyArg; using Cursor = typename Map<T>::Cursor; @@ -65,7 +72,7 @@ class Patricia : public Map<T> { private: Storage *storage_; uint32_t storage_node_id_; - PatriciaHeader *header_; + Header *header_; bool create_map(Storage *storage, uint32_t storage_node_id, const MapOptions &options); Added: lib/grnxx/map/patricia/Makefile.am (+12 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/patricia/Makefile.am 2013-06-05 13:50:54 +0900 (232d00b) @@ -0,0 +1,12 @@ +noinst_LTLIBRARIES = libgrnxx_map_patricia.la + +libgrnxx_map_patricia_la_LDFLAGS = @AM_LTLDFLAGS@ + +libgrnxx_map_patricia_la_SOURCES = \ + dummy.cpp \ + header.cpp + +libgrnxx_map_patricia_includedir = ${includedir}/grnxx/map/patricia +libgrnxx_map_patricia_include_HEADERS = \ + dummy.hpp \ + header.hpp Added: lib/grnxx/map/patricia/dummy.cpp (+28 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/patricia/dummy.cpp 2013-06-05 13:50:54 +0900 (c54fb55) @@ -0,0 +1,28 @@ +/* + Copyright (C) 2012-2013 Brazil, Inc. + + This library 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 (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include "grnxx/map/patricia/dummy.hpp" + +#include "grnxx/map/patricia/header.hpp" + +namespace grnxx { +namespace map { +namespace patricia { + +} // namespace patricia +} // namespace map +} // namespace grnxx Added: lib/grnxx/map/patricia/dummy.hpp (+31 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/patricia/dummy.hpp 2013-06-05 13:50:54 +0900 (3195d55) @@ -0,0 +1,31 @@ +/* + Copyright (C) 2012-2013 Brazil, Inc. + + This library 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 (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef GRNXX_MAP_PATRICIA_DUMMY_HPP +#define GRNXX_MAP_PATRICIA_DUMMY_HPP + +#include "grnxx/features.hpp" + +namespace grnxx { +namespace map { +namespace patricia { + +} // namespace patricia +} // namespace map +} // namespace grnxx + +#endif // GRNXX_MAP_PATRICIA_DUMMY_HPP Added: lib/grnxx/map/patricia/header.cpp (+33 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/patricia/header.cpp 2013-06-05 13:50:54 +0900 (5991821) @@ -0,0 +1,33 @@ +/* + Copyright (C) 2012-2013 Brazil, Inc. + + This library 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 (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include "grnxx/map/patricia/header.hpp" + +#include "grnxx/storage.hpp" + +namespace grnxx { +namespace map { +namespace patricia { + +Header::Header() + : map_type(MAP_ARRAY), + max_key_id(MAP_MIN_KEY_ID - 1), + num_keys(0) {} + +} // namespace patricia +} // namespace map +} // namespace grnxx Added: lib/grnxx/map/patricia/header.hpp (+42 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/patricia/header.hpp 2013-06-05 13:50:54 +0900 (ae0e474) @@ -0,0 +1,42 @@ +/* + Copyright (C) 2012-2013 Brazil, Inc. + + This library 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 (at your option) any later version. + + This library 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 this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef GRNXX_MAP_PATRICIA_HEADER_HPP +#define GRNXX_MAP_PATRICIA_HEADER_HPP + +#include "grnxx/features.hpp" + +#include "grnxx/map.hpp" +#include "grnxx/types.hpp" + +namespace grnxx { +namespace map { +namespace patricia { + +struct Header { + MapType map_type; + int64_t max_key_id; + uint64_t num_keys; + + Header(); +}; + +} // namespace patricia +} // namespace map +} // namespace grnxx + +#endif // GRNXX_MAP_PATRICIA_HEADER_HPP -------------- next part -------------- HTML����������������������������...Download