Skip to content

Commit

Permalink
Variables and Traits Docs (#542)
Browse files Browse the repository at this point in the history
* add missing examples

* address comment
  • Loading branch information
cn337131 authored Dec 11, 2024
1 parent 7eef07b commit 5fc5b01
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 4 deletions.
149 changes: 149 additions & 0 deletions docs/reference/operations-guide/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -4524,11 +4524,118 @@ Gets the Schema of a Graph. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/
}
```

## Variables

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.

### SetVariable

Stores a variable in the Context variable map. Takes a variable
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)

??? example "Example setting a variable"
=== "Java"

``` java
final SetVariable op = new SetVariable.Builder()
.variableName("varName")
.input(5)
.build();
```

=== "JSON"

``` json
{
"class" : "SetVariable",
"variableName": "varName",
"input": 5
}
```

### GetVariable

Gets a variable from the Context variable map. Takes the variable
name as an input. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/operation/impl/GetVariable.html)

??? example "Example getting a variable"
=== "Java"

``` java
final GetVariable op = new GetVariable.Builder()
.variableName("varName")
.build();
```

=== "JSON"

``` json
{
"class" : "GetVariable",
"variableName": "varName"
}
```

Results:

=== "Java"

``` java
5
```

=== "JSON"

``` json
5
```

### GetVariables

Gets all the variables from the Context variable map. Takes a list of variable names
as an input. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/operation/impl/GetVariables.html)

??? example "Example getting all variables"
=== "Java"

``` java
final List<String> variableNames = Arrays.asList("varName");
final GetVariables op = new GetVariables.Builder()
.variableNames(variableNames)
.build();
```

=== "JSON"

``` json
{
"class" : "GetVariables",
"variableNames": ["varName"]
}
```

Results:

=== "Java"

``` java
5
```

=== "JSON"

``` json
5
```

## GetTraits

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

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

=== "Java"

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

## HasTrait

Checks if a Store has a given trait. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/store/operation/HasTrait.html)

??? example "Example checking if store has trait"
`currentTraits` is an optional field that holds a boolean value and
defaults to true. It is used to check if the provided traits exists in the either the store default (false)
or the schema current traits (true).

=== "Java"

``` java
final HasTrait operation = new HasTrait.Builder()
.currentTraits(false)
.trait(PRE_AGGREGATION_FILTERING)
.build();
```

=== "JSON"

``` json
{
"class" : "HasTrait",
"currentTraits" : false,
"trait": "PRE_AGGREGATION_FILTERING"
}
```

Results:

=== "Java"

``` java
true
```

=== "JSON"

``` json
true
```

## DeleteAllData

Deletes all retained data including deleting the graph. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/store/operation/DeleteAllData.html)
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/operations-guide/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ Operation | Type
[`operation.impl.function.Aggregate`](core.md#aggregate) | Core
[`operation.impl.function.Filter`](core.md#filter) | Core
[`operation.impl.function.Transform`](core.md#transform) | Core
`operation.impl.GetVariable` | Core
`operation.impl.GetVariables` | Core
[`operation.impl.GetVariable`](core.md#getvariable) | Core
[`operation.impl.GetVariables`](core.md#getvariables) | Core
[`operation.impl.get.GetGraphCreatedTime`](core.md#getgraphcreatedtime) | Core
[`operation.impl.Limit`](core.md#limit) | Core
`operation.impl.Map` | Core
[`operation.impl.Reduce`](core.md#reduce) | Core
`operation.impl.SampleElementsForSplitPoints` | Core
`operation.impl.SetVariable` | Core
[`operation.impl.SetVariable`](core.md#setvariable) | Core
`operation.impl.SplitStoreFromFile` | Core
`operation.impl.SplitStoreFromIterable` | Core
`operation.impl.Validate` | Core
Expand Down Expand Up @@ -84,7 +84,7 @@ Operation | Type
[`store.operation.DeleteAllData`](core.md#deletealldata) | Core
[`store.operation.GetSchema`](core.md#getschema) | Store
[`store.operation.GetTraits`](core.md#gettraits) | Store
`store.operation.HasTrait` | Store
[`store.operation.HasTrait`](core.md#hastrait) | Store
`store.operation.add.AddSchemaToLibrary` | Store
`store.operation.add.AddStorePropertiesToLibrary` | Store
`federatedstore.operation.AddGraph` | Federated
Expand Down

0 comments on commit 5fc5b01

Please sign in to comment.