Navigation Menu

Skip to content

Commit

Permalink
Create directories for DoubleArray and Patricia.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yata committed Jun 5, 2013
1 parent 52ca8d6 commit 51ebf86
Show file tree
Hide file tree
Showing 16 changed files with 354 additions and 64 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Expand Up @@ -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])
Expand Down
52 changes: 28 additions & 24 deletions lib/grnxx/map/Makefile.am
@@ -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
25 changes: 7 additions & 18 deletions lib/grnxx/map/double_array.cpp
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
11 changes: 9 additions & 2 deletions lib/grnxx/map/double_array.hpp
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions lib/grnxx/map/double_array/Makefile.am
@@ -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
28 changes: 28 additions & 0 deletions lib/grnxx/map/double_array/dummy.cpp
@@ -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
31 changes: 31 additions & 0 deletions lib/grnxx/map/double_array/dummy.hpp
@@ -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
33 changes: 33 additions & 0 deletions lib/grnxx/map/double_array/header.cpp
@@ -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
42 changes: 42 additions & 0 deletions lib/grnxx/map/double_array/header.hpp
@@ -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
25 changes: 7 additions & 18 deletions lib/grnxx/map/patricia.cpp
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 51ebf86

Please sign in to comment.