Skip to content

Commit

Permalink
Merge pull request #805 from epam/feature/520_std_map_embedding_storage
Browse files Browse the repository at this point in the history
Issue #520: core: replace RedBlackMap for GraphEmbeddingsStorage
  • Loading branch information
MysterionRise authored Oct 13, 2022
2 parents c96b1a1 + a0e88b6 commit bb5a66c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion core/indigo-core/graph/embeddings_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#ifndef __embeddings_storage__
#define __embeddings_storage__

#include <map>

#include "base_c/defs.h"
#include "base_cpp/array.h"
#include "base_cpp/exception.h"
Expand Down Expand Up @@ -68,7 +70,7 @@ namespace indigo
int next; // Index to the next
};
Array<_EmbeddingData> _embedding_data;
RedBlackMap<dword, int> _map_hash_to_id;
std::map<dword, int> _map_hash_to_id;

static dword _calcSetHash(const Array<int>& set, int offset, int size);
bool _compareEmbedding(int id, int id2);
Expand Down
8 changes: 4 additions & 4 deletions core/indigo-core/graph/src/embeddings_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ bool GraphEmbeddingsStorage::addEmbedding(const Graph& super, const Graph& sub,
data.sorted = false;

// Try to find element with the same hash
int* id = _map_hash_to_id.at2(hash);
const auto it = _map_hash_to_id.find(hash);
int append_to = -1;
if (id != 0)
if (it != _map_hash_to_id.end())
{
// Compare elements in the list
int cur = *id;
int cur = it->second;
while (true)
{
if (check_uniquencess && _compareEmbedding(cur, added_index))
Expand All @@ -120,7 +120,7 @@ bool GraphEmbeddingsStorage::addEmbedding(const Graph& super, const Graph& sub,
_embedding_data[append_to].next = added_index;
else
// Insert embedding into map
_map_hash_to_id.insert(hash, added_index);
_map_hash_to_id.insert(std::make_pair(hash, added_index));

return true;
}
Expand Down

0 comments on commit bb5a66c

Please sign in to comment.