GenerateElements

See javadoc - uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements

Available since Gaffer version 1.0.0

Required fields

The following fields are required:

  • elementGenerator

Examples

Generate elements from strings

Using this directed graph:


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

Java
JSON
Full JSON
Python
final GenerateElements<String> operation = new GenerateElements.Builder<String>()
        .input("1,1", "1,2,1")
        .generator(new ElementGenerator())
        .build();
{
  "class" : "GenerateElements",
  "input" : [ "1,1", "1,2,1" ],
  "elementGenerator" : {
    "class" : "ElementGenerator"
  }
}
{
  "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements",
  "input" : [ "1,1", "1,2,1" ],
  "elementGenerator" : {
    "class" : "uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator"
  }
}
g.GenerateElements( 
  input=[ 
    "1,1", 
    "1,2,1" 
  ], 
  element_generator=g.ElementGenerator( 
    class_name="uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator", 
    fields={'class': 'uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator'} 
  ) 
)

Result:

Java
JSON
Entity[vertex=1,group=entity,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=1,destination=2,directed=true,group=edge,properties=Properties[count=<java.lang.Integer>1]]
[ {
  "class" : "uk.gov.gchq.gaffer.data.element.Entity",
  "group" : "entity",
  "vertex" : 1,
  "properties" : {
    "count" : 1
  }
}, {
  "class" : "uk.gov.gchq.gaffer.data.element.Edge",
  "group" : "edge",
  "source" : 1,
  "destination" : 2,
  "directed" : true,
  "properties" : {
    "count" : 1
  }
} ]


Generate elements from domain objects

Using this directed graph:


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

Java
JSON
Full JSON
Python
final GenerateElements<Object> operation = new GenerateElements.Builder<>()
        .input(new DomainObject1(1, 1),
                new DomainObject2(1, 2, 1))
        .generator(new DomainObjectGenerator())
        .build();
{
  "class" : "GenerateElements",
  "input" : [ {
    "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject1",
    "a" : 1,
    "c" : 1
  }, {
    "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject2",
    "a" : 1,
    "b" : 2,
    "c" : 1
  } ],
  "elementGenerator" : {
    "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObjectGenerator"
  }
}
{
  "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements",
  "input" : [ {
    "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject1",
    "a" : 1,
    "c" : 1
  }, {
    "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject2",
    "a" : 1,
    "b" : 2,
    "c" : 1
  } ],
  "elementGenerator" : {
    "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObjectGenerator"
  }
}
g.GenerateElements( 
  element_generator=g.ElementGenerator( 
    fields={'class': 'uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObjectGenerator'}, 
    class_name="uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObjectGenerator" 
  ), 
  input=[ 
    {'a': 1, 'class': 'uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject1', 'c': 1}, 
    {'b': 2, 'a': 1, 'class': 'uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject2', 'c': 1} 
  ] 
)

Result:

Java
JSON
Entity[vertex=1,group=entity,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=1,destination=2,directed=true,group=edge,properties=Properties[count=<java.lang.Integer>1]]
[ {
  "class" : "uk.gov.gchq.gaffer.data.element.Entity",
  "group" : "entity",
  "vertex" : 1,
  "properties" : {
    "count" : 1
  }
}, {
  "class" : "uk.gov.gchq.gaffer.data.element.Edge",
  "group" : "edge",
  "source" : 1,
  "destination" : 2,
  "directed" : true,
  "properties" : {
    "count" : 1
  }
} ]


results matching ""

    No results matching ""