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

Fixup and debugging

parent 2037f387
...@@ -126,6 +126,7 @@ oqgraph3::graph::~graph() ...@@ -126,6 +126,7 @@ oqgraph3::graph::~graph()
oqgraph3::row_cursor& oqgraph3::row_cursor::operator++() oqgraph3::row_cursor& oqgraph3::row_cursor::operator++()
{ {
printf("%s:%d\n", __func__, __LINE__);
if (!_current) if (!_current)
return *this; return *this;
...@@ -147,6 +148,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator++() ...@@ -147,6 +148,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator++()
table.file->ha_index_init(0, 1); table.file->ha_index_init(0, 1);
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_read_map");
if (table.file->ha_index_read_map( if (table.file->ha_index_read_map(
table.record[0], table.record[0],
reinterpret_cast<const uchar*>(current->first._ref.data()), reinterpret_cast<const uchar*>(current->first._ref.data()),
...@@ -197,40 +199,33 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator++() ...@@ -197,40 +199,33 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator++()
oqgraph3::row_cursor& oqgraph3::row_cursor::first() oqgraph3::row_cursor& oqgraph3::row_cursor::first()
{ {
printf("%s:%d\n", __func__, __LINE__);
TABLE& table= *_cache->_table; TABLE& table= *_cache->_table;
printf("%s:%d\n", __func__, __LINE__);
table.file->ha_index_init(0, 1); table.file->ha_index_init(0, 1);
printf("%s:%d\n", __func__, __LINE__); printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_first");
if (!table.file->ha_index_first(table.record[0])) if (!table.file->ha_index_first(table.record[0]))
{ {
printf("%s:%d\n", __func__, __LINE__);
update_virtual_fields(table.in_use, &table); update_virtual_fields(table.in_use, &table);
printf("%s:%d\n", __func__, __LINE__);
edge_key tmp(table.key_info->key_length, _cache); edge_key tmp(table.key_info->key_length, _cache);
printf("%s:%d\n", __func__, __LINE__);
key_copy( key_copy(
reinterpret_cast<uchar*>(const_cast<char*>(tmp._ref.data())), reinterpret_cast<uchar*>(const_cast<char*>(tmp._ref.data())),
table.record[0], table.record[0],
table.key_info, table.key_info,
tmp._ref.size(), true); tmp._ref.size(), true);
printf("%s:%d\n", __func__, __LINE__);
graph::edge_cache_type::iterator graph::edge_cache_type::iterator
found= _cache->_cache_edges.find(tmp); found= _cache->_cache_edges.find(tmp);
printf("%s:%d\n", __func__, __LINE__);
if (found != _cache->_cache_edges.end()) if (found != _cache->_cache_edges.end())
{ {
// we already had a row // we already had a row
printf("%s:%d\n", __func__, __LINE__);
_current.reset(&found->first); _current.reset(&found->first);
} }
else else
{ {
printf("%s:%d\n", __func__, __LINE__);
_current.reset(&_cache->_cache_edges.insert( _current.reset(&_cache->_cache_edges.insert(
std::make_pair( std::make_pair(
tmp, tmp,
...@@ -245,19 +240,19 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::first() ...@@ -245,19 +240,19 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::first()
} }
} }
printf("%s:%d\n", __func__, __LINE__);
table.file->ha_index_end(); table.file->ha_index_end();
printf("%s:%d\n", __func__, __LINE__);
return *this; return *this;
} }
oqgraph3::row_cursor& oqgraph3::row_cursor::last() oqgraph3::row_cursor& oqgraph3::row_cursor::last()
{ {
printf("%s:%d\n", __func__, __LINE__);
TABLE& table= *_cache->_table; TABLE& table= *_cache->_table;
table.file->ha_index_init(0, 1); table.file->ha_index_init(0, 1);
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_last");
if (!table.file->ha_index_last(table.record[0])) if (!table.file->ha_index_last(table.record[0]))
{ {
update_virtual_fields(table.in_use, &table); update_virtual_fields(table.in_use, &table);
...@@ -300,6 +295,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::last() ...@@ -300,6 +295,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::last()
oqgraph3::row_cursor& oqgraph3::row_cursor::operator--() oqgraph3::row_cursor& oqgraph3::row_cursor::operator--()
{ {
printf("%s:%d\n", __func__, __LINE__);
if (!_current) if (!_current)
return last(); return last();
...@@ -320,6 +316,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator--() ...@@ -320,6 +316,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator--()
TABLE& table= *_cache->_table; TABLE& table= *_cache->_table;
table.file->ha_index_init(0, 1); table.file->ha_index_init(0, 1);
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_read_map");
if (table.file->ha_index_read_map( if (table.file->ha_index_read_map(
table.record[0], table.record[0],
reinterpret_cast<const uchar*>(current->first._ref.data()), reinterpret_cast<const uchar*>(current->first._ref.data()),
...@@ -370,6 +367,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator--() ...@@ -370,6 +367,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator--()
oqgraph3::row_cursor& oqgraph3::row_cursor::operator+=(difference_type delta) oqgraph3::row_cursor& oqgraph3::row_cursor::operator+=(difference_type delta)
{ {
printf("%s:%d\n", __func__, __LINE__);
if (!delta || !_current) if (!delta || !_current)
return *this; return *this;
...@@ -403,6 +401,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator+=(difference_type delta) ...@@ -403,6 +401,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator+=(difference_type delta)
index_started= true; index_started= true;
} }
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_read_map");
if (table.file->ha_index_read_map( if (table.file->ha_index_read_map(
table.record[0], table.record[0],
reinterpret_cast<const uchar*>(current->second._next->data()), reinterpret_cast<const uchar*>(current->second._next->data()),
...@@ -422,6 +421,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator+=(difference_type delta) ...@@ -422,6 +421,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator+=(difference_type delta)
index_started= true; index_started= true;
} }
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_read_map");
if (table.file->ha_index_read_map( if (table.file->ha_index_read_map(
table.record[0], table.record[0],
reinterpret_cast<const uchar*>(current->first._ref.data()), reinterpret_cast<const uchar*>(current->first._ref.data()),
...@@ -457,6 +457,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator+=(difference_type delta) ...@@ -457,6 +457,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator+=(difference_type delta)
if (!index_started) if (!index_started)
return *this; return *this;
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_next");
if (table.file->ha_index_next(table.record[0])) if (table.file->ha_index_next(table.record[0]))
{ {
table.file->ha_index_end(); table.file->ha_index_end();
...@@ -486,6 +487,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator+=(difference_type delta) ...@@ -486,6 +487,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator+=(difference_type delta)
oqgraph3::row_cursor& oqgraph3::row_cursor::operator-=(difference_type delta) oqgraph3::row_cursor& oqgraph3::row_cursor::operator-=(difference_type delta)
{ {
printf("%s:%d\n", __func__, __LINE__);
if (!delta || !_current) if (!delta || !_current)
return *this; return *this;
...@@ -519,6 +521,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator-=(difference_type delta) ...@@ -519,6 +521,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator-=(difference_type delta)
index_started= true; index_started= true;
} }
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_read_map");
if (table.file->ha_index_read_map( if (table.file->ha_index_read_map(
table.record[0], table.record[0],
reinterpret_cast<const uchar*>(current->second._next->data()), reinterpret_cast<const uchar*>(current->second._next->data()),
...@@ -537,6 +540,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator-=(difference_type delta) ...@@ -537,6 +540,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator-=(difference_type delta)
index_started= true; index_started= true;
} }
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_read_map");
if (table.file->ha_index_read_map( if (table.file->ha_index_read_map(
table.record[0], table.record[0],
reinterpret_cast<const uchar*>(current->first._ref.data()), reinterpret_cast<const uchar*>(current->first._ref.data()),
...@@ -571,6 +575,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator-=(difference_type delta) ...@@ -571,6 +575,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator-=(difference_type delta)
if (!index_started) if (!index_started)
return first(); return first();
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_prev");
if (table.file->ha_index_prev(table.record[0])) if (table.file->ha_index_prev(table.record[0]))
{ {
table.file->ha_index_end(); table.file->ha_index_end();
...@@ -599,6 +604,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator-=(difference_type delta) ...@@ -599,6 +604,7 @@ oqgraph3::row_cursor& oqgraph3::row_cursor::operator-=(difference_type delta)
oqgraph3::vertex_descriptor oqgraph3::graph::vertex(vertex_id id) oqgraph3::vertex_descriptor oqgraph3::graph::vertex(vertex_id id)
{ {
printf("%s:%d\n", __func__, __LINE__);
vertex_cache_type::const_iterator vertex_cache_type::const_iterator
found= _cache_vertices.find(vertex_info(id)); found= _cache_vertices.find(vertex_info(id));
...@@ -611,6 +617,7 @@ oqgraph3::vertex_descriptor oqgraph3::graph::vertex(vertex_id id) ...@@ -611,6 +617,7 @@ oqgraph3::vertex_descriptor oqgraph3::graph::vertex(vertex_id id)
oqgraph3::edge_descriptor oqgraph3::graph::edge(const edge_key& key) oqgraph3::edge_descriptor oqgraph3::graph::edge(const edge_key& key)
{ {
printf("%s:%d\n", __func__, __LINE__);
edge_cache_type::const_iterator edge_cache_type::const_iterator
found= _cache_edges.find(key); found= _cache_edges.find(key);
...@@ -621,6 +628,7 @@ oqgraph3::edge_descriptor oqgraph3::graph::edge(const edge_key& key) ...@@ -621,6 +628,7 @@ oqgraph3::edge_descriptor oqgraph3::graph::edge(const edge_key& key)
table.file->ha_index_init(0, 0); table.file->ha_index_init(0, 0);
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_read_map");
if (table.file->ha_index_read_map( if (table.file->ha_index_read_map(
table.record[0], table.record[0],
reinterpret_cast<const uchar*>(key._ref.data()), reinterpret_cast<const uchar*>(key._ref.data()),
...@@ -652,6 +660,7 @@ oqgraph3::edge_descriptor oqgraph3::graph::edge( ...@@ -652,6 +660,7 @@ oqgraph3::edge_descriptor oqgraph3::graph::edge(
const vertex_descriptor& source, const vertex_descriptor& source,
const vertex_descriptor& target) const vertex_descriptor& target)
{ {
printf("%s:%d\n", __func__, __LINE__);
vertex_cache_type::const_iterator xsource= _cache_vertices.find(*source); vertex_cache_type::const_iterator xsource= _cache_vertices.find(*source);
if (_cache_vertices.end() != xsource && xsource->_out_edges) if (_cache_vertices.end() != xsource && xsource->_out_edges)
...@@ -721,15 +730,20 @@ oqgraph3::edge_descriptor oqgraph3::graph::edge( ...@@ -721,15 +730,20 @@ oqgraph3::edge_descriptor oqgraph3::graph::edge(
bitmap_clear_bit(table.write_set, _source->field_index); bitmap_clear_bit(table.write_set, _source->field_index);
bitmap_clear_bit(table.write_set, _target->field_index); bitmap_clear_bit(table.write_set, _target->field_index);
uint key_len= key_info->key_part[0].store_length + uint key_len= key_info->key_length;
key_info->key_part[1].store_length;
uchar* key_prefix= (uchar*) my_alloca(key_len); uchar* key_prefix= (uchar*) my_alloca(key_len);
table.file->ha_index_init(i, 0); table.file->ha_index_init(i, 0);
key_copy(key_prefix, table.record[0], key_info, key_len); key_copy(key_prefix, table.record[0], key_info, key_len, 1);
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_read_map");
if (!table.file->ha_index_read_map( if (!table.file->ha_index_read_map(
table.record[0], key_prefix, (key_part_map)3, HA_READ_KEY_EXACT)) table.record[0], key_prefix, (key_part_map)3,
key_info->key_parts == 2 ?
HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT) &&
_source->val_int() == source->id &&
_target->val_int() == target->id)
{ {
// We have found the edge, // We have found the edge,
...@@ -795,6 +809,7 @@ oqgraph3::edges_size_type oqgraph3::graph::num_edges() const ...@@ -795,6 +809,7 @@ oqgraph3::edges_size_type oqgraph3::graph::num_edges() const
const oqgraph3::vertex_info::edge_list_type& const oqgraph3::vertex_info::edge_list_type&
oqgraph3::vertex_info::out_edges() oqgraph3::vertex_info::out_edges()
{ {
printf("%s:%d id=%lld\n", __func__, __LINE__, id);
if (!_out_edges) if (!_out_edges)
{ {
_out_edges = edge_list_type(); _out_edges = edge_list_type();
...@@ -815,14 +830,18 @@ oqgraph3::vertex_info::out_edges() ...@@ -815,14 +830,18 @@ oqgraph3::vertex_info::out_edges()
_cache->_source->store(id, 1); _cache->_source->store(id, 1);
bitmap_clear_bit(table.write_set, _cache->_source->field_index); bitmap_clear_bit(table.write_set, _cache->_source->field_index);
uint key_len= key_info->key_part[0].store_length; uint key_len= key_info->key_length;
uchar* key= (uchar*) my_alloca(key_len); uchar* key= (uchar*) my_alloca(key_len);
table.file->ha_index_init(i, 1); table.file->ha_index_init(i, 1);
key_copy(key, table.record[0], key_info, key_len); key_copy(key, table.record[0], key_info, key_len, true);
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_read_map");
if (!table.file->ha_index_read_map( if (!table.file->ha_index_read_map(
table.record[0], key, (key_part_map)1, HA_READ_KEY_EXACT)) table.record[0], key, (key_part_map)1,
key_info->key_parts == 1 ?
HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT))
{ {
// We have found an edge, // We have found an edge,
do do
...@@ -854,9 +873,14 @@ oqgraph3::vertex_info::out_edges() ...@@ -854,9 +873,14 @@ oqgraph3::vertex_info::out_edges()
)).first; )).first;
} }
_out_edges->push_back(found->first._ref); _out_edges->push_back(found->first._ref);
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_next");
if (table.file->ha_index_next(table.record[0]))
{
break;
} }
while (!table.file->ha_index_next_same( }
table.record[0], key, key_len)); while (_cache->_source->val_int() == id);
table.file->ha_index_end(); table.file->ha_index_end();
my_afree(key); my_afree(key);
...@@ -872,6 +896,7 @@ oqgraph3::vertex_info::out_edges() ...@@ -872,6 +896,7 @@ oqgraph3::vertex_info::out_edges()
const oqgraph3::vertex_info::edge_list_type& const oqgraph3::vertex_info::edge_list_type&
oqgraph3::vertex_info::in_edges() oqgraph3::vertex_info::in_edges()
{ {
printf("%s:%d\n", __func__, __LINE__);
if (!_in_edges) if (!_in_edges)
{ {
_in_edges = edge_list_type(); _in_edges = edge_list_type();
...@@ -892,14 +917,18 @@ oqgraph3::vertex_info::in_edges() ...@@ -892,14 +917,18 @@ oqgraph3::vertex_info::in_edges()
_cache->_target->store(id, 1); _cache->_target->store(id, 1);
bitmap_clear_bit(table.write_set, _cache->_target->field_index); bitmap_clear_bit(table.write_set, _cache->_target->field_index);
uint key_len= key_info->key_part[0].store_length; uint key_len= key_info->key_length;
uchar* key= (uchar*) my_alloca(key_len); uchar* key= (uchar*) my_alloca(key_len);
table.file->ha_index_init(i, 1); table.file->ha_index_init(i, 1);
key_copy(key, table.record[0], key_info, key_len); key_copy(key, table.record[0], key_info, key_len, true);
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_read_map");
if (!table.file->ha_index_read_map( if (!table.file->ha_index_read_map(
table.record[0], key, (key_part_map)1, HA_READ_KEY_EXACT)) table.record[0], key, (key_part_map)1,
key_info->key_parts == 1 ?
HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT))
{ {
// We have found an edge, // We have found an edge,
do do
...@@ -931,9 +960,12 @@ oqgraph3::vertex_info::in_edges() ...@@ -931,9 +960,12 @@ oqgraph3::vertex_info::in_edges()
)).first; )).first;
} }
_in_edges->push_back(found->first._ref); _in_edges->push_back(found->first._ref);
printf("%s:%d - %s\n", __func__, __LINE__, "ha_index_next");
if (table.file->ha_index_next(table.record[0]))
break;
} }
while (!table.file->ha_index_next_same( while (_cache->_target->val_int() == id);
table.record[0], key, key_len));
table.file->ha_index_end(); table.file->ha_index_end();
my_afree(key); my_afree(key);
...@@ -948,27 +980,32 @@ oqgraph3::vertex_info::in_edges() ...@@ -948,27 +980,32 @@ oqgraph3::vertex_info::in_edges()
std::size_t oqgraph3::vertex_info::degree() std::size_t oqgraph3::vertex_info::degree()
{ {
printf("%s:%d\n", __func__, __LINE__);
return out_edges().size() + in_edges().size(); return out_edges().size() + in_edges().size();
} }
oqgraph3::degree_size_type oqgraph3::vertex_descriptor::in_degree() const oqgraph3::degree_size_type oqgraph3::vertex_descriptor::in_degree() const
{ {
printf("%s:%d\n", __func__, __LINE__);
return (*this)->in_edges().size(); return (*this)->in_edges().size();
} }
oqgraph3::degree_size_type oqgraph3::vertex_descriptor::out_degree() const oqgraph3::degree_size_type oqgraph3::vertex_descriptor::out_degree() const
{ {
printf("%s:%d\n", __func__, __LINE__);
return (*this)->out_edges().size(); return (*this)->out_edges().size();
} }
oqgraph3::vertex_descriptor oqgraph3::edge_descriptor::source() const oqgraph3::vertex_descriptor oqgraph3::edge_descriptor::source() const
{ {
printf("%s:%d\n", __func__, __LINE__);
return (*this)->_cache->vertex( return (*this)->_cache->vertex(
oqgraph3::row_cursor(*this, (*this)->_cache)->first); oqgraph3::row_cursor(*this, (*this)->_cache)->first);
} }
oqgraph3::vertex_descriptor oqgraph3::edge_descriptor::target() const oqgraph3::vertex_descriptor oqgraph3::edge_descriptor::target() const
{ {
printf("%s:%d\n", __func__, __LINE__);
return (*this)->_cache->vertex( return (*this)->_cache->vertex(
oqgraph3::row_cursor(*this, (*this)->_cache)->second); oqgraph3::row_cursor(*this, (*this)->_cache)->second);
} }
......
...@@ -205,7 +205,7 @@ namespace oqgraph3 ...@@ -205,7 +205,7 @@ namespace oqgraph3
, _weight(weight) , _weight(weight)
, _prev(prev) , _prev(prev)
, _next(next) , _next(next)
{ } { printf("row_info(%lld,%lld,%f)\n", source, target, weight);}
}; };
namespace internal namespace internal
......
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