fixed bug in GstoreConnector.recv()

This commit is contained in:
Caesar11 2014-12-11 01:52:51 -05:00
parent 6ea3b20683
commit 98eb1be60c
2 changed files with 20 additions and 3 deletions

Binary file not shown.

View File

@ -207,8 +207,14 @@ public class GstoreConnector
int context_len = GstoreConnector.byte4ToInt(head); int context_len = GstoreConnector.byte4ToInt(head);
// in Java String, there is no need for terminator '\0' in C. so we should omit '\0' at the end of receiving message. // in Java String, there is no need for terminator '\0' in C. so we should omit '\0' at the end of receiving message.
byte[] data_context = new byte[context_len-1]; byte[] data_context = new byte[context_len];
dis.read(data_context); int recv_len = 0;
do
{
int cur_len = dis.read(data_context, recv_len, data_context.length-recv_len);
recv_len += cur_len;
}while (recv_len < data_context.length);
String ret = new String(data_context,"utf-8"); String ret = new String(data_context,"utf-8");
return ret; return ret;
@ -283,11 +289,22 @@ public class GstoreConnector
//gc.build("db_LUBM10", "example/rdf_triple/LUBM_10_GStore.n3"); //gc.build("db_LUBM10", "example/rdf_triple/LUBM_10_GStore.n3");
String sparql = "select ?x where {" String sparql = "select ?x where {"
+ "<cdblp.cn/namedisambiguation/ÓÚ¸ê/Unknown/2857.html> <cdblp.cn/schema/property/hasPaper> ?x. " + "?x <rdf:type> <cdblp.cn/class/Paper>. "
+ "?x <cdblp.cn/schema/property/has_author> <cdblp.cn/author/Íõɺ>. "
+ "}"; + "}";
gc.load("db_cdblp"); gc.load("db_cdblp");
String answer = gc.query(sparql); String answer = gc.query(sparql);
System.out.println(answer); System.out.println(answer);
answer = gc.query(sparql);
System.out.println(answer);
sparql = "select ?x where {"
+ "?x <rdf:type> <cdblp.cn/class/Paper>. "
+ "?x <cdblp.cn/schema/property/has_author> <cdblp.cn/author/ÓÚ¸ê>. "
+ "}";
answer = gc.query(sparql);
System.out.println(answer);
} }
} }