PredicateMap

See javadoc - uk.gov.gchq.koryphe.predicate.PredicateMap

Available since Koryphe version 1.0.0

Extracts a value from a map then applies the predicate to it

Examples

Freq map is more than 2

Java
JSON
Full JSON
Python
final PredicateMap function = new PredicateMap("key1", new IsMoreThan(2L));
{
  "class" : "PredicateMap",
  "predicate" : {
    "class" : "IsMoreThan",
    "orEqualTo" : false,
    "value" : {
      "Long" : 2
    }
  },
  "key" : "key1"
}
{
  "class" : "uk.gov.gchq.koryphe.predicate.PredicateMap",
  "predicate" : {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan",
    "orEqualTo" : false,
    "value" : {
      "java.lang.Long" : 2
    }
  },
  "key" : "key1"
}
g.PredicateMap( 
  key="key1", 
  predicate=g.IsMoreThan( 
    value={'java.lang.Long': 2}, 
    or_equal_to=False 
  ) 
)

Input type:

java.util.Map

Example inputs:

Input TypeInputResult
uk.gov.gchq.gaffer.types.FreqMap{key1=1}false
uk.gov.gchq.gaffer.types.FreqMap{key1=2}false
uk.gov.gchq.gaffer.types.FreqMap{key1=3}true
uk.gov.gchq.gaffer.types.FreqMap{key1=3, key2=0}true
uk.gov.gchq.gaffer.types.FreqMap{key2=3}false

Freq map is more than or equal to 2

Java
JSON
Full JSON
Python
final PredicateMap function = new PredicateMap("key1", new IsMoreThan(2L, true));
{
  "class" : "PredicateMap",
  "predicate" : {
    "class" : "IsMoreThan",
    "orEqualTo" : true,
    "value" : {
      "Long" : 2
    }
  },
  "key" : "key1"
}
{
  "class" : "uk.gov.gchq.koryphe.predicate.PredicateMap",
  "predicate" : {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan",
    "orEqualTo" : true,
    "value" : {
      "java.lang.Long" : 2
    }
  },
  "key" : "key1"
}
g.PredicateMap( 
  key="key1", 
  predicate=g.IsMoreThan( 
    value={'java.lang.Long': 2}, 
    or_equal_to=True 
  ) 
)

Input type:

java.util.Map

Example inputs:

Input TypeInputResult
uk.gov.gchq.gaffer.types.FreqMap{key1=1}false
uk.gov.gchq.gaffer.types.FreqMap{key1=2}true
uk.gov.gchq.gaffer.types.FreqMap{key1=3}true
uk.gov.gchq.gaffer.types.FreqMap{key1=3, key2=0}true
uk.gov.gchq.gaffer.types.FreqMap{key2=3}false

Map with date key has a value that exists

Java
JSON
Full JSON
Python
final PredicateMap function = new PredicateMap(new Date(0L), new Exists());
{
  "class" : "PredicateMap",
  "predicate" : {
    "class" : "Exists"
  },
  "key" : {
    "Date" : 0
  }
}
{
  "class" : "uk.gov.gchq.koryphe.predicate.PredicateMap",
  "predicate" : {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.Exists"
  },
  "key" : {
    "java.util.Date" : 0
  }
}
g.PredicateMap( 
  key={'java.util.Date': 0}, 
  predicate=g.Exists() 
)

Input type:

java.util.Map

Example inputs:

Input TypeInputResult
java.util.HashMap{Thu Jan 01 00:00:00 UTC 1970=1}true
java.util.HashMap{Tue Oct 11 10:39:27 UTC 2022=2}false

results matching ""

    No results matching ""