In which cases FindAttribute gives 0(zero) as ouput?

27 views
Skip to first unread message

Frank Smith

unread,
Mar 8, 2016, 9:05:01 AM3/8/16
to Sparksee
Hi,
I do not understand what is going on...:

I've set this edge with two edge's attributes:

        relType = graph->NewEdgeType(RelationshipType, CNode, CNode);
        RSText = graph->NewAttribute(relType, L"RSTEXT", String, Basic);
        RDataset = graph->NewAttribute(relType, L"RDATASET", String, Indexed);


       attr_t RDatasetId = graph->FindAttribute(relType, L"RDATASET");
        std::wcout << "RDatasetId = " << RDatasetId << std::endl;
        value->SetString(RelDataset);
        graph->SetAttribute(anEdge, RDatasetId, *value); 

When importing the pair of nodes, the edge between them with the attached two attributes, for the first couple of nodes, RDatasetId has value > 0, while the second time, RDatasetId is 0 and then the software crashes:

g++ -O3 -std=c++11 -I /home/frank/sparkseecpp-5.2.0/includes/sparksee objJsonParser.cpp CGraph.cpp -o CGraph -L /home/frank/sparkseecpp-5.2.0/lib/linux64 -lsparksee
export LD_LIBRARY_PATH=/home/frank/sparkseecpp-5.2.0/lib/linux64/
 time ./CGraph
CNODE already present
jsonParsingWResult= backyard_in,AtLocation,house_in_suburb,You are likely to find [[a backyard in]] behind [[a house in the suburbs]],cnet
lineCounter= 1
RelationshipType= AtLocation
relTypeId= 9
AtLocation already present
HeadNodeName= backyard_in
headOid= 1024
TailNodeName= house_in_suburb
tailOid= 1025
RelDataset= conceptnet
RDatasetId = 11

real    0m0.253s
user    0m0.009s
sys     0m0.005s

CNODE already present
jsonParsingWResult= CapableOf,TranslationOf -,fly_with_wing,[[???????????????????????????????????????]] in Japanese means [[birds can fly with wings.]] in English.,globalmind
jsonParsingWResult.size()= 154
lineCounter= 2
RelationshipType= TranslationOf -
relTypeId= 10
TranslationOf - already present
HeadNodeName= CapableOf
headOid= 1026
TailNodeName= fly_with_wing
tailOid= 1027
RelDataset= globalmind
RDatasetId = 0
terminate called after throwing an instance of 'sparksee::gdb::Error'
**** CRITICAL ERROR (SIGNAL NUM 6)
------- Begin of call stack ------
/home/frank/sparkseecpp-5.2.0/lib/linux64/libsparksee.so(_ZN13sparksee_core21CallStackTraceHandler13SignalHandlerEi+0x28) [0x7f5f11b199a8]
/lib/x86_64-linux-gnu/libc.so.6(+0x36d40) [0x7f5f1112cd40]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x39) [0x7f5f1112ccc9]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7f5f111300d8]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x15d) [0x7f5f1173b6dd]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x67746) [0x7f5f11739746]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x67791) [0x7f5f11739791]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x679a8) [0x7f5f117399a8]
/home/frank/sparkseecpp-5.2.0/lib/linux64/libsparksee.so(_ZN8sparksee3gdb5Graph12SetAttributeExiRNS0_5ValueE+0x74) [0x7f5f11ad1aa4]
./CGraph() [0x403c9f]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f5f11117ec5]
./Cgraph() [0x4049ee]
-------- End of call stack -------

So...I ask you... in which cases FindAttribute gives 0 (zero) as output? 

Frank

c3po.ac

unread,
Mar 9, 2016, 4:42:29 AM3/9/16
to Sparksee
Hi,

From the code snippet it's a little difficult to understand your schema and how you are using FindAttribute and NewEdgeType but we are going to try to give you some insights of what we think it may be happening:

- NewEdgeType: Its arguments are the string with the name of the edge type, a boolean to set the edge as directed/undirected and another boolean to decide whether to index or not the neighbors. We see a variable called CNode for the boolean arguments that you should double check.

- FindAttribute: Once you have successfully created an attribute for an edge type, then the FindAttribute method should always return the attribute id, as long both arguments are correct. In the first part of your test the edge type used is number 9 (AtLocation)  while in the second part the edge is number 10 (TranslationOf -).  In both cases the edge types appear to already exist. You should verify that, in the place where you have created them, the attributes for both edge types are also created and that you're using the exact name in the FindAttribute.

- Another important thing is to verify that the Database has been properly closed, because in case of a crash that might lead to a database corruption. Another way to avoid it and be always secured is to activate the Recovery function in the SparkseeConfig.

- About the crash, the SetAttribute is throwing an Exception. You could catch it to get the error message and avoid the crash, or you could check the log file to see what happened. It's probably just that the attribute argument is invalid because the FindAtttibute couldn't find it.

Hope this is helpful!

El dimarts, 8 març de 2016 15:05:01 UTC+1, Frank Smith va escriure:

Frank Smith

unread,
Mar 9, 2016, 8:35:11 AM3/9/16
to Sparksee
Hi, 
apart from the very first element (boolean arguments for NewEdgeType) which I promptly corrected, the rest was fine.

I discovered that the problem lies in the fact that the asian characters are not supported by std::wstring (they become question marks, ex: "??????").
So....any suggestions on how to seamlessly handle asian characters in C++ first and then in Sparksee?

Frank

c3po.ac

unread,
Mar 9, 2016, 10:17:51 AM3/9/16
to Sparksee
Hi,

The Sparksee C++ API uses wstrings because it expects unicode wide char strings. And the std::wstrings should be able to handle any asian language characters in unicode.

You may want to check the conversion from your data source format (maybe utf8) to wide chars.  But It may be easier to check first  that the wstrings work in a simple example with hardcoded unicode strings.
For example:

    graph->SetAttribute(aNode, nodeTypeStrAttr, aValue->SetString(L"こんにちは世界"));
     
Value *val = graph->GetAttribute(aNode, nodeTypeStrAttr);
     
assert(val->GetString().compare(L"こんにちは世界") == 0 );


You can also try not using C++11 because the normal Sparksee C++ version is not compiled with C++11 and the wstrings of different std libraries might be the problem. If that was the case, and you need C++11, you might want to ask for a specific release of Sparksee with C++11.

Best regards,


El dimecres, 9 març de 2016 14:35:11 UTC+1, Frank Smith va escriure:

Frank Smith

unread,
Mar 9, 2016, 12:33:35 PM3/9/16
to Sparksee
Hi,
I need C++11 and "hard-coding" the asian-characters string within the code is not feasible....
How can I get the specific release of Sparksee with C++11?

Frank

c3po.ac

unread,
Mar 10, 2016, 3:08:01 AM3/10/16
to Sparksee
Hi,

The idea of using hardcoded unicode strings was only to check if the problem was in the conversion from the source data to the wstrings or in the call of the Sparksee api methods using wstrings arguments.

You can ask Dàmaris to send you a release with your requirements.

Best regards,


El dimecres, 9 març de 2016 18:33:35 UTC+1, Frank Smith va escriure:
Reply all
Reply to author
Forward
0 new messages