Commit a062735d authored by Antony T Curtis's avatar Antony T Curtis

Cleanup, simplify and optimize. Change makefile a little so that we have debug...

Cleanup, simplify and optimize. Change makefile a little so that we have debug symbols for the graph core.
parent b27a83d5
...@@ -59,9 +59,9 @@ noinst_HEADERS = ha_oqgraph.h \ ...@@ -59,9 +59,9 @@ noinst_HEADERS = ha_oqgraph.h \
graphcore-graph.h graphcore-types.h graphcore.h graphcore-graph.h graphcore-types.h graphcore.h
# oqgraph_probes.h # oqgraph_probes.h
noinst_LTLIBRARIES = libgraphcore.la #noinst_LTLIBRARIES = libgraphcore.la
libgraphcore_la_SOURCES = graphcore.cc graphcore-graph.cc oqgraph_shim.cc oqgraph_thunk.cc #libgraphcore_la_SOURCES = graphcore.cc graphcore-graph.cc oqgraph_shim.cc oqgraph_thunk.cc
libgraphcore_la_CXXFLAGS = $(ORIG_CXXFLAGS) $(BOOST_CXXFLAGS) #libgraphcore_la_CXXFLAGS = $(ORIG_CXXFLAGS) $(BOOST_CXXFLAGS)
if BUILD_OQGRAPH_FOR_MYSQL if BUILD_OQGRAPH_FOR_MYSQL
...@@ -73,8 +73,27 @@ endif !BUILD_OQGRAPH_STANDALONE ...@@ -73,8 +73,27 @@ endif !BUILD_OQGRAPH_STANDALONE
EXTRA_LTLIBRARIES = ha_oqgraph.la EXTRA_LTLIBRARIES = ha_oqgraph.la
mysqlplugin_LTLIBRARIES = @plugin_oqgraph_shared_target@ mysqlplugin_LTLIBRARIES = @plugin_oqgraph_shared_target@
ha_oqgraph_la_SOURCES = ha_oqgraph.cc oqgraph_judy.cc ha_oqgraph_la_SOURCES = ha_oqgraph.cc oqgraph_judy.cc \
ha_oqgraph_la_LIBADD = libgraphcore.la graphcore.cc graphcore-graph.cc \
oqgraph_thunk.cc oqgraph_shim.cc
#ha_oqgraph_la_LIBADD = libgraphcore.la
ha_oqgraph_la-graphcore.lo: graphcore.cc
$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ORIG_CXXFLAGS) $(BOOST_CXXFLAGS) $(CXXFLAGS) -MT ha_oqgraph_la-graphcore.lo -MD -MP -MF $(DEPDIR)/ha_oqgraph_la-graphcore.Tpo -c -o ha_oqgraph_la-graphcore.lo `test -f 'graphcore.cc' || echo '$(srcdir)/'`graphcore.cc
mv -f $(DEPDIR)/ha_oqgraph_la-graphcore.Tpo $(DEPDIR)/ha_oqgraph_la-graphcore.Plo
ha_oqgraph_la-graphcore-graph.lo: graphcore-graph.cc
$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ORIG_CXXFLAGS) $(BOOST_CXXFLAGS) $(CXXFLAGS) -MT ha_oqgraph_la-graphcore-graph.lo -MD -MP -MF $(DEPDIR)/ha_oqgraph_la-graphcore-graph.Tpo -c -o ha_oqgraph_la-graphcore-graph.lo `test -f 'graphcore.cc' || echo '$(srcdir)/'`graphcore-graph.cc
mv -f $(DEPDIR)/ha_oqgraph_la-graphcore-graph.Tpo $(DEPDIR)/ha_oqgraph_la-graphcore-graph.Plo
ha_oqgraph_la-oqgraph_shim.lo: oqgraph_shim.cc
$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ORIG_CXXFLAGS) $(BOOST_CXXFLAGS) $(CXXFLAGS) -MT ha_oqgraph_la-oqgraph_shim.lo -MD -MP -MF $(DEPDIR)/ha_oqgraph_la-oqgraph_shim.Tpo -c -o ha_oqgraph_la-oqgraph_shim.lo `test -f 'oqgraph_shim.cc' || echo '$(srcdir)/'`oqgraph_shim.cc
mv -f $(DEPDIR)/ha_oqgraph_la-oqgraph_shim.Tpo $(DEPDIR)/ha_oqgraph_la-oqgraph_shim.Plo
ha_oqgraph_la-oqgraph_thunk.lo: oqgraph_thunk.cc
$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ORIG_CXXFLAGS) $(BOOST_CXXFLAGS) $(CXXFLAGS) -MT ha_oqgraph_la-oqgraph_thunk.lo -MD -MP -MF $(DEPDIR)/ha_oqgraph_la-oqgraph_thunk.Tpo -c -o ha_oqgraph_la-oqgraph_thunk.lo `test -f 'oqgraph_thunk.cc' || echo '$(srcdir)/'`oqgraph_thunk.cc
mv -f $(DEPDIR)/ha_oqgraph_la-oqgraph_thunk.Tpo $(DEPDIR)/ha_oqgraph_la-oqgraph_thunk.Plo
# if HAVE_DTRACE # if HAVE_DTRACE
# ha_oqgraph_la_LIBADD += oqgraph_probes.o # ha_oqgraph_la_LIBADD += oqgraph_probes.o
......
...@@ -35,18 +35,6 @@ namespace boost ...@@ -35,18 +35,6 @@ namespace boost
{ {
typedef oqgraph3::graph Graph; typedef oqgraph3::graph Graph;
template <>
struct hash<graph_traits<oqgraph3::graph>::vertex_descriptor>
: public std::unary_function<
graph_traits<oqgraph3::graph>::vertex_descriptor, std::size_t>
{
std::size_t operator()(
const graph_traits<oqgraph3::graph>::vertex_descriptor& v) const
{
return boost::hash_value(v->id);
}
};
template<typename IndexMap = identity_property_map> template<typename IndexMap = identity_property_map>
struct two_bit_judy_map struct two_bit_judy_map
{ {
...@@ -175,61 +163,6 @@ namespace boost ...@@ -175,61 +163,6 @@ namespace boost
make_lazy_property_map(Container& c, Generator g) make_lazy_property_map(Container& c, Generator g)
{ return lazy_property_map<Container, Generator>(c, g); } { return lazy_property_map<Container, Generator>(c, g); }
#if 0
struct map_wra
struct property_traits< unordered_map_wrapper<K,T,H,P,A
template <class K, class T, class H, class P, class A>
struct property_traits< unordered_map<K,T,H,P,A> > {
typedef T value_type;
typedef K key_type;
typedef T& reference;
struct category
: public read_write_property_map_tag
, public lvalue_property_map_tag
{ };
friend reference get(
unordered_map<K,T,H,P,A>& m,
const key_type& k)
{
return m[k];
}
friend void put(
unordered_map<K,T,H,P,A>& m,
const key_type& k,
const value_type& v)
{
m[k]= v;
}
};
//template <class K, class T, class H, class P, class A>
//property_traits< unordered_map<K,T,H,P,A> >::reference
//get(unordered_map<K,T,H,P,A>& m,
// const property_traits< unordered_map<K,T,H,P,A> >::key_type& k)
//{ return m[ k ]; }
//template <class K, class T, class H, class P, class A>
//void put(
// unordered_map<K,T,H,P,A>& m,
// const property_traits< unordered_map<K,T,H,P,A> >::key_type& k,
// const property_traits< unordered_map<K,T,H,P,A> >::value_type& v)
//{ m[ k ] = v; }
//template <class K, class T, class H, class P, class A>
//property_traits< unordered_map<K,T,H,P,A>::reference
//get(unordered_map<K,T,H,P,A>& m,
// const graph_traits<oqgraph3::graph>::vertex_descriptor& v)
//{ return m[ v->id ]; }
#endif
} }
#endif #endif
...@@ -1060,9 +1060,8 @@ int edges_cursor::fetch_row(const row &row_info, row &result) ...@@ -1060,9 +1060,8 @@ int edges_cursor::fetch_row(const row &row_info, row &result)
{ {
edge_iterator it, end; edge_iterator it, end;
reference ref; reference ref;
size_t count= position; tie(it, end)= edges(share->g);
for (tie(it, end)= edges(share->g); count && it != end; ++it, --count) it+= position;
;
if (it != end) if (it != end)
ref= reference(position+1, *it); ref= reference(position+1, *it);
if (int res= fetch_row(row_info, result, ref)) if (int res= fetch_row(row_info, result, ref))
......
...@@ -90,6 +90,19 @@ open_query::judy_bitset::size_type open_query::judy_bitset::count() const ...@@ -90,6 +90,19 @@ open_query::judy_bitset::size_type open_query::judy_bitset::count() const
return rc; return rc;
} }
open_query::judy_bitset& open_query::judy_bitset::set(const judy_bitset& src)
{
if (!src.empty())
{
for (size_type pos= src.find_first(); pos != npos; pos= src.find_next(pos))
{
set(pos);
}
}
return *this;
}
open_query::judy_bitset::size_type open_query::judy_bitset::find_first() const open_query::judy_bitset::size_type open_query::judy_bitset::find_first() const
{ {
int rc; int rc;
......
...@@ -41,9 +41,21 @@ namespace open_query ...@@ -41,9 +41,21 @@ namespace open_query
: array(0) : array(0)
{ } { }
judy_bitset(const judy_bitset& src)
: array(0)
{
set(src);
}
~judy_bitset() ~judy_bitset()
{ clear(); } { clear(); }
judy_bitset& operator=(const judy_bitset& src)
{
clear();
return set(src);
}
void clear(); void clear();
bool empty() const { return !array; } bool empty() const { return !array; }
bool none() const { return npos == find_first(); } bool none() const { return npos == find_first(); }
...@@ -56,6 +68,8 @@ namespace open_query ...@@ -56,6 +68,8 @@ namespace open_query
return setbit(n); return setbit(n);
} }
judy_bitset& set(const judy_bitset& src);
judy_bitset& reset(size_type n); judy_bitset& reset(size_type n);
judy_bitset& flip(size_type n); judy_bitset& flip(size_type n);
bool test(size_type) const; bool test(size_type) const;
......
...@@ -26,3 +26,51 @@ ...@@ -26,3 +26,51 @@
#include "oqgraph_shim.h" #include "oqgraph_shim.h"
bool oqgraph3::edge_iterator::seek()
{
if (!_graph->_cursor ||
_graph->_rnd_pos > _offset ||
_graph->_cursor != _graph->_rnd_cursor.operator->())
{
_graph->_rnd_pos= 0;
_graph->_rnd_cursor= new cursor(_graph);
if (_graph->_rnd_cursor->seek_to(boost::none, boost::none))
_graph->_rnd_pos= size_t(-1);
}
while (_graph->_rnd_pos < _offset)
{
if (_graph->_rnd_cursor->seek_next())
{
_offset = size_t(-1);
return true;
}
_graph->_rnd_pos++;
}
return false;
}
oqgraph3::edge_iterator::value_type oqgraph3::edge_iterator::operator*()
{
seek();
return *_graph->_rnd_cursor;
}
bool oqgraph3::edge_iterator::operator==(const self& x)
{
if (_offset == size_t(-1) && x._offset != size_t(-1))
return const_cast<edge_iterator&>(x).seek();
if (_offset != size_t(-1) && x._offset == size_t(-1))
return seek();
return _offset == x._offset;
}
bool oqgraph3::edge_iterator::operator!=(const self& x)
{
if (_offset == size_t(-1) && x._offset != size_t(-1))
return !const_cast<edge_iterator&>(x).seek();
if (_offset != size_t(-1) && x._offset == size_t(-1))
return !seek();
return _offset != x._offset;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment