zzkk
zzkk

Reputation: 1

Use joern's RunGremlinQuery() to query the length of the list returned by the data

def getUSENodesVar(db, func_ids):
    func_ids_str = str(func_ids).replace('[', '').replace(']', '')
    query = "g.V().hasId(within(func_ids_str)).out('USE').values('code').dedup()"
    return db.runGremlinQuery(query)

I want the return value to be equal to the length of func_ids.

Upvotes: 0

Views: 34

Answers (1)

cybersam
cybersam

Reputation: 67019

By your question's phrasing, I assume that you have a special situation in which every input id has exactly one output code, and will answer with that assumption in mind. But in the general case the output list could have any length >= 0, regardless of the length on the input list.

dedup() removes duplicates, which is why the result list can be shorter than the input list.

If you want the result to be the same length, just remove .dedup() from the query. But be aware that the result list could then contain duplicates.

Upvotes: 0

Related Questions