Opened the database but the schema was not recognized

17 views
Skip to first unread message

NMS

unread,
Jan 7, 2014, 2:30:34 AM1/7/14
to dex...@googlegroups.com
Hi,

I'm a beginner... I have created a database (schema and sample data) with no problems as follows: 

#include <iostream>

#include "gdb/Dex.h"

#include "gdb/Database.h"

#include "gdb/Session.h"

#include "gdb/Graph.h"

#include "gdb/Objects.h"

#include "gdb/ObjectsIterator.h"

 

using namespace dex::gdb;

 

int main(int argc, char *argv[])

{

    DexConfig cfg;

    Dex *dex = new Dex(cfg);

    Database *db = dex->Create(L"RMATLarge1.dex", L"RMATLarge1");

    Session *sess = db->NewSession();

    Graph *g = sess->GetGraph();

   

    // Add a node type with two indexed attributes

    type_t thingType = g->NewNodeType(L"THING");

    attr_t thingIdType = g->NewAttribute(thingType, L"ID", Long, Indexed);

    attr_t thingWeightType = g->NewAttribute(thingType, L"WEIGHT", Long, Basic);

 

    // Add an undirected edge type with an attribute

    type_t edgeType = g->NewEdgeType(L"EDGE", false, false);

    attr_t edgeWeightType = g->NewAttribute(edgeType, L"WEIGHT", long, Basic);

 

    // Add two THING nodes

    Value *value = new Value();

 

    oid_t thing1 = g->NewNode(thingType);

    g->SetAttribute(thing1, thingIdType, value->SetLong(1));

    g->SetAttribute(thing1, thingWeightType, value->SetLong(10));

 

    oid_t thing2 = g->NewNode(thingType);

    g->SetAttribute(thing2, thingIdType, value->SetLong(2));

    g->SetAttribute(thing2, thingWeightType, value->SetLong(11));

 

    oid_t thing3 = g->NewNode(thingType);

    g->SetAttribute(thing3, thingIdType, value->SetLong(3));

    g->SetAttribute(thing3, thingWeightType, value->SetLong(12));

  

    // Add some edges

    oid_t edge;

    edge = g->NewEdge(edgeType, thing1, thing2);

    g->SetAttribute(edge, edgeWeightType, value->SetLong(5));

 

    edge = g->NewEdge(edgeType, thing2, thing3);

    g->SetAttribute(edge, edgeWeightType, value->SetLong(6));

 
        delete value;

    delete sess;

    delete db;

    delete dex;

    return 0;

}

The problem occurs when I try to open the database again... the schema is not recognized... below is my code:

#include <iostream>

#include "gdb/Dex.h"

#include "gdb/Database.h"

#include "gdb/Session.h"

#include "gdb/Graph.h"

#include "gdb/Objects.h"

#include "gdb/ObjectsIterator.h"

 

using namespace dex::gdb;

 

int main(int argc, char *argv[])

{

    DexConfig cfg;

    Dex *dex = new Dex(cfg);

    Database *db = dex->Open(L"RMATLarge1.dex", L"RMATLarge1");

    Session *sess = db->NewSession();

    Graph *g = sess->GetGraph();

 

    Value v;


    Objects* thing1 = g->Select(thingIdType,Equal,v.SetLong(1);


    delete v;

 

 

    delete sess;

    delete db;

    delete dex;

    return 0;

}

 

The compiler gives my undeclared identifier for "thingIdType"?

What should I do?

Best regards,

Nouf

 

 

c3po.ac

unread,
Jan 8, 2014, 9:07:06 AM1/8/14
to dex...@googlegroups.com
Hi,

When you create types and attributes the identifier is returned, so you can start using it.

But when you open a database you have to retrieve the identifiers of any type and attribute that you want to use.
In this case, you need to find the "thing" type and it's "id" attribute:

type_t thingType
= g->FindType(L"THING");
attr_t thingIdType
= g->FindAttribute(thingType, L"ID");


And you may want to do the same with the rest of the schema too.

Best regards.

El dimarts 7 de gener de 2014 8:30:34 UTC+1, NMS va escriure:

NMS

unread,
Jan 9, 2014, 3:40:50 AM1/9/14
to
Thank you very much...
Reply all
Reply to author
Forward
0 new messages