Hi,
I am trying to generate a report of vertex info using println()
. I have defined a tuple
(aString, uint, uint) myTuple
and was trying to print out the values into the file - see code. I realize there is TO_CSV
and all that, but this is more of a report than a csv file. I assume there is a better way of going about this task, but am still figuring out GSQL and trying different things. What is getting put into the report is (example):
"idString<bad characters>,2000,3"
so the data is correct, it just seems the println()
does not like my tuple that much.
When I change the foreach loop to loop over the set of vertices (not the tuples), the report has no stray control characters.
CREATE QUERY getUnconnectedVertexs(INT theyear=0) FOR GRAPH myGraph {
FILE report ("/tmp/tiger/output.txt");
SumAccum< INT > @@vcnt;
SetAccum< VERTEX < myVertex > > @@vs;
SetAccum< myTuple > @@vids;
start = {myVertex.*};
find = SELECT v FROM start:v
POST-ACCUM IF (theyear == 0 OR theyear == v.year) AND v.outdegree() == 0 THEN
@@vcnt += 1,
@@vs += v,
@@vids += myTuple(v.idString, v.year, v.period)
END;
IF @@vcnt > 0 THEN
report.println("Unconnected Vertices: " + to_string(@@vcnt));
// FOREACH v IN @@vs DO this line causes no problems
FOREACH v IN @@vids DO // this results in control characters
report.println(v.idString, v.year, v.period);
END;
END;
PRINT @@vcnt as NumberOfUnconnVertices;
PRINT @@vs;
}
Obviously, trying to print the tuple information is unnecessary, but still, this is a bug as far as I can see. The extra characters at the end of idString
are always “e1 07”. I’ve had a number of issues trying to use tuples - if I define the tuple as having ints of less than 8 bytes, then printing the numbers also results in extra control characters - I get the general sense there are memory access/alignment issues going on? My C/C++ is very rusty… This is not a problem for now and I can work around it.
Doug