Skip to content

[#1102] Implementation of the MORK type AdapterDB 2#1125

Open
marcocapozzoli wants to merge 5 commits into
masterfrom
masc/1102-adapterdb-mork-3
Open

[#1102] Implementation of the MORK type AdapterDB 2#1125
marcocapozzoli wants to merge 5 commits into
masterfrom
masc/1102-adapterdb-mork-3

Conversation

@marcocapozzoli
Copy link
Copy Markdown
Collaborator

@marcocapozzoli marcocapozzoli commented May 27, 2026

  • Implementesd Metta2AtomsMapper, MorkWrapper and MorkMappingStrategy
  • Implemented loading of .metta query files
  • Improved and added tests

@marcocapozzoli marcocapozzoli changed the title Masc/1102 adapterdb mork 3 [#1102] Implementation of the MORK type AdapterDB 2 May 27, 2026
LOG_DEBUG("Mapping MORK expression: " << expr);

vector<shared_ptr<Atom>> atoms;
std::queue<shared_ptr<Atom>>* batch_queue = new std::queue<shared_ptr<Atom>>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see where batch_queue is being deleted

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replied here: #1124 (comment)

shared_ptr<BoundedSharedQueue> output_queue,
MAPPER_TYPE mapper_type)
: DatabaseWrapper(conn, MapperFactory::create(mapper_type)),
: DatabaseWrapper(*conn, MapperFactory::create(mapper_type)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This very error prone. Inside DatabaseWrapper you are storing a reference to an object attached to a shared_ptr. but this reference is not known by the shared_ptr which means that when the count in shared_ptr reaches ZERO (i.e. when all the shared_ptr which have copied the same obj is deleted) the object itself is deleted turning the reference inside DatabaseWrapper bogus.

I suggest passing (and storing inside DatabaseWrapper the shared_ptr itself instead of a reference to the object.

MAPPER_TYPE mapper_type)
: DatabaseWrapper(conn, MapperFactory::create(mapper_type)),
: DatabaseWrapper(*conn, MapperFactory::create(mapper_type)),
conn(conn),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is even weirder. The superclass already store a connection object. And here you have the subclass storing it again. This is a design flaw.

private:
mutex api_mutex;
MorkConnection& conn;
shared_ptr<MorkConnection> conn;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above. The superclass already has an object of this type.

Base automatically changed from masc/1102-adapterdb-mork-2 to master May 29, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants