-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(c++): API design for multi-label support #614
Labels
enhancement
New feature or request
Comments
Neo4j Cypher statements involving tags can be mainly divided into the following categories:1. Creation
CREATE (n:Label {property: value})
MATCH (n) SET n:NewLabel 2. Deletion and Renaming
MATCH (n) REMOVE LABELS(n)
MATCH (n:OldLabel) SET n:NewLabel REMOVE n:OldLabel 3. Querying and Filtering
MATCH (n:Label) RETURN n
MATCH (n:Label1:Label2) RETURN n
MATCH (n:Label {property: value}) RETURN n
MATCH (n)
WHERE id(n) = <your_node_id> AND n:Label1
RETURN COUNT(n) > 0 AS hasLabel1 4. Statistics and Information
MATCH (n:Label) RETURN COUNT(n)
CALL db.labels() YIELD label RETURN label |
LDBC SNB Cypher statements:Querying and Filtering
/*
:params { datetime: datetime('2011-12-01T00:00:00.000') }
*/
MATCH (message:Message)
WHERE message.creationDate < $datetime
WITH count(message) AS totalMessageCountInt // this should be a subquery once Cypher supports it
WITH toFloat(totalMessageCountInt) AS totalMessageCount
MATCH (tag:Tag)-[:HAS_TYPE]->(:TagClass {name: $tagClass})
// window 1
OPTIONAL MATCH (message1:Message)-[:HAS_TAG]->(tag)
WHERE $date <= message1.creationDate
AND message1.creationDate < $date + duration({days: 100})
WITH tag, count(message1) AS countWindow1
// window 2
OPTIONAL MATCH (message2:Message)-[:HAS_TAG]->(tag)
WHERE $date + duration({days: 100}) <= message2.creationDate
AND message2.creationDate < $date + duration({days: 200})
WITH
tag,
countWindow1,
count(message2) AS countWindow2
/*
:params { tagClass: 'MusicalArtist', country: 'Burma' }
*/
MATCH
(:Country {name: $country})<-[:IS_PART_OF]-(:City)<-[:IS_LOCATED_IN]-
(person:Person)<-[:HAS_MODERATOR]-(forum:Forum)-[:CONTAINER_OF]->
(post:Post)<-[:REPLY_OF*0..]-(message:Message)-[:HAS_TAG]->(:Tag)-[:HAS_TYPE]->(:TagClass {name: $tagClass}) |
LDBC SNB Gremlin statements:Querying and Filtering
|
class VerticesCollection {
public:
/**
* @brief Query vertices with a specific label
*
* @param filter_label The label to query vertices by
* @param graph_info A smart pointer to GraphInfo that contains details about the graph
* @param type The type of vertices to query
* @return A VerticesCollection containing all vertices that have the specified label
*/
static Result<std::shared_ptr<VerticesCollection>> verticesWithLabel(
const std::string& filter_label,
const std::shared_ptr<GraphInfo>& graph_info,
const std::string& type);
/**
* @brief Query vertices with a specific label within a given collection
*
* @param filter_label The label to query vertices by
* @param vertices_collection The collection of vertices to search within
* @return A VerticesCollection containing all vertices from the specified collection that have the specified label
*/
static Result<std::shared_ptr<VerticesCollection>> verticesWithLabel(
const std::string& filter_label,
const std::shared_ptr<VerticesCollection>& vertices_collection);
/**
* @brief Query vertices with multiple labels
*
* @param filter_labels A vector of labels to query vertices by
* @param graph_info A smart pointer to GraphInfo that contains details about the graph
* @param type The type of vertices to query
* @return A VerticesCollection containing all vertices that have all of the specified labels
*/
static Result<std::shared_ptr<VerticesCollection>> verticesWithMultipleLabels(
const std::vector<std::string>& filter_labels,
const std::shared_ptr<GraphInfo>& graph_info,
const std::string& type);
/**
* @brief Query vertices with multiple labels within a given collection
*
* @param filter_labels A vector of labels to query vertices by
* @param vertices_collection The collection of vertices to search within
* @return A VerticesCollection containing all vertices from the specified collection that have all of the specified labels
*/
static Result<std::shared_ptr<VerticesCollection>> verticesWithMultipleLabels(
const std::vector<std::string>& filter_labels,
const std::shared_ptr<VerticesCollection>& vertices_collection);
/**
* @brief Query vertices with a specific label and properties
*
* @param filter_label The label to query vertices by
* @param propery_filter_expr A shared pointers to Property filter expression that the vertices should match
* @param graph_info A smart pointer to GraphInfo that contains details about the graph
* @param type The type of vertices to query
* @return A VerticesCollection containing all vertices that have the specified label and match the given properties
*/
static Result<std::shared_ptr<VerticesCollection>> verticesWithLabelAndProperty(
const std::string& filter_label,
const std::shared_ptr<Expression> propery_filter_expr,
const std::shared_ptr<GraphInfo>& graph_info,
const std::string& type);
/**
* @brief Query vertices with a specific label and properties within a given collection
*
* @param filter_label The label to query vertices by
* @param propery_filter_expr A shared pointers to Property filter expression that the vertices should match
* @param vertices_collection The collection of vertices to search within
* @return A VerticesCollection containing all vertices from the specified collection that have the specified label and match the given properties
*/
static Result<std::shared_ptr<VerticesCollection>> verticesWithLabelAndProperty(
const std::string& filter_label,
const std::shared_ptr<Expression> propery_filter_expr,
const std::shared_ptr<VerticesCollection>& vertices_collection);
};
class VertexIter {
/**
* @brief Check if the vertex has a specific label
*
* @param label The label to check for on the specified vertex
* @return True if the vertex has the specified label, false otherwise
*/
bool HasLabel(const std::string& label);
}
|
Please refers to the existing |
They should be static functions like ref:
|
1. Query nodes with a specific labelCypher: MATCH (n:Label) RETURN n Gremlin:
2. Query nodes with multiple labelsCypher: MATCH (n:Label1:Label2) RETURN n Gremlin:
3. Query nodes with a specific label and propertyCypher: MATCH (n:Label {property: value}) RETURN n Gremlin:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the enhancement requested
TBF
Component(s)
C++
The text was updated successfully, but these errors were encountered: