ToSingletonList

See javadoc - uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList

Available since Gaffer version 1.7.0

Converts a single input of type T to a List

Required fields

No required fields

Examples

To singleton list example

Using this directed graph:


    --> 4 <--
  /     ^     \
 /      |      \
1  -->  2  -->  3
         \
           -->  5

Java
JSON
Full JSON
Python
final ToSingletonList<Integer> opChain = new ToSingletonList.Builder<Integer>()
        .input(4)
        .build();
{
  "class" : "ToSingletonList",
  "input" : 4
}
{
  "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList",
  "input" : 4
}
g.ToSingletonList( 
  input=4 
)

Result:

Java
JSON
4
[ 4 ]


To singleton list in chain example

Using this directed graph:


    --> 4 <--
  /     ^     \
 /      |      \
1  -->  2  -->  3
         \
           -->  5

Java
JSON
Full JSON
Python
final OperationChain<Iterable<?>> opChain = new OperationChain.Builder()
        .first(new GetAdjacentIds.Builder()
                .input(new EntitySeed(1))
                .build())
        .then(new ForEach.Builder<>()
                .operation(new OperationChain.Builder()
                        .first(new ToSingletonList<EntitySeed>())
                        .then(new GetAdjacentIds())
                        .then(new ToVertices())
                        .build())
                .build())
        .build();
{
  "class" : "OperationChain",
  "operations" : [ {
    "class" : "GetAdjacentIds",
    "input" : [ {
      "class" : "EntitySeed",
      "vertex" : 1
    } ]
  }, {
    "class" : "ForEach",
    "operation" : {
      "class" : "OperationChain",
      "operations" : [ {
        "class" : "ToSingletonList"
      }, {
        "class" : "GetAdjacentIds"
      }, {
        "class" : "ToVertices"
      } ]
    }
  } ]
}
{
  "class" : "uk.gov.gchq.gaffer.operation.OperationChain",
  "operations" : [ {
    "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds",
    "input" : [ {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 1
    } ]
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.ForEach",
    "operation" : {
      "class" : "uk.gov.gchq.gaffer.operation.OperationChain",
      "operations" : [ {
        "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList"
      }, {
        "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds"
      }, {
        "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToVertices"
      } ]
    }
  } ]
}
g.OperationChain( 
  operations=[ 
    g.GetAdjacentIds( 
      input=[ 
        g.EntitySeed( 
          vertex=1 
        ) 
      ] 
    ), 
    g.ForEach( 
      operation=g.OperationChain( 
        operations=[ 
          g.ToSingletonList(), 
          g.GetAdjacentIds(), 
          g.ToVertices() 
        ] 
      ) 
    ) 
  ] 
)

Result:

Java
JSON
[ 4 --> 3 --> 1 --> 5 ]
[ 3 --> 1 --> 2 ]
[ [ 4, 3, 1, 5 ], [ 3, 1, 2 ] ]


results matching ""

    No results matching ""