susumu.yata
null+****@clear*****
Wed May 15 18:29:02 JST 2013
susumu.yata 2013-05-15 18:29:02 +0900 (Wed, 15 May 2013) New Revision: 2797057a2ab95caeb0167bd530931a7d48479a81 https://github.com/groonga/grnxx/commit/2797057a2ab95caeb0167bd530931a7d48479a81 Message: Add skeletons. Modified files: lib/grnxx/map.cpp lib/grnxx/map.hpp Modified: lib/grnxx/map.cpp (+163 -5) =================================================================== --- lib/grnxx/map.cpp 2013-05-15 18:01:09 +0900 (477a6d5) +++ lib/grnxx/map.cpp 2013-05-15 18:29:02 +0900 (bce0e8f) @@ -17,10 +17,19 @@ */ #include "grnxx/map.hpp" +#include "grnxx/bytes.hpp" +#include "grnxx/geo_point.hpp" #include "grnxx/logger.hpp" namespace grnxx { +MapOptions::MapOptions() {} + +MapCursorOptions::MapCursorOptions() + : flags(MAP_CURSOR_DEFAULT), + offset(0), + limit(-1) {} + template <typename T> MapCursor<T>::MapCursor() : key_id_(-1), key_() {} @@ -33,11 +42,160 @@ bool MapCursor<T>::remove() { return false; } -MapCursorOptions::MapCursorOptions() - : flags(MAP_CURSOR_DEFAULT), - offset(0), - limit(-1) {} +template <typename T> +MapScanner<T>::MapScanner() + : offset_(0), + size_(0), + key_id_(-1), + key_() {} + +template <typename T> +MapScanner<T>::~MapScanner() {} + +template <typename T> +Map<T>::Map() {} + +template <typename T> +Map<T>::~Map() {} + +template <typename T> +Map<T> *Map<T>::create(Storage *storage, uint32_t storage_node_id, + MapType type, const MapOptions &options) { + // TODO + return nullptr; +} + +template <typename T> +Map<T> *Map<T>::open(Storage *storage, uint32_t storage_node_id) { + // TODO + return nullptr; +} + +template <typename T> +bool Map<T>::unlink(Storage *storage, uint32_t storage_node_id) { + // TODO + return nullptr; +} + +template <typename T> +bool Map<T>::get(uint64_t, Key *) { + GRNXX_ERROR() << "invalid operation"; + return false; +} + +template <typename T> +bool Map<T>::get_next(uint64_t, uint64_t *, Key *) { + // TODO: Give a naive implementation. + GRNXX_ERROR() << "invalid operation"; + return false; +} + +template <typename T> +bool Map<T>::unset(uint64_t key_id) { + GRNXX_ERROR() << "invalid operation"; + return false; +} + +template <typename T> +bool Map<T>::reset(uint64_t key_id, KeyArg dest_key) { + GRNXX_ERROR() << "invalid operation"; + return false; +} + +template <typename T> +bool Map<T>::find(KeyArg, uint64_t *) { + // TODO: Give a naive implementation. + GRNXX_ERROR() << "invalid operation"; + return false; +} + +template <typename T> +bool Map<T>::insert(KeyArg, uint64_t *) { + GRNXX_ERROR() << "invalid operation"; + return false; +} + +template <typename T> +bool Map<T>::remove(KeyArg) { + GRNXX_ERROR() << "invalid operation"; + return false; +} + +template <typename T> +bool Map<T>::update(KeyArg, KeyArg, uint64_t *) { + GRNXX_ERROR() << "invalid operation"; + return false; +} + +template <typename T> +bool Map<T>::find_longest_prefix_match(KeyArg, uint64_t *, Key *) { + // TODO: Give a naive implementation. + GRNXX_ERROR() << "invalid operation"; + return false; +} + +template <typename T> +bool Map<T>::truncate() { + GRNXX_ERROR() << "invalid operation"; + return false; +} + +template <typename T> +MapCursor<T> *Map<T>::create_cursor(const MapCursorOptions &) { + // TODO: Give a naive implementation. + GRNXX_ERROR() << "invalid operation"; + return nullptr; +} + +template <typename T> +MapCursor<T> *Map<T>::create_cursor(const map::CursorQuery<Key> &, + const MapCursorOptions &) { + // TODO: Give a naive implementation. + GRNXX_ERROR() << "invalid operation"; + return nullptr; +} + +template <typename T> +MapScanner<T> *Map<T>::create_scanner(KeyArg, const Charset *) { + // TODO: Give a naive implementation. + GRNXX_ERROR() << "invalid operation"; + return nullptr; +} + +template class MapCursor<int8_t>; +template class MapCursor<uint8_t>; +template class MapCursor<int16_t>; +template class MapCursor<uint16_t>; +template class MapCursor<int32_t>; +template class MapCursor<uint32_t>; +template class MapCursor<int64_t>; +template class MapCursor<uint64_t>; +template class MapCursor<double>; +template class MapCursor<GeoPoint>; +template class MapCursor<Bytes>; + +template class MapScanner<int8_t>; +template class MapScanner<uint8_t>; +template class MapScanner<int16_t>; +template class MapScanner<uint16_t>; +template class MapScanner<int32_t>; +template class MapScanner<uint32_t>; +template class MapScanner<int64_t>; +template class MapScanner<uint64_t>; +template class MapScanner<double>; +template class MapScanner<GeoPoint>; +template class MapScanner<Bytes>; -// TODO +template class Map<int8_t>; +template class Map<uint8_t>; +template class Map<int16_t>; +template class Map<uint16_t>; +template class Map<int32_t>; +template class Map<uint32_t>; +template class Map<int64_t>; +template class Map<uint64_t>; +template class Map<double>; +template class Map<GeoPoint>; +template class Map<Bytes>; } // namespace grnxx Modified: lib/grnxx/map.hpp (+14 -7) =================================================================== --- lib/grnxx/map.hpp 2013-05-15 18:01:09 +0900 (75109f2) +++ lib/grnxx/map.hpp 2013-05-15 18:29:02 +0900 (6af5e47) @@ -33,8 +33,13 @@ template <typename T> class CursorQuery; class Storage; class Charset; + template <typename T> class Map; +constexpr uint64_t MAP_MIN_KEY_ID = 0; +constexpr uint64_t MAP_MAX_KEY_ID = (1ULL << 40) - 1; +constexpr uint64_t MAP_INVALID_KEY_ID = MAP_MAX_KEY_ID + 1; + enum MapType : uint32_t { MAP_UNKNOWN = 0, MAP_ARRAY = 1, // TODO: Array-based implementation. @@ -44,6 +49,8 @@ enum MapType : uint32_t { }; struct MapOptions { + // Initialize the members. + MapOptions(); }; // TODO: How to implement NEAR cursor. @@ -160,21 +167,21 @@ class Map { static bool unlink(Storage *storage, uint32_t storage_node_id); // Return the storage node ID. - virtual uint32_t storage_node_id() const; + virtual uint32_t storage_node_id() const = 0; // Return the implementation type. - virtual MapType type() const; + virtual MapType type() const = 0; // Return the minimum key ID. constexpr uint64_t min_key_id() { - return 0; + return MAP_MIN_KEY_ID; } // Return the maximum key ID ever used. - // If the map is empty, the return value can be -1. - virtual uint64_t max_key_id() const; + // If the map is empty, the return value can be MAP_INVALID_KEY_ID. + virtual uint64_t max_key_id() const = 0; // Return the ID of the expected next inserted ID. - virtual uint64_t next_key_id() const; + virtual uint64_t next_key_id() const = 0; // Return the number of keys. - virtual uint64_t num_keys() const; + virtual uint64_t num_keys() const = 0; // Get a key associated with "key_id" and return true on success. // Assign the found key to "*key" iff "key" != nullptr. -------------- next part -------------- HTML����������������������������...Download