Skip to content

Misc Operations

These Operations don't fit under other pages and are not core operations.

This directed graph is used in all the examples on this page:

GetFromEndpoint

Gets data from an endpoint. Javadoc

Example

final GetFromEndpoint get = new GetFromEndpoint.Builder()
        .endpoint("https://mydata.io:8443/mydata")
        .build();
{
"class" : "GetFromEndpoint",
"endpoint" : "https://mydata.io:8443/mydata"
}
g.GetFromEndpoint( 
endpoint="https://mydata.io:8443/mydata" 
)

ScoreOperationChain

Determines a "score" for an OperationChain. This is used to determine whether a particular user has the required permissions to execute a given OperationChain. Javadoc

Example ScoreOperationChain

final ScoreOperationChain scoreOpChain = new ScoreOperationChain.Builder()
        .operationChain(new OperationChain.Builder()
                .first(new GetElements())
                .then(new NamedOperation.Builder<Element, Iterable<? extends Element>>()
                        .name("namedOp")
                        .build())
                .then(new Limit<>(3))
                .build())
        .build();
{
"class" : "ScoreOperationChain",
"operationChain" : {
    "class" : "OperationChain",
    "operations" : [ {
    "class" : "GetElements"
    }, {
    "class" : "NamedOperation",
    "operationName" : "namedOp"
    }, {
    "class" : "Limit",
    "resultLimit" : 3,
    "truncate" : true
    } ]
}
}
g.ScoreOperationChain( 
operation_chain=g.OperationChain( 
    operations=[ 
    g.GetElements(), 
    g.NamedOperation( 
        operation_name="namedOp" 
    ), 
    g.Limit( 
        result_limit=3, 
        truncate=True 
    ) 
    ] 
) 
)

Results:

5
5

Example of ScoreOperationChain with custom named score

Here we have added a NamedOperation to the NamedOperationCache, with a custom score of 3. In our ScoreOperationChainDeclaration.json file, we have also declared that this should be resolved with a NamedOperationScoreResolver. With Limit declared as having a score of 2, the above chain correctly has a score of 5.

final ScoreOperationChain scoreOperationChain = new ScoreOperationChain.Builder()
        .operationChain(new OperationChain.Builder()
                .first(new NamedOperation.Builder<EntitySeed, Iterable<? extends Element>>()
                        .name("1-hop")
                        .input(new EntitySeed(1))
                        .build())
                .then(new Limit<>(3))
                .build())
        .build();
{
"class" : "ScoreOperationChain",
"operationChain" : {
    "class" : "OperationChain",
    "operations" : [ {
    "class" : "NamedOperation",
    "input" : [ {
        "class" : "EntitySeed",
        "class" : "EntitySeed",
        "vertex" : 1
    } ],
    "operationName" : "1-hop"
    }, {
    "class" : "Limit",
    "resultLimit" : 3,
    "truncate" : true
    } ]
}
}
g.ScoreOperationChain( 
operation_chain=g.OperationChain( 
    operations=[ 
    g.NamedOperation( 
        input=[ 
        g.EntitySeed( 
            vertex=1 
        ) 
        ], 
        operation_name="1-hop" 
    ), 
    g.Limit( 
        result_limit=3, 
        truncate=True 
    ) 
    ] 
) 
)

Results:

5
5

Last update: May 18, 2023
Created: May 18, 2023