Ultipa graph algorithms can be executed with both GQL and UQL through Ultipa Manager, Ultipa CLI, or by integrating Ultipa Drivers into your applications. Drivers are available for Java, Python, Go, Node.js, and C#.
Algorithm Results
The results of an algorithm's execution include primary result and optionally, statistical summary.
- Primary result delivers the algorithm’s core outputs, such as node rankings, pairwise similarities, or calculated metrics.
- Statistical summary, when available, offers aggregated insights, including averages, sums, or distribution details, to support further analysis of the primary results.
Execution Modes
Algorithms are executed using one of the six execution modes: File Writeback, DB Writeback, Stats Writeback, Full Return, Stream Return, and Stats Return.
An algorithm may support one or more of these execution methods. For details, refer to the individual algorithm page.
Overall, the HDC and distributed algorithm versions differ in their support for these execution modes:
Execution Mode | HDC Algorithm | Distributed Algorithm |
---|---|---|
File Writeback | Yes | Yes |
DB Writeback | Yes | Yes |
Stats Writeback | Yes | / |
Full Return | Yes | / |
Stream Return | Yes | / |
Stats Return | Yes | / |
We will introduce each execution mode below, along with their syntax. Note that regardless of whether an algorithm runs on an HDC graph or a distributed projection, the syntax remains the same.
File Writeback
The algorithm runs as a job in this mode with primary result written to one or more files, and statistical summary saved to the job when available, facilitating later access. This is useful for handling large outputs without returning data directly to the client, especially when offline storage or later processing is required.
CALL algo.<algoName>.write("<hdcGraphName_Or_DistProjName>", {
params: {
...
},
return_params: {
file: {
filename: "<fileName>"
}
}
})
algo(<algoName>).params({
project: "<hdcGraphName_Or_DistProjName>",
...
}).write({
file: {
filename: "<fileName>"
}
})
Details
- You can specify the file extension (like
.csv
or.txt
) in<fiileName>
or leave it unspecified, in which case the system may use a default or a generic format.
DB Writeback
The algorithm runs as a job in this mode, writing certain columns from its primary result directly to designated node properties within the database for permanent storage, and statistical summary saved to the job when available. This allows data to be readily accessible for future queries or analyses.
CALL algo.<algoName>.write("<hdcGraphName_Or_DistProjName>", {
params: {
...
},
return_params: {
db: {
property: "<propertyName>"
}
}
})
algo(<algoName>).params({
project: "<hdcGraphName_Or_DistProjName>",
...
}).write({
db: {
property: "<propertyName>"
}
})
Details
- The system creates the specified property for all labels (schemas) if it does not already exist.
- If the property exists with the right type, its values will be overwritten. If the type is incorrect, the DB writeback fails.
- For nodes with algorithm results, those values are stored in the properties; nodes without results receive a default, such as 0 or an empty string, depending on the result type.
Stats Writeback
The algorithm runs as a job in this mode. The statistical summary from the execution are saved along with the job.
CALL algo.<algoName>.write("<hdcGraphName>", {
params: {
...
},
return_params: {
stats: {}
}
})
algo(<algoName>).params({
project: "<hdcGraphName>",
...
}).write({
stats: {}
})
Full Return
The algorithm runs as a real-time process in this mode. The algorithm completes execution and then returns the full primary result in a single response to the client.
CALL algo.<algoName>("<hdcGraphName>", {
params: {
...
},
return_params: {}
}) YIELD <resultsAlias>
RETURN <resultsAlias>
exec{
algo(<algoName>).params({
...
}) as <resultsAlias>
return <resultsAlias>
} on <hdcGraphName>
Stream Return
The algorithm runs as a real-time process in this mode. The primary result is streamed progressively to the client as they are generated. This mode optimizes resource usage and grants quicker access to results, beneficial for applications needing immediate feedback.
CALL algo.<algoName>("<hdcGraphName>", {
params: {
...
},
return_params: {
stream: {}
}
}) YIELD <resultsAlias>
RETURN <resultsAlias>
exec{
algo(<algoName>).params({
...
}).stream() as <resultsAlias>
return <resultsAlias>
} on <hdcGraphName>
Stats Return
The algorithm runs as a real-time process in this mode. The algorithm completes execution and then returns the statistical summary to the client.
CALL algo.<algoName>("<hdcGraphName>", {
params: {
...
},
return_params: {
stats: {}
}
}) YIELD <statsAlias>
RETURN <statsAlias>
exec{
algo(<algoName>).params({
...
}).stats() as <statsAlias>
return <statsAlias>
} on <hdcGraphName>