本文整理匯總了Java中com.ldbc.driver.workloads.ldbc.snb.interactive.LdbcQuery9Result類的典型用法代碼示例。如果您正苦於以下問題:Java LdbcQuery9Result類的具體用法?Java LdbcQuery9Result怎麽用?Java LdbcQuery9Result使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LdbcQuery9Result類屬於com.ldbc.driver.workloads.ldbc.snb.interactive包,在下文中一共展示了LdbcQuery9Result類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertSingleResult
import com.ldbc.driver.workloads.ldbc.snb.interactive.LdbcQuery9Result; //導入依賴的package包/類
@Override
public LdbcQuery9Result convertSingleResult(ResultSet result) throws SQLException {
return new LdbcQuery9Result(
result.getLong(1),
result.getString(2),
result.getString(3),
result.getLong(4),
result.getString(5),
stringTimestampToEpoch(result,6));
}
示例2: executeOperation
import com.ldbc.driver.workloads.ldbc.snb.interactive.LdbcQuery9Result; //導入依賴的package包/類
@Override
public void executeOperation(LdbcQuery9 operation,
DbConnectionState dbConnectionState,
ResultReporter resultReporter) throws DbException {
Driver driver = ((Neo4jDbConnectionState) dbConnectionState).getDriver();
String statement =
" MATCH (:Person {id:{1}})-[:KNOWS*1..2]-(friend:Person)<-[:HAS_CREATOR]-(message)"
+ " WHERE message.creationDate < {2}"
+ " RETURN DISTINCT"
+ " friend.id AS personId,"
+ " friend.firstName AS personFirstName,"
+ " friend.lastName AS personLastName,"
+ " message.id AS messageId,"
+ " CASE exists(message.content)"
+ " WHEN true THEN message.content"
+ " ELSE message.imageFile"
+ " END AS messageContent,"
+ " message.creationDate AS messageCreationDate"
+ " ORDER BY message.creationDate DESC, toInt(message.id) ASC"
+ " LIMIT {3}";
Value parameters = parameters(
"1", String.valueOf(operation.personId()),
"2", operation.maxDate().getTime(),
"3", operation.limit());
// Execute the query and get the results.
List<LdbcQuery9Result> resultList = new ArrayList<>();
try (Session session = driver.session(AccessMode.READ)) {
try (Transaction tx = session.beginTransaction()) {
StatementResult result = tx.run(statement, parameters);
tx.success();
tx.close();
while (result.hasNext()) {
Record record = result.next();
resultList.add(
new LdbcQuery9Result(
Long.valueOf(record.get("personId").asString()),
record.get("personFirstName").asString(),
record.get("personLastName").asString(),
Long.valueOf(record.get("messageId").asString()),
record.get("messageContent").asString(),
record.get("messageCreationDate").asLong()));
}
}
}
resultReporter.report(0, resultList, operation);
}
示例3: executeOperation
import com.ldbc.driver.workloads.ldbc.snb.interactive.LdbcQuery9Result; //導入依賴的package包/類
@Override
public void executeOperation(final LdbcQuery9 operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
long person_id = operation.personId();
long max_date = operation.maxDate().getTime();
final int limit = operation.limit();
logger.debug("Query 9 called on Person id: {} with maxDate {}",
person_id, max_date);
TitanFTMDb.BasicClient client = dbConnectionState.client();
final Set<Vertex> friends = QueryUtils.getInstance().getFoF(person_id, client);
GremlinPipeline<Collection<Vertex>, Vertex> gpf = new GremlinPipeline<>(friends);
Iterable<Row> it = gpf.as("friend").in("hasCreator").has("creationDate", Compare.LESS_THAN, max_date).as("post").select();
List<LdbcQuery9Result> result = new ArrayList<>();
for (Row r : it) {
Vertex commenter = (Vertex) r.getColumn(0);
Vertex comment = (Vertex) r.getColumn(1);
long id = client.getVLocalId((Long) commenter.getId());
String fName = commenter.getProperty("firstName");
String lName = commenter.getProperty("lastName");
long cDate = comment.getProperty("creationDate");
long commentID = client.getVLocalId((Long) comment.getId());
String content = comment.getProperty("content");
if (content.length() == 0)
content = comment.getProperty("imageFile");
LdbcQuery9Result res = new LdbcQuery9Result(id, fName, lName, commentID, content, cDate);
result.add(res);
}
Collections.sort(result, new Comparator<LdbcQuery9Result>() {
@Override
public int compare(LdbcQuery9Result o1, LdbcQuery9Result o2) {
if (o1.commentOrPostCreationDate() == o2.commentOrPostCreationDate())
return Long.compare(o1.commentOrPostId(), o2.commentOrPostId());
return Long.compare(o2.commentOrPostCreationDate(), o1.commentOrPostCreationDate());
}
});
if (result.size() > limit)
result = result.subList(0, limit);
resultReporter.report(result.size(), result, operation);
}