susumu.yata
null+****@clear*****
Fri May 17 21:53:38 JST 2013
susumu.yata 2013-05-17 21:53:38 +0900 (Fri, 17 May 2013) New Revision: 0cd4eb2139d7684fd64eea70e9c80a9135487791 https://github.com/groonga/grnxx/commit/0cd4eb2139d7684fd64eea70e9c80a9135487791 Message: Add an interface of grnxx::map::BytesStore. Added files: lib/grnxx/map/bytes_store.cpp lib/grnxx/map/bytes_store.hpp Modified files: lib/grnxx/map/Makefile.am Modified: lib/grnxx/map/Makefile.am (+2 -0) =================================================================== --- lib/grnxx/map/Makefile.am 2013-05-17 21:53:21 +0900 (77fb4f7) +++ lib/grnxx/map/Makefile.am 2013-05-17 21:53:38 +0900 (d430696) @@ -4,12 +4,14 @@ libgrnxx_map_la_LDFLAGS = @AM_LTLDFLAGS@ libgrnxx_map_la_SOURCES = \ array_map.cpp \ + bytes_store.cpp \ cursor.cpp \ scanner.cpp libgrnxx_map_includedir = ${includedir}/grnxx/map libgrnxx_map_include_HEADERS = \ array_map.hpp \ + bytes_store.hpp \ cursor.hpp \ header.hpp \ helper.hpp \ Added: lib/grnxx/map/bytes_store.cpp (+32 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/bytes_store.cpp 2013-05-17 21:53:38 +0900 (a608f19) @@ -0,0 +1,32 @@ +/* + 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/bytes_store.hpp" + +#include <memory> +#include <new> + +#include "grnxx/logger.hpp" +#include "grnxx/storage.hpp" + +namespace grnxx { +namespace map { + +// TODO + +} // namespace map +} // namespace grnxx Added: lib/grnxx/map/bytes_store.hpp (+64 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/bytes_store.hpp 2013-05-17 21:53:38 +0900 (9086f0f) @@ -0,0 +1,64 @@ +/* + 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_BYTES_STORE_HPP +#define GRNXX_MAP_BYTES_STORE_HPP + +#include "grnxx/features.hpp" + +#include "grnxx/bytes.hpp" +#include "grnxx/traits.hpp" +#include "grnxx/types.hpp" + +namespace grnxx { + +class Storage; + +namespace map { + +constexpr uint64_t BYTES_STORE_ID_MASK = (1ULL << 60) - 1; +constexpr uint64_t BYTES_STORE_MIN_ID = 0; +constexpr uint64_t BYTES_STORE_MAX_ID = BYTES_STORE_ID_MASK; + +class BytesStore { + public: + using BytesArg = typename Traits<Bytes>::ArgumentType; + + BytesStore(); + virtual ~BytesStore(); + + // Create a store. + static BytesStore *create(Storage *storage, uint32_t storage_node_id); + // Open a store. + static BytesStore *open(Storage *storage, uint32_t storage_node_id); + + // Unlink a store. + static bool unlink(Storage *storage, uint32_t storage_node_id); + + // TODO: get() should be inlined? + // Get a stored byte sequence. + virtual bool get(uint64_t bytes_id, Bytes *bytes) = 0; + // Remove a stored byte sequence. + virtual bool unset(uint64_t bytes_id) = 0; + // Add a byte sequence. + virtual bool add(BytesArg bytes, uint64_t *bytes_id) = 0; +}; + +} // namespace map +} // namespace grnxx + +#endif // GRNXX_MAP_BYTES_STORE_HPP -------------- next part -------------- HTML����������������������������... Download