susumu.yata
null+****@clear*****
Wed May 15 13:27:26 JST 2013
susumu.yata 2013-05-15 13:27:26 +0900 (Wed, 15 May 2013) New Revision: 436e6ef709fd1d7de9f45c0c57a3fe3892b4c1bd https://github.com/groonga/grnxx/commit/436e6ef709fd1d7de9f45c0c57a3fe3892b4c1bd Message: Remove the old implementations of Map. Added files: lib/grnxx/map/array.cpp lib/grnxx/map/array.hpp lib/grnxx/map/cursor.cpp lib/grnxx/map/cursor.hpp lib/grnxx/map/scanner.cpp lib/grnxx/map/scanner.hpp obsolete/test/test_map obsolete/test/test_map_da_basic_trie obsolete/test/test_map_da_large_trie obsolete/test/test_map_double_array Copied files: obsolete/lib/grnxx/map.cpp (from lib/grnxx/map.cpp) obsolete/lib/grnxx/map.hpp (from lib/grnxx/map.hpp) obsolete/lib/grnxx/map/Makefile.am (from lib/grnxx/map/Makefile.am) obsolete/test/test_map.cpp (from test/test_map.cpp) Modified files: .gitignore configure.ac lib/grnxx/map.cpp lib/grnxx/map.hpp lib/grnxx/map/Makefile.am test/Makefile.am test/test_map.cpp Renamed files: obsolete/lib/grnxx/map/da/Makefile.am (from lib/grnxx/map/da/Makefile.am) obsolete/lib/grnxx/map/da/basic/Makefile.am (from lib/grnxx/map/da/basic/Makefile.am) obsolete/lib/grnxx/map/da/basic/id_cursor.cpp (from lib/grnxx/map/da/basic/id_cursor.cpp) obsolete/lib/grnxx/map/da/basic/id_cursor.hpp (from lib/grnxx/map/da/basic/id_cursor.hpp) obsolete/lib/grnxx/map/da/basic/key_cursor.cpp (from lib/grnxx/map/da/basic/key_cursor.cpp) obsolete/lib/grnxx/map/da/basic/key_cursor.hpp (from lib/grnxx/map/da/basic/key_cursor.hpp) obsolete/lib/grnxx/map/da/basic/predictive_cursor.cpp (from lib/grnxx/map/da/basic/predictive_cursor.cpp) obsolete/lib/grnxx/map/da/basic/predictive_cursor.hpp (from lib/grnxx/map/da/basic/predictive_cursor.hpp) obsolete/lib/grnxx/map/da/basic/prefix_cursor.cpp (from lib/grnxx/map/da/basic/prefix_cursor.cpp) obsolete/lib/grnxx/map/da/basic/prefix_cursor.hpp (from lib/grnxx/map/da/basic/prefix_cursor.hpp) obsolete/lib/grnxx/map/da/basic/trie.cpp (from lib/grnxx/map/da/basic/trie.cpp) obsolete/lib/grnxx/map/da/basic/trie.hpp (from lib/grnxx/map/da/basic/trie.hpp) obsolete/lib/grnxx/map/da/large/Makefile.am (from lib/grnxx/map/da/large/Makefile.am) obsolete/lib/grnxx/map/da/large/id_cursor.cpp (from lib/grnxx/map/da/large/id_cursor.cpp) obsolete/lib/grnxx/map/da/large/id_cursor.hpp (from lib/grnxx/map/da/large/id_cursor.hpp) obsolete/lib/grnxx/map/da/large/key_cursor.cpp (from lib/grnxx/map/da/large/key_cursor.cpp) obsolete/lib/grnxx/map/da/large/key_cursor.hpp (from lib/grnxx/map/da/large/key_cursor.hpp) obsolete/lib/grnxx/map/da/large/predictive_cursor.cpp (from lib/grnxx/map/da/large/predictive_cursor.cpp) obsolete/lib/grnxx/map/da/large/predictive_cursor.hpp (from lib/grnxx/map/da/large/predictive_cursor.hpp) obsolete/lib/grnxx/map/da/large/prefix_cursor.cpp (from lib/grnxx/map/da/large/prefix_cursor.cpp) obsolete/lib/grnxx/map/da/large/prefix_cursor.hpp (from lib/grnxx/map/da/large/prefix_cursor.hpp) obsolete/lib/grnxx/map/da/large/trie.cpp (from lib/grnxx/map/da/large/trie.cpp) obsolete/lib/grnxx/map/da/large/trie.hpp (from lib/grnxx/map/da/large/trie.hpp) obsolete/lib/grnxx/map/da/trie.cpp (from lib/grnxx/map/da/trie.cpp) obsolete/lib/grnxx/map/da/trie.hpp (from lib/grnxx/map/da/trie.hpp) obsolete/lib/grnxx/map/double_array.cpp (from lib/grnxx/map/double_array.cpp) obsolete/lib/grnxx/map/double_array.hpp (from lib/grnxx/map/double_array.hpp) obsolete/test/test_map_da_basic_trie.cpp (from test/test_map_da_basic_trie.cpp) obsolete/test/test_map_da_large_trie.cpp (from test/test_map_da_large_trie.cpp) obsolete/test/test_map_double_array.cpp (from test/test_map_double_array.cpp) Modified: .gitignore (+0 -3) =================================================================== --- .gitignore 2013-05-15 13:04:31 +0900 (a4bb95f) +++ .gitignore 2013-05-15 13:27:26 +0900 (c08c288) @@ -44,9 +44,6 @@ test/test_intrinsic test/test_io test/test_logger test/test_map -test/test_map_da_basic_trie -test/test_map_da_large_trie -test/test_map_double_array test/test_mutex test/test_os test/test_recycler Modified: configure.ac (+0 -3) =================================================================== --- configure.ac 2013-05-15 13:04:31 +0900 (b480a79) +++ configure.ac 2013-05-15 13:27:26 +0900 (9399c19) @@ -67,9 +67,6 @@ AC_CONFIG_FILES([Makefile lib/grnxx/db/Makefile lib/grnxx/io/Makefile lib/grnxx/map/Makefile - lib/grnxx/map/da/Makefile - lib/grnxx/map/da/basic/Makefile - lib/grnxx/map/da/large/Makefile lib/grnxx/storage/Makefile lib/grnxx/time/Makefile src/Makefile Modified: lib/grnxx/map.cpp (+1 -131) =================================================================== --- lib/grnxx/map.cpp 2013-05-15 13:04:31 +0900 (5126462) +++ lib/grnxx/map.cpp 2013-05-15 13:27:26 +0900 (8b41a34) @@ -17,138 +17,8 @@ */ #include "grnxx/map.hpp" -#include "grnxx/charset.hpp" -#include "grnxx/exception.hpp" -#include "grnxx/logger.hpp" -#include "grnxx/map/double_array.hpp" - namespace grnxx { -MapOptions::MapOptions() : type(MAP_UNKNOWN) {} - -MapHeader::MapHeader() : type(MAP_UNKNOWN) {} - -MapCursor::MapCursor() : key_id_(-1), key_() {} -MapCursor::~MapCursor() {} - -MapScan::~MapScan() {} - -MapScan *MapScan::open(Map *map, const Slice &query, const Charset *charset) { - std::unique_ptr<MapScan> scan(new (std::nothrow) MapScan); - if (!scan) { - GRNXX_ERROR() << "new grnxx::MapScan failed"; - GRNXX_THROW(); - } - scan->map_ = map; - scan->query_ = query; - scan->charset_ = charset; - return scan.release(); -} - -bool MapScan::next() { - offset_ += size_; - while (offset_ < query_.size()) { - const Slice query_left = query_.subslice(offset_, query_.size() - offset_); - if (map_->lcp_search(query_left, &key_id_, &key_)) { - size_ = key_.size(); - return true; - } - // Move to the next character. - if (charset_) { - offset_ += charset_->get_char_size(query_left); - } else { - ++offset_; - } - } - size_ = 0; - return false; -} - -MapScan::MapScan() - : map_(nullptr), - query_(), - offset_(0), - size_(0), - key_id_(-1), - key_() {} - -Map::Map() {} -Map::~Map() {} - -Map *Map::create(const MapOptions &options, io::Pool pool) { - switch (options.type) { - case MAP_UNKNOWN: { - break; - } - case MAP_DOUBLE_ARRAY: { - return map::DoubleArray::create(options, pool); - } - // TODO: Other map types will be supported in future. -// case ???: { -// return map::???::create(options, pool); -// } - } - - // TODO: Unknown type error! - return nullptr; -} - -Map *Map::open(io::Pool pool, uint32_t block_id) { - // Get the address to the header. - auto block_info = pool.get_block_info(block_id); - auto block_address = pool.get_block_address(*block_info); - auto header = static_cast<MapHeader *>(block_address); - - // Check the type. - MapType type = header->type; - - // Call the appropriate function. - switch (type) { - case MAP_UNKNOWN: { - break; - } - case MAP_DOUBLE_ARRAY: { - return map::DoubleArray::open(pool, block_id); - } - // TODO: Other map types will be supported in future. -// case ???: { -// return map::???::open(pool, block_id); -// } - } - - // TODO: Unknown type error! - return nullptr; -} - -void Map::unlink(io::Pool pool, uint32_t block_id) { - // Get the address to the header. - auto block_info = pool.get_block_info(block_id); - auto block_address = pool.get_block_address(*block_info); - auto header = static_cast<MapHeader *>(block_address); - - // Check the type. - MapType type = header->type; - - // Call the appropriate function. - switch (type) { - case MAP_UNKNOWN: { - break; - } - case MAP_DOUBLE_ARRAY: { - map::DoubleArray::unlink(pool, block_id); - return; - } - // TODO: Other map types will be supported in future. -// case ???: { -// return map::???::unlink(pool, block_id); -// } - } - - // TODO: Unknown type error! -} - -MapScan *Map::open_scan(const Slice &query, const Charset *charset) { - return MapScan::open(this, query, charset); -} +// TODO } // namespace grnxx Modified: lib/grnxx/map.hpp (+121 -188) =================================================================== --- lib/grnxx/map.hpp 2013-05-15 13:04:31 +0900 (ac99a3e) +++ lib/grnxx/map.hpp 2013-05-15 13:27:26 +0900 (be0070e) @@ -18,166 +18,177 @@ #ifndef GRNXX_MAP_HPP #define GRNXX_MAP_HPP -#include "grnxx/io/pool.hpp" -#include "grnxx/slice.hpp" +#include "grnxx/storage.hpp" +#include "grnxx/traits.hpp" namespace grnxx { class Charset; -class Map; + +namespace alpha { + +template <typename T> class Map; +template <typename T> class MapCursor; +template <typename T> class MapScan; enum MapType : int32_t { MAP_UNKNOWN = 0, - MAP_DOUBLE_ARRAY = 1 // grnxx::map::DoubleArray. + MAP_ARRAY = 1, // Array-based implementation. + MAP_DOUBLE_ARRAY = 2, // DoubleArray-based implementation. + MAP_PATRICIA = 3, // TODO: Patricia-based implementation. + MAP_HASH_TABLE = 4 // TODO: HashTable-based implementation. }; struct MapOptions { - MapType type; - - MapOptions(); }; -struct MapHeader { - MapType type; - - MapHeader(); +struct MapCursorFlagsIdentifier; +using MapCursorFlags = FlagsImpl<MapCursorFlagsIdentifier>; + +// Use the default settings. +constexpr MapCursorFlags MAP_CURSOR_DEFAULT = + MapCursorFlags::define(0x000); +// Sort keys by ID. +constexpr MapCursorFlags MAP_CURSOR_ORDER_BY_ID = + MapCursorFlags::define(0x001); +// Sort keys by key. +constexpr MapCursorFlags MAP_CURSOR_ORDER_BY_KEY = + MapCursorFlags::define(0x002); +// Access keys in reverse order. +constexpr MapCursorFlags MAP_CURSOR_REVERSE_ORDER = + MapCursorFlags::define(0x010); + +struct MapCursorOptions { + MapCursorFlags flags; + uint64_t offset; + uint64_t limit; + + MapCursorOptions() : flags(MAP_CURSOR_DEFAULT), offset(0), limit(-1) {} }; -// TODO: Dynamic memory allocation will be supported. -class MapKey { +template <typename T> +class Map { public: - // Create an empty (zero-size) key. - MapKey() : slice_() {} - // Create a key that refers to a zero-terminated string. - MapKey(const char *cstr) : slice_(cstr) {} - // Create a key. - MapKey(const void *ptr, size_t size) : slice_(ptr, size) {} - - // Disable copy. - MapKey(const MapKey &) = delete; - MapKey &operator=(const MapKey &) = delete; - - MapKey &operator=(const Slice &s) { - slice_ = s; - return *this; - } + using Value = typename Traits<T>::Type; + using ValueArg = typename Traits<T>::ArgumentType; - // Return true iff "*this" is not empty. - explicit operator bool() const { - return static_cast<bool>(slice_); - } + Map(); + virtual ~Map(); - // Make "*this" empty. - void clear() { - slice_.clear(); - } + // Create a map. + static Map *create(Storage *storage, uint32_t storage_node_id, + MapType type, const MapOptions &options = MapOptions()); + // Open a map. + static Map *open(Storage *storage, uint32_t storage_node_id); - // Compare "*this" and "s" and return a negative value if "*this" < "s", - // zero if "*this" == "s", or a positive value otherwise (if "*this" > "s"). - int compare(const Slice &s) const { - return slice_.compare(s); - } + // Unlink a map. + static bool unlink(Storage *storage, uint32_t storage_node_id); - // Return true iff "s" is a prefix of "*this". - bool starts_with(const Slice &s) const { - return slice_.starts_with(s); - } - // Return true iff "s" is a suffix of "*this". - bool ends_with(const Slice &s) const { - return slice_.ends_with(s); - } + // Return the storage node ID. + virtual uint32_t storage_node_id() const; + // Return the implementation type. + virtual MapType type() const; - // Return the "i"-th byte of "*this". - uint8_t operator[](size_t i) const { - return slice_[i]; + // Return the minimum key ID. + constexpr int64_t min_key_id() { + return 0; } + // Return the maximum key ID ever used. + // If the map is empty, the return value can be -1. + virtual int64_t max_key_id() const; + // Return the ID of the expected next inserted ID. + virtual int64_t next_key_id() const; + // Return the number of keys. + virtual uint64_t num_keys() const; - // Return the slice of "*this". - const Slice &slice() const { - return slice_; - } - // Return the starting address of "*this". - const void *address() const { - return slice_.address(); - } - // Return a pointer that refers to the starting address of "*this". - const uint8_t *ptr() const { - return slice_.ptr(); - } - // Return the size of "*this". - size_t size() const { - return slice_.size(); - } + // Get a key associated with "key_id" and return true on success. + // Assign the found key to "*key" iff "key" != nullptr. + virtual bool get(int64_t key_id, Value *key = nullptr); + // Find the next key and return true on success. The next key means the key + // associated with the smallest valid ID that is greater than "key_id". + // If "key_id" < 0, this finds the first key. + // Assign the ID to "*next_key_id" iff "next_key_id" != nullptr. + // Assign the key to "*next_key" iff "next_key" != nullptr. + virtual bool get_next(int64_t key_id, int64_t *next_key_id = nullptr, + Value *next_key = nullptr); + // Remove a key associated with "key_id" and return true on success. + virtual bool unset(int64_t key_id); + // Replace a key associated with "key_id" with "dest_key" and return true + // on success. + virtual bool reset(int64_t key_id, ValueArg dest_key); - private: - Slice slice_; -}; + // Find "key" and return true on success. + // Assign the ID to "*key_id" iff "key_id" != nullptr. + virtual bool find(ValueArg key, int64_t *key_id = nullptr); + // Insert "key" and return true on success. + // Assign the ID to "*key_id" iff "key_id" != nullptr. + virtual bool insert(ValueArg key, int64_t *key_id = nullptr); + // Remove "key" and return true on success. + virtual bool remove(ValueArg key); + // Replace "src_key" with "dest_key" and return true on success. + // Assign the ID to "*key_id" iff "key_id" != nullptr. + virtual bool update(ValueArg src_key, ValueArg dest_key, + int64_t *key_id = nullptr); + + // Perform the longest prefix matching and return true on success. + // Assign the ID to "*key_id" iff "key_id" != nullptr. + // Assign the key to "*key" iff "key" != nullptr. + virtual bool find_longest_prefix_match(ValueArg query, + int64_t *key_id = nullptr, + Value *key = nullptr); + + // Remove all the keys in "*this" and return true on success. + virtual bool truncate(); -inline bool operator==(const MapKey &lhs, const Slice &rhs) { - return lhs.slice() == rhs; -} + // TODO: Cursors. -inline bool operator!=(const MapKey &lhs, const Slice &rhs) { - return lhs.slice() != rhs; -} + // Only for Slice. + // Create a MapScan object to find keys in "query". + virtual MapScan<Value> *open_scan(ValueArg query, + const Charset *charset = nullptr); +}; +template <typename T> class MapCursor { public: + using Value = typename Traits<T>::Type; + using ValueArg = typename Traits<T>::ArgumentType; + MapCursor(); virtual ~MapCursor(); // Move the cursor to the next key and return true on success. - virtual bool next() = 0; - - // TODO + virtual bool next(); // Remove the current key and return true on success. -// virtual bool remove() = 0; + virtual bool remove(); // Return the ID of the current key. int64_t key_id() const { return key_id_; } // Return a reference to the current key. - const MapKey &key() const { + const Value &key() const { return key_; } protected: int64_t key_id_; - MapKey key_; + Value key_; }; -typedef FlagsImpl<MapCursor> MapCursorFlags; - -// Get keys in ascending order. -constexpr MapCursorFlags MAP_CURSOR_ASCENDING = - MapCursorFlags::define(0x01); -// Get keys in descending order. -constexpr MapCursorFlags MAP_CURSOR_DESCENDING = - MapCursorFlags::define(0x02); -// Get keys except "min". -constexpr MapCursorFlags MAP_CURSOR_EXCEPT_MIN = - MapCursorFlags::define(0x10); -// Get keys except "max". -constexpr MapCursorFlags MAP_CURSOR_EXCEPT_MAX = - MapCursorFlags::define(0x20); - +template <typename T> class MapScan { public: - ~MapScan(); + using Value = typename Traits<T>::Type; + using ValueArg = typename Traits<T>::ArgumentType; - // Create an object to find keys in "query". - static MapScan *open(Map *map, const Slice &query, - const Charset *charset = nullptr); + MapScan(); + virtual ~MapScan(); // Scan the rest of the query and return true iff a key is found (success). // On success, the found key is accessible via accessors. - bool next(); + virtual bool next() = 0; - // Return the query. - const Slice &query() const { - return query_; - } // Return the start position of the found key. uint64_t offset() const { return offset_; @@ -191,96 +202,18 @@ class MapScan { return key_id_; } // Return a reference to the found key. - const MapKey &key() const { + const Value &key() const { return key_; } protected: - Map *map_; - Slice query_; uint64_t offset_; uint64_t size_; int64_t key_id_; - MapKey key_; - const Charset *charset_; - - MapScan(); -}; - -class Map { - public: - Map(); - virtual ~Map(); - - // Create a map on "pool". - static Map *create(const MapOptions &options, io::Pool pool); - // Open a map. - static Map *open(io::Pool pool, uint32_t block_id); - - // Remove blocks allocated to a map. - static void unlink(io::Pool pool, uint32_t block_id); - - // Return the header block ID of "*this". - virtual uint32_t block_id() const = 0; - - // Search the key associated with "key_id" and return true on success. - // Assign the found key to "*key" iff "key" != nullptr. - virtual bool search(int64_t key_id, MapKey *key = nullptr) = 0; - // Search "key" and return true on success. - // Assign the ID to "*key_id" iff "key_id" != nullptr. - virtual bool search(const Slice &key, int64_t *key_id = nullptr) = 0; - - // Search a prefix key of "query" and return true on success. - // Assign the longest prefix key to "*key" iff "key" != nullptr. - // Assign the ID to "*key_id" iff "key_id" != nullptr. - virtual bool lcp_search(const Slice &query, int64_t *key_id = nullptr, - MapKey *key = nullptr) = 0; - - // Insert "key" and return true on success. - // Assign the ID to "*key_id" iff "key_id" != nullptr. - virtual bool insert(const Slice &key, int64_t *key_id = nullptr) = 0; - - // Remove the key associated with "key_id" and return true on success. - virtual bool remove(int64_t key_id) = 0; - // Remove "key" and return true on success. - virtual bool remove(const Slice &key) = 0; - - // Replace the key associated with "key_id" with "dest_key" and return true - // on success. - virtual bool update(int64_t key_id, const Slice &dest_key) = 0; - // Replace "src_key" with "dest_key" and return true on success. - // Assign the ID to "*key_id" iff "key_id" != nullptr. - virtual bool update(const Slice &src_key, const Slice &dest_key, - int64_t *key_id = nullptr) = 0; - - // Start scan to find keys in "query" and return an object for the scan. - // The object must be deleted after the scan. - MapScan *open_scan(const Slice &query, const Charset *charset = nullptr); - - // Find keys in an ID range ["min", "max"] and return the keys in ID order. - // "flags" accepts MAP_CURSOR_ASCENDING, MAP_CURSOR_DESCENDING, - // MAP_CURSOR_EXCEPT_MIN, and MAP_CURSOR_EXCEPT_MAX. - virtual MapCursor *open_id_cursor(MapCursorFlags flags, - int64_t min, int64_t max, - int64_t offset, int64_t limit) = 0; - // Find keys in a range ["min", "max"] and return the keys in lexicographic - // order. "flags" accepts MAP_CURSOR_ASCENDING, MAP_CURSOR_DESCENDING, - // MAP_CURSOR_EXCEPT_MIN, and MAP_CURSOR_EXCEPT_MAX. - virtual MapCursor *open_key_cursor(MapCursorFlags flags, - const Slice &min, const Slice &max, - int64_t offset, int64_t limit) = 0; - // Find keys in prefixes of "max". "flags" accepts MAP_CURSOR_ASCENDING, - // MAP_CURSOR_DESCENDING, MAP_CURSOR_EXCEPT_MIN, and MAP_CURSOR_EXCEPT_MAX. - virtual MapCursor *open_prefix_cursor(MapCursorFlags flags, - size_t min, const Slice &max, - int64_t offset, int64_t limit) = 0; - // Find keys starting with "min". "flags" accepts MAP_CURSOR_ASCENDING, - // MAP_CURSOR_DESCENDING, and MAP_CURSOR_EXCEPT_MIN. - virtual MapCursor *open_predictive_cursor(MapCursorFlags flags, - const Slice &min, - int64_t offset, int64_t limit) = 0; + Value key_; }; +} // namespace alpha } // namespace grnxx #endif // GRNXX_MAP_HPP Modified: lib/grnxx/map/Makefile.am (+6 -7) =================================================================== --- lib/grnxx/map/Makefile.am 2013-05-15 13:04:31 +0900 (53c2fe3) +++ lib/grnxx/map/Makefile.am 2013-05-15 13:27:26 +0900 (4bd9e46) @@ -1,15 +1,14 @@ -SUBDIRS = da - noinst_LTLIBRARIES = libgrnxx_map.la -libgrnxx_map_la_LIBADD = \ - da/libgrnxx_map_da.la - libgrnxx_map_la_LDFLAGS = @AM_LTLDFLAGS@ libgrnxx_map_la_SOURCES = \ - double_array.cpp + array.cpp \ + cursor.cpp \ + scanner.cpp libgrnxx_map_includedir = ${includedir}/grnxx/map libgrnxx_map_include_HEADERS = \ - double_array.hpp + array.hpp \ + cursor.hpp \ + scanner.hpp Added: lib/grnxx/map/array.cpp (+24 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/array.cpp 2013-05-15 13:27:26 +0900 (5c60f41) @@ -0,0 +1,24 @@ +/* + Copyright (C) 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/array.hpp" + +namespace grnxx { +namespace map { + +} // namespace map +} // namespace grnxx Added: lib/grnxx/map/array.hpp (+29 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/array.hpp 2013-05-15 13:27:26 +0900 (0b9011b) @@ -0,0 +1,29 @@ +/* + Copyright (C) 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_ARRAY_HPP +#define GRNXX_MAP_ARRAY_HPP + +#include "grnxx/features.hpp" + +namespace grnxx { +namespace map { + +} // namespace map +} // namespace grnxx + +#endif // GRNXX_MAP_ARRAY_HPP Added: lib/grnxx/map/cursor.cpp (+24 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/cursor.cpp 2013-05-15 13:27:26 +0900 (6e6c0d9) @@ -0,0 +1,24 @@ +/* + Copyright (C) 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/cursor.hpp" + +namespace grnxx { +namespace map { + +} // namespace map +} // namespace grnxx Added: lib/grnxx/map/cursor.hpp (+29 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/cursor.hpp 2013-05-15 13:27:26 +0900 (5ac9df5) @@ -0,0 +1,29 @@ +/* + Copyright (C) 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_CURSOR_HPP +#define GRNXX_MAP_CURSOR_HPP + +#include "grnxx/features.hpp" + +namespace grnxx { +namespace map { + +} // namespace map +} // namespace grnxx + +#endif // GRNXX_MAP_CURSOR_HPP Added: lib/grnxx/map/scanner.cpp (+24 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/scanner.cpp 2013-05-15 13:27:26 +0900 (8264259) @@ -0,0 +1,24 @@ +/* + Copyright (C) 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/scanner.hpp" + +namespace grnxx { +namespace map { + +} // namespace map +} // namespace grnxx Added: lib/grnxx/map/scanner.hpp (+29 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/scanner.hpp 2013-05-15 13:27:26 +0900 (c91cbc9) @@ -0,0 +1,29 @@ +/* + Copyright (C) 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_SCANNER_HPP +#define GRNXX_MAP_SCANNER_HPP + +#include "grnxx/features.hpp" + +namespace grnxx { +namespace map { + +} // namespace map +} // namespace grnxx + +#endif // GRNXX_MAP_SCANNER_HPP Copied: obsolete/lib/grnxx/map.cpp (+0 -0) 100% =================================================================== Copied: obsolete/lib/grnxx/map.hpp (+0 -0) 100% =================================================================== Copied: obsolete/lib/grnxx/map/Makefile.am (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/Makefile.am (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/Makefile.am (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/id_cursor.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/id_cursor.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/key_cursor.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/key_cursor.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/predictive_cursor.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/predictive_cursor.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/prefix_cursor.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/prefix_cursor.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/trie.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/basic/trie.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/Makefile.am (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/id_cursor.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/id_cursor.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/key_cursor.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/key_cursor.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/predictive_cursor.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/predictive_cursor.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/prefix_cursor.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/prefix_cursor.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/trie.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/large/trie.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/trie.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/da/trie.hpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/double_array.cpp (+0 -0) 100% =================================================================== Renamed: obsolete/lib/grnxx/map/double_array.hpp (+0 -0) 100% =================================================================== Added: obsolete/test/test_map (+228 -0) 100755 =================================================================== --- /dev/null +++ obsolete/test/test_map 2013-05-15 13:27:26 +0900 (e5c08f7) @@ -0,0 +1,228 @@ +#! /bin/bash + +# test_map - temporary wrapper script for .libs/test_map +# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 +# +# The test_map program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /home/s-yata/git/grnxx/test; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games; export PATH; clang++ -Wall -Wextra -std=c++11 -fno-strict-aliasing -I../lib -pthread -g -O2 -o \$progdir/\$file test_map.o ../lib/grnxx/.libs/libgrnxx.so -lpthread -lrt -lbfd -pthread -Wl,-rpath -Wl,/home/s-yata/git/grnxx/lib/grnxx/.libs)" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variables: + generated_by_libtool_version='2.4.2' + notinst_deplibs=' ../lib/grnxx/libgrnxx.la' +else + # When we are sourced in execute mode, $file and $ECHO are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + file="$0" + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + ECHO="printf %s\\n" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ which is used only on +# windows platforms, and (c) all begin with the string --lt- +# (application programs are unlikely to have options which match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's ../libtool value, followed by no. +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=$0 + shift + for lt_opt + do + case "$lt_opt" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` + test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. + lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` + cat "$lt_dump_D/$lt_dump_F" + exit 0 + ;; + --lt-*) + $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n "$lt_option_debug"; then + echo "test_map:test_map:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + $ECHO "test_map:test_map:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" + lt_dump_args_N=`expr $lt_dump_args_N + 1` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ + + if test -n "$lt_option_debug"; then + $ECHO "test_map:test_map:${LINENO}: newargv[0]: $progdir/$program" 1>&2 + func_lt_dump_args ${1+"$@"} 1>&2 + fi + exec "$progdir/$program" ${1+"$@"} + + $ECHO "$0: cannot exec $program $*" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from $@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case " $* " in + *\ --lt-*) + for lt_wr_arg + do + case $lt_wr_arg in + --lt-*) ;; + *) set x "$@" "$lt_wr_arg"; shift;; + esac + shift + done ;; + esac + func_exec_program_core ${1+"$@"} +} + + # Parse options + func_parse_lt_options "$0" ${1+"$@"} + + # Find the directory that this script lives in. + thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no + if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then + # special case for '.' + if test "$thisdir" = "."; then + thisdir=`pwd` + fi + # remove .libs from thisdir + case "$thisdir" in + *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; + .libs ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'test_map' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + printf %s\n "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + func_exec_program ${1+"$@"} + fi + else + # The program doesn't exist. + $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 + $ECHO "This script is just a wrapper for $program." 1>&2 + $ECHO "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi Copied: obsolete/test/test_map.cpp (+0 -0) 100% =================================================================== Added: obsolete/test/test_map_da_basic_trie (+228 -0) 100755 =================================================================== --- /dev/null +++ obsolete/test/test_map_da_basic_trie 2013-05-15 13:27:26 +0900 (25d2647) @@ -0,0 +1,228 @@ +#! /bin/bash + +# test_map_da_basic_trie - temporary wrapper script for .libs/test_map_da_basic_trie +# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 +# +# The test_map_da_basic_trie program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /home/s-yata/git/grnxx/test; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games; export PATH; clang++ -Wall -Wextra -std=c++11 -fno-strict-aliasing -I../lib -pthread -g -O2 -o \$progdir/\$file test_map_da_basic_trie.o ../lib/grnxx/.libs/libgrnxx.so -lpthread -lrt -lbfd -pthread -Wl,-rpath -Wl,/home/s-yata/git/grnxx/lib/grnxx/.libs)" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variables: + generated_by_libtool_version='2.4.2' + notinst_deplibs=' ../lib/grnxx/libgrnxx.la' +else + # When we are sourced in execute mode, $file and $ECHO are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + file="$0" + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + ECHO="printf %s\\n" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ which is used only on +# windows platforms, and (c) all begin with the string --lt- +# (application programs are unlikely to have options which match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's ../libtool value, followed by no. +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=$0 + shift + for lt_opt + do + case "$lt_opt" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` + test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. + lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` + cat "$lt_dump_D/$lt_dump_F" + exit 0 + ;; + --lt-*) + $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n "$lt_option_debug"; then + echo "test_map_da_basic_trie:test_map_da_basic_trie:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + $ECHO "test_map_da_basic_trie:test_map_da_basic_trie:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" + lt_dump_args_N=`expr $lt_dump_args_N + 1` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ + + if test -n "$lt_option_debug"; then + $ECHO "test_map_da_basic_trie:test_map_da_basic_trie:${LINENO}: newargv[0]: $progdir/$program" 1>&2 + func_lt_dump_args ${1+"$@"} 1>&2 + fi + exec "$progdir/$program" ${1+"$@"} + + $ECHO "$0: cannot exec $program $*" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from $@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case " $* " in + *\ --lt-*) + for lt_wr_arg + do + case $lt_wr_arg in + --lt-*) ;; + *) set x "$@" "$lt_wr_arg"; shift;; + esac + shift + done ;; + esac + func_exec_program_core ${1+"$@"} +} + + # Parse options + func_parse_lt_options "$0" ${1+"$@"} + + # Find the directory that this script lives in. + thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no + if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then + # special case for '.' + if test "$thisdir" = "."; then + thisdir=`pwd` + fi + # remove .libs from thisdir + case "$thisdir" in + *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; + .libs ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'test_map_da_basic_trie' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + printf %s\n "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + func_exec_program ${1+"$@"} + fi + else + # The program doesn't exist. + $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 + $ECHO "This script is just a wrapper for $program." 1>&2 + $ECHO "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi Renamed: obsolete/test/test_map_da_basic_trie.cpp (+0 -0) 100% =================================================================== Added: obsolete/test/test_map_da_large_trie (+228 -0) 100755 =================================================================== --- /dev/null +++ obsolete/test/test_map_da_large_trie 2013-05-15 13:27:26 +0900 (cd4cef7) @@ -0,0 +1,228 @@ +#! /bin/bash + +# test_map_da_large_trie - temporary wrapper script for .libs/test_map_da_large_trie +# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 +# +# The test_map_da_large_trie program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /home/s-yata/git/grnxx/test; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games; export PATH; clang++ -Wall -Wextra -std=c++11 -fno-strict-aliasing -I../lib -pthread -g -O2 -o \$progdir/\$file test_map_da_large_trie.o ../lib/grnxx/.libs/libgrnxx.so -lpthread -lrt -lbfd -pthread -Wl,-rpath -Wl,/home/s-yata/git/grnxx/lib/grnxx/.libs)" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variables: + generated_by_libtool_version='2.4.2' + notinst_deplibs=' ../lib/grnxx/libgrnxx.la' +else + # When we are sourced in execute mode, $file and $ECHO are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + file="$0" + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + ECHO="printf %s\\n" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ which is used only on +# windows platforms, and (c) all begin with the string --lt- +# (application programs are unlikely to have options which match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's ../libtool value, followed by no. +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=$0 + shift + for lt_opt + do + case "$lt_opt" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` + test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. + lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` + cat "$lt_dump_D/$lt_dump_F" + exit 0 + ;; + --lt-*) + $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n "$lt_option_debug"; then + echo "test_map_da_large_trie:test_map_da_large_trie:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + $ECHO "test_map_da_large_trie:test_map_da_large_trie:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" + lt_dump_args_N=`expr $lt_dump_args_N + 1` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ + + if test -n "$lt_option_debug"; then + $ECHO "test_map_da_large_trie:test_map_da_large_trie:${LINENO}: newargv[0]: $progdir/$program" 1>&2 + func_lt_dump_args ${1+"$@"} 1>&2 + fi + exec "$progdir/$program" ${1+"$@"} + + $ECHO "$0: cannot exec $program $*" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from $@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case " $* " in + *\ --lt-*) + for lt_wr_arg + do + case $lt_wr_arg in + --lt-*) ;; + *) set x "$@" "$lt_wr_arg"; shift;; + esac + shift + done ;; + esac + func_exec_program_core ${1+"$@"} +} + + # Parse options + func_parse_lt_options "$0" ${1+"$@"} + + # Find the directory that this script lives in. + thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no + if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then + # special case for '.' + if test "$thisdir" = "."; then + thisdir=`pwd` + fi + # remove .libs from thisdir + case "$thisdir" in + *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; + .libs ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'test_map_da_large_trie' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + printf %s\n "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + func_exec_program ${1+"$@"} + fi + else + # The program doesn't exist. + $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 + $ECHO "This script is just a wrapper for $program." 1>&2 + $ECHO "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi Renamed: obsolete/test/test_map_da_large_trie.cpp (+0 -0) 100% =================================================================== Added: obsolete/test/test_map_double_array (+228 -0) 100755 =================================================================== --- /dev/null +++ obsolete/test/test_map_double_array 2013-05-15 13:27:26 +0900 (07c4a8a) @@ -0,0 +1,228 @@ +#! /bin/bash + +# test_map_double_array - temporary wrapper script for .libs/test_map_double_array +# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 +# +# The test_map_double_array program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /home/s-yata/git/grnxx/test; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games; export PATH; clang++ -Wall -Wextra -std=c++11 -fno-strict-aliasing -I../lib -pthread -g -O2 -o \$progdir/\$file test_map_double_array.o ../lib/grnxx/.libs/libgrnxx.so -lpthread -lrt -lbfd -pthread -Wl,-rpath -Wl,/home/s-yata/git/grnxx/lib/grnxx/.libs)" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variables: + generated_by_libtool_version='2.4.2' + notinst_deplibs=' ../lib/grnxx/libgrnxx.la' +else + # When we are sourced in execute mode, $file and $ECHO are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + file="$0" + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + ECHO="printf %s\\n" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ which is used only on +# windows platforms, and (c) all begin with the string --lt- +# (application programs are unlikely to have options which match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's ../libtool value, followed by no. +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=$0 + shift + for lt_opt + do + case "$lt_opt" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` + test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. + lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` + cat "$lt_dump_D/$lt_dump_F" + exit 0 + ;; + --lt-*) + $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n "$lt_option_debug"; then + echo "test_map_double_array:test_map_double_array:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + $ECHO "test_map_double_array:test_map_double_array:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" + lt_dump_args_N=`expr $lt_dump_args_N + 1` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ + + if test -n "$lt_option_debug"; then + $ECHO "test_map_double_array:test_map_double_array:${LINENO}: newargv[0]: $progdir/$program" 1>&2 + func_lt_dump_args ${1+"$@"} 1>&2 + fi + exec "$progdir/$program" ${1+"$@"} + + $ECHO "$0: cannot exec $program $*" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from $@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case " $* " in + *\ --lt-*) + for lt_wr_arg + do + case $lt_wr_arg in + --lt-*) ;; + *) set x "$@" "$lt_wr_arg"; shift;; + esac + shift + done ;; + esac + func_exec_program_core ${1+"$@"} +} + + # Parse options + func_parse_lt_options "$0" ${1+"$@"} + + # Find the directory that this script lives in. + thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no + if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then + # special case for '.' + if test "$thisdir" = "."; then + thisdir=`pwd` + fi + # remove .libs from thisdir + case "$thisdir" in + *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; + .libs ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'test_map_double_array' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + printf %s\n "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + func_exec_program ${1+"$@"} + fi + else + # The program doesn't exist. + $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 + $ECHO "This script is just a wrapper for $program." 1>&2 + $ECHO "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi Renamed: obsolete/test/test_map_double_array.cpp (+0 -0) 100% =================================================================== Modified: test/Makefile.am (+0 -12) =================================================================== --- test/Makefile.am 2013-05-15 13:04:31 +0900 (887bb44) +++ test/Makefile.am 2013-05-15 13:27:26 +0900 (b8192a0) @@ -18,9 +18,6 @@ TESTS = \ test_io \ test_logger \ test_map \ - test_map_double_array \ - test_map_da_basic_trie \ - test_map_da_large_trie \ test_mutex \ test_os \ test_recycler \ @@ -85,15 +82,6 @@ test_logger_LDADD = ../lib/grnxx/libgrnxx.la test_map_SOURCES = test_map.cpp test_map_LDADD = ../lib/grnxx/libgrnxx.la -test_map_double_array_SOURCES = test_map_double_array.cpp -test_map_double_array_LDADD = ../lib/grnxx/libgrnxx.la - -test_map_da_basic_trie_SOURCES = test_map_da_basic_trie.cpp -test_map_da_basic_trie_LDADD = ../lib/grnxx/libgrnxx.la - -test_map_da_large_trie_SOURCES = test_map_da_large_trie.cpp -test_map_da_large_trie_LDADD = ../lib/grnxx/libgrnxx.la - test_mutex_SOURCES = test_mutex.cpp test_mutex_LDADD = ../lib/grnxx/libgrnxx.la Modified: test/test_map.cpp (+5 -382) =================================================================== --- test/test_map.cpp 2013-05-15 13:04:31 +0900 (d7bee52) +++ test/test_map.cpp 2013-05-15 13:27:26 +0900 (e2c36ec) @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Brazil, Inc. + 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 @@ -16,398 +16,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <cassert> -#include <random> -#include <string> -#include <unordered_set> -#include <vector> -#include "grnxx/charset.hpp" -#include "grnxx/map.hpp" #include "grnxx/logger.hpp" -#include "grnxx/time/time.hpp" -void test_basics() { - grnxx::io::Pool pool; - pool.open(grnxx::io::POOL_TEMPORARY); +namespace { - grnxx::MapOptions options; - options.type = grnxx::MAP_DOUBLE_ARRAY; - std::unique_ptr<grnxx::Map> map(grnxx::Map::create(options, pool)); +// TODO - std::vector<grnxx::Slice> keys; - keys.push_back("apple"); - keys.push_back("banana"); - keys.push_back("strawberry"); - - for (std::size_t i = 0; i < keys.size(); ++i) { - assert(!map->search(keys[i])); - } - - for (std::size_t i = 0; i < keys.size(); ++i) { - std::int64_t key_id; - assert(map->insert(keys[i], &key_id)); - assert(key_id == static_cast<std::int64_t>(i)); - } - - for (std::size_t i = 0; i < keys.size(); ++i) { - std::int64_t key_id; - assert(map->search(keys[i], &key_id)); - assert(key_id == static_cast<std::int64_t>(i)); - } - - const std::uint32_t block_id = map->block_id(); - map.reset(grnxx::Map::open(pool, block_id)); - - for (std::size_t i = 0; i < keys.size(); ++i) { - assert(!map->insert(keys[i])); - } - - for (std::size_t i = 0; i < keys.size(); ++i) { - assert(map->remove(keys[i])); - } - - for (std::size_t i = 0; i < keys.size(); ++i) { - assert(!map->search(keys[i])); - } - - for (std::size_t i = 0; i < keys.size(); ++i) { - assert(!map->remove(keys[i])); - } - - for (std::size_t i = 0; i < keys.size(); ++i) { - assert(map->insert(keys[i])); - } - - std::vector<grnxx::Slice> new_keys; - new_keys.push_back("dog"); - new_keys.push_back("monkey"); - new_keys.push_back("bird"); - - for (std::size_t i = 0; i < keys.size(); ++i) { - assert(map->update(keys[i], new_keys[i])); - } - - for (std::size_t i = 0; i < keys.size(); ++i) { - assert(!map->search(keys[i])); - assert(map->search(new_keys[i])); - } -} - -void test_lcp_search() { - grnxx::io::Pool pool; - pool.open(grnxx::io::POOL_TEMPORARY); - - grnxx::MapOptions options; - options.type = grnxx::MAP_DOUBLE_ARRAY; - std::unique_ptr<grnxx::Map> map(grnxx::Map::create(options, pool)); - - assert(map->insert("AB")); - assert(map->insert("ABCD")); - assert(map->insert("ABE")); - - std::int64_t key_id; - grnxx::MapKey key; - - assert(!map->lcp_search("", &key_id, &key)); - assert(!map->lcp_search("A", &key_id, &key)); - assert(map->lcp_search("AB", &key_id, &key)); - assert(key_id == 0); - assert(key == "AB"); - assert(map->lcp_search("ABC", &key_id, &key)); - assert(key_id == 0); - assert(key == "AB"); - assert(map->lcp_search("ABCD", &key_id, &key)); - assert(key_id == 1); - assert(key == "ABCD"); - assert(map->lcp_search("ABCDE", &key_id, &key)); - assert(key_id == 1); - assert(key == "ABCD"); - assert(map->lcp_search("ABE", &key_id, &key)); - assert(key_id == 2); - assert(key == "ABE"); - assert(map->lcp_search("ABEF", &key_id, &key)); - assert(key_id == 2); - assert(key == "ABE"); - assert(!map->lcp_search("BCD", &key_id, &key)); -} - -void test_scan() { - grnxx::io::Pool pool; - pool.open(grnxx::io::POOL_TEMPORARY); - - grnxx::MapOptions options; - options.type = grnxx::MAP_DOUBLE_ARRAY; - std::unique_ptr<grnxx::Map> map(grnxx::Map::create(options, pool)); - - assert(map->insert("AB")); - assert(map->insert("ABCD")); - assert(map->insert("BCD")); - assert(map->insert("CDE")); - assert(map->insert("EF")); - assert(map->insert("EFG")); - assert(map->insert("EFGH")); - assert(map->insert("FG")); - - grnxx::Slice query = "ABCDXEFG"; - - std::unique_ptr<grnxx::MapScan> scan(map->open_scan(query)); - - assert(scan->next()); - assert(scan->offset() == 0); - assert(scan->size() == 4); - assert(scan->key_id() == 1); - assert(scan->key() == "ABCD"); - - assert(scan->next()); - assert(scan->offset() == 5); - assert(scan->size() == 3); - assert(scan->key_id() == 5); - assert(scan->key() == "EFG"); - - assert(!scan->next()); - - scan.reset(map->open_scan( - query, grnxx::Charset::get(grnxx::CHARSET_UTF_8))); - - assert(scan->next()); - assert(scan->offset() == 0); - assert(scan->size() == 4); - assert(scan->key_id() == 1); - assert(scan->key() == "ABCD"); - - assert(scan->next()); - assert(scan->offset() == 5); - assert(scan->size() == 3); - assert(scan->key_id() == 5); - assert(scan->key() == "EFG"); - - assert(!scan->next()); - - map.reset(grnxx::Map::create(options, pool)); - - assert(map->insert("今")); - assert(map->insert("今日")); - assert(map->insert("明日")); - assert(map->insert("良い")); - assert(map->insert("悪い")); - assert(map->insert("天気")); - assert(map->insert("です")); - - query = "今日は良い天気ですね"; - - scan.reset(map->open_scan( - query, grnxx::Charset::get(grnxx::CHARSET_UTF_8))); - - assert(scan->next()); - assert(scan->offset() == 0); - assert(scan->size() == 6); - assert(scan->key_id() == 1); - assert(scan->key() == "今日"); - - assert(scan->next()); - assert(scan->offset() == 9); - assert(scan->size() == 6); - assert(scan->key_id() == 3); - assert(scan->key() == "良い"); - - assert(scan->next()); - assert(scan->offset() == 15); - assert(scan->size() == 6); - assert(scan->key_id() == 5); - assert(scan->key() == "天気"); - - assert(scan->next()); - assert(scan->offset() == 21); - assert(scan->size() == 6); - assert(scan->key_id() == 6); - assert(scan->key() == "です"); - - assert(!scan->next()); -} - -void create_keys(std::size_t num_keys, - std::size_t min_size, std::size_t max_size, - std::unordered_set<std::string> *both_keys, - std::vector<grnxx::Slice> *true_keys, - std::vector<grnxx::Slice> *false_keys) { - both_keys->clear(); - true_keys->resize(num_keys); - false_keys->resize(num_keys); - { - while (both_keys->size() < (num_keys * 2)) { - std::string key; - key.resize(min_size + (random() % (max_size - min_size + 1))); - for (std::size_t i = 0; i < key.size(); ++i) { - key[i] = '0' + (random() % 10); - } - both_keys->insert(key); - } - auto it = both_keys->begin(); - for (std::size_t i = 0; i < num_keys; ++i) { - (*true_keys)[i] = grnxx::Slice(it->data(), it->size()); - ++it; - (*false_keys)[i] = grnxx::Slice(it->data(), it->size()); - ++it; - } - } -} - -void test_insert() { - constexpr std::size_t NUM_KEYS = 1 << 16; - constexpr std::size_t MIN_SIZE = 1; - constexpr std::size_t MAX_SIZE = 10; - - std::mt19937 random; - - grnxx::io::Pool pool; - pool.open(grnxx::io::POOL_TEMPORARY); - - grnxx::MapOptions options; - options.type = grnxx::MAP_DOUBLE_ARRAY; - std::unique_ptr<grnxx::Map> map(grnxx::Map::create(options, pool)); - - std::unordered_set<std::string> both_keys; - std::vector<grnxx::Slice> true_keys; - std::vector<grnxx::Slice> false_keys; - create_keys(NUM_KEYS, MIN_SIZE, MAX_SIZE, - &both_keys, &true_keys, &false_keys); - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - std::int64_t key_id; - assert(map->insert(true_keys[i], &key_id)); - assert(key_id == static_cast<std::int64_t>(i)); - - assert(!map->insert(true_keys[i], &key_id)); - - key_id = i + 1; - assert(map->search(true_keys[i], &key_id)); - assert(key_id == static_cast<std::int64_t>(i)); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - std::int64_t key_id; - assert(map->search(true_keys[i], &key_id)); - assert(key_id == static_cast<std::int64_t>(i)); - - assert(!map->search(false_keys[i], &key_id)); - } -} - -void test_remove() { - constexpr std::size_t NUM_KEYS = 1 << 16; - constexpr std::size_t MIN_SIZE = 1; - constexpr std::size_t MAX_SIZE = 10; - - std::mt19937 random; - - grnxx::io::Pool pool; - pool.open(grnxx::io::POOL_TEMPORARY); - - grnxx::MapOptions options; - options.type = grnxx::MAP_DOUBLE_ARRAY; - std::unique_ptr<grnxx::Map> map(grnxx::Map::create(options, pool)); - - std::unordered_set<std::string> both_keys; - std::vector<grnxx::Slice> true_keys; - std::vector<grnxx::Slice> false_keys; - create_keys(NUM_KEYS, MIN_SIZE, MAX_SIZE, - &both_keys, &true_keys, &false_keys); - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - std::int64_t key_id; - assert(map->insert(true_keys[i], &key_id)); - assert(key_id == static_cast<std::int64_t>(i * 2)); - assert(map->insert(false_keys[i], &key_id)); - assert(key_id == static_cast<std::int64_t>((i * 2) + 1)); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - assert(map->remove((i * 2) + 1)); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - assert(map->search(true_keys[i])); - assert(!map->search(false_keys[i])); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - assert(map->insert(false_keys[i])); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - assert(map->search(true_keys[i])); - assert(map->search(false_keys[i])); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - assert(map->remove(false_keys[i])); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - assert(map->search(true_keys[i])); - assert(!map->search(false_keys[i])); - } -} - -void test_update() { - constexpr std::size_t NUM_KEYS = 1 << 16; - constexpr std::size_t MIN_SIZE = 1; - constexpr std::size_t MAX_SIZE = 10; - - std::mt19937 random; - - grnxx::io::Pool pool; - pool.open(grnxx::io::POOL_TEMPORARY); - - grnxx::MapOptions options; - options.type = grnxx::MAP_DOUBLE_ARRAY; - std::unique_ptr<grnxx::Map> map(grnxx::Map::create(options, pool)); - - std::unordered_set<std::string> both_keys; - std::vector<grnxx::Slice> true_keys; - std::vector<grnxx::Slice> false_keys; - create_keys(NUM_KEYS, MIN_SIZE, MAX_SIZE, - &both_keys, &true_keys, &false_keys); - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - std::int64_t key_id; - assert(map->insert(true_keys[i], &key_id)); - assert(key_id == static_cast<std::int64_t>(i)); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - assert(!map->update(i, true_keys[i])); - assert(map->update(i, false_keys[i])); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - assert(!map->search(true_keys[i])); - assert(map->search(false_keys[i])); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - assert(!map->update(true_keys[i], false_keys[i])); - assert(map->update(false_keys[i], true_keys[i])); - } - - for (std::size_t i = 0; i < NUM_KEYS; ++i) { - assert(map->search(true_keys[i])); - assert(!map->search(false_keys[i])); - } -} +} // namespace int main() { grnxx::Logger::set_flags(grnxx::LOGGER_WITH_ALL | grnxx::LOGGER_ENABLE_COUT); grnxx::Logger::set_max_level(grnxx::NOTICE_LOGGER); - test_basics(); - test_lcp_search(); - test_scan(); - - test_insert(); - test_remove(); - test_update(); + // TODO return 0; }