Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Commit 5fc5b01

Browse files
authored
Variables and Traits Docs (#542)
* add missing examples * address comment
1 parent 7eef07b commit 5fc5b01

File tree

2 files changed

+153
-4
lines changed

2 files changed

+153
-4
lines changed

docs/reference/operations-guide/core.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4524,11 +4524,118 @@ Gets the Schema of a Graph. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/
45244524
}
45254525
```
45264526

4527+
## Variables
4528+
4529+
Operations associated with storing variables in the operation context map. Note that the context only exists during that operation and so these operations must be contained within the same operation chain to work.
4530+
4531+
### SetVariable
4532+
4533+
Stores a variable in the Context variable map. Takes a variable
4534+
name and an input and stores them as a key value pair. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/operation/impl/SetVariable.html)
4535+
4536+
??? example "Example setting a variable"
4537+
=== "Java"
4538+
4539+
``` java
4540+
final SetVariable op = new SetVariable.Builder()
4541+
.variableName("varName")
4542+
.input(5)
4543+
.build();
4544+
```
4545+
4546+
=== "JSON"
4547+
4548+
``` json
4549+
{
4550+
"class" : "SetVariable",
4551+
"variableName": "varName",
4552+
"input": 5
4553+
}
4554+
```
4555+
4556+
### GetVariable
4557+
4558+
Gets a variable from the Context variable map. Takes the variable
4559+
name as an input. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/operation/impl/GetVariable.html)
4560+
4561+
??? example "Example getting a variable"
4562+
=== "Java"
4563+
4564+
``` java
4565+
final GetVariable op = new GetVariable.Builder()
4566+
.variableName("varName")
4567+
.build();
4568+
```
4569+
4570+
=== "JSON"
4571+
4572+
``` json
4573+
{
4574+
"class" : "GetVariable",
4575+
"variableName": "varName"
4576+
}
4577+
```
4578+
4579+
Results:
4580+
4581+
=== "Java"
4582+
4583+
``` java
4584+
5
4585+
```
4586+
4587+
=== "JSON"
4588+
4589+
``` json
4590+
5
4591+
```
4592+
4593+
### GetVariables
4594+
4595+
Gets all the variables from the Context variable map. Takes a list of variable names
4596+
as an input. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/operation/impl/GetVariables.html)
4597+
4598+
??? example "Example getting all variables"
4599+
=== "Java"
4600+
4601+
``` java
4602+
final List<String> variableNames = Arrays.asList("varName");
4603+
final GetVariables op = new GetVariables.Builder()
4604+
.variableNames(variableNames)
4605+
.build();
4606+
```
4607+
4608+
=== "JSON"
4609+
4610+
``` json
4611+
{
4612+
"class" : "GetVariables",
4613+
"variableNames": ["varName"]
4614+
}
4615+
```
4616+
4617+
Results:
4618+
4619+
=== "Java"
4620+
4621+
``` java
4622+
5
4623+
```
4624+
4625+
=== "JSON"
4626+
4627+
``` json
4628+
5
4629+
```
4630+
45274631
## GetTraits
45284632

45294633
Gets the traits of the current store. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/store/operation/GetTraits.html)
45304634

45314635
??? example "Example getting all traits"
4636+
`currentTraits` is an optional field that holds a boolean value. When false the
4637+
operation returns a list of all supported traits from the store, but if true then a list of current traits is returned.
4638+
Defaults to true.
45324639

45334640
=== "Java"
45344641

@@ -4625,6 +4732,48 @@ Gets the traits of the current store. [Javadoc](https://gchq.github.io/Gaffer/uk
46254732
[ "QUERY_AGGREGATION", "MATCHED_VERTEX", "TRANSFORMATION", "INGEST_AGGREGATION", "PRE_AGGREGATION_FILTERING", "POST_TRANSFORMATION_FILTERING", "POST_AGGREGATION_FILTERING" ]
46264733
```
46274734

4735+
## HasTrait
4736+
4737+
Checks if a Store has a given trait. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/store/operation/HasTrait.html)
4738+
4739+
??? example "Example checking if store has trait"
4740+
`currentTraits` is an optional field that holds a boolean value and
4741+
defaults to true. It is used to check if the provided traits exists in the either the store default (false)
4742+
or the schema current traits (true).
4743+
4744+
=== "Java"
4745+
4746+
``` java
4747+
final HasTrait operation = new HasTrait.Builder()
4748+
.currentTraits(false)
4749+
.trait(PRE_AGGREGATION_FILTERING)
4750+
.build();
4751+
```
4752+
4753+
=== "JSON"
4754+
4755+
``` json
4756+
{
4757+
"class" : "HasTrait",
4758+
"currentTraits" : false,
4759+
"trait": "PRE_AGGREGATION_FILTERING"
4760+
}
4761+
```
4762+
4763+
Results:
4764+
4765+
=== "Java"
4766+
4767+
``` java
4768+
true
4769+
```
4770+
4771+
=== "JSON"
4772+
4773+
``` json
4774+
true
4775+
```
4776+
46284777
## DeleteAllData
46294778

46304779
Deletes all retained data including deleting the graph. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/store/operation/DeleteAllData.html)

docs/reference/operations-guide/operations.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ Operation | Type
2727
[`operation.impl.function.Aggregate`](core.md#aggregate) | Core
2828
[`operation.impl.function.Filter`](core.md#filter) | Core
2929
[`operation.impl.function.Transform`](core.md#transform) | Core
30-
`operation.impl.GetVariable` | Core
31-
`operation.impl.GetVariables` | Core
30+
[`operation.impl.GetVariable`](core.md#getvariable) | Core
31+
[`operation.impl.GetVariables`](core.md#getvariables) | Core
3232
[`operation.impl.get.GetGraphCreatedTime`](core.md#getgraphcreatedtime) | Core
3333
[`operation.impl.Limit`](core.md#limit) | Core
3434
`operation.impl.Map` | Core
3535
[`operation.impl.Reduce`](core.md#reduce) | Core
3636
`operation.impl.SampleElementsForSplitPoints` | Core
37-
`operation.impl.SetVariable` | Core
37+
[`operation.impl.SetVariable`](core.md#setvariable) | Core
3838
`operation.impl.SplitStoreFromFile` | Core
3939
`operation.impl.SplitStoreFromIterable` | Core
4040
`operation.impl.Validate` | Core
@@ -84,7 +84,7 @@ Operation | Type
8484
[`store.operation.DeleteAllData`](core.md#deletealldata) | Core
8585
[`store.operation.GetSchema`](core.md#getschema) | Store
8686
[`store.operation.GetTraits`](core.md#gettraits) | Store
87-
`store.operation.HasTrait` | Store
87+
[`store.operation.HasTrait`](core.md#hastrait) | Store
8888
`store.operation.add.AddSchemaToLibrary` | Store
8989
`store.operation.add.AddStorePropertiesToLibrary` | Store
9090
`federatedstore.operation.AddGraph` | Federated

0 commit comments

Comments
 (0)