Codota Logo
FreqMap.<init>
Code IndexAdd Codota to your IDE (free)

How to use
uk.gov.gchq.gaffer.types.FreqMap
constructor

Best Java code snippets using uk.gov.gchq.gaffer.types.FreqMap.<init> (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Point p =
  • Codota Iconnew Point(x, y)
  • Codota Iconnew Point()
  • Codota IconMouseEvent e;e.getPoint()
  • Smart code suggestions by Codota
}
origin: gchq/Gaffer

  @Override
  public FreqMap deserialiseEmpty() {
    return new FreqMap();
  }
}
origin: gchq/Gaffer

  @Override
  public FreqMap apply(final Object value) {
    return new FreqMap(null != value ? value.toString() : null);
  }
}
origin: gchq/Gaffer

/**
 * Creates a filtered copy of the map using a supplied predicate.<br>
 * Returns a copy of the map if predicate supplied is null.
 *
 * @param map The frequency map that is to be sorted through
 * @return A new frequency map with only the filtered entries present.
 */
private FreqMap filterPredicate(final FreqMap map) {
  final FreqMap f = new FreqMap();
  if (predicate == null) {
    map.forEach(f::upsert);
  } else {
    map.entrySet().stream().filter(e -> predicate.test(e.getKey()))
        .forEach(e -> f.upsert(e.getKey(), e.getValue()));
  }
  return f;
}
origin: gchq/Gaffer

@Before
public void initialiseFreqMap() {
  freqMap = new FreqMap();
}
origin: gchq/Gaffer

@Override
public void shouldDeserialiseEmpty() throws SerialisationException {
  // When
  final FreqMap value = serialiser.deserialiseEmpty();
  // Then
  assertEquals(new FreqMap(), value);
}
origin: gchq/Gaffer

@Test
public void shouldConvertObjectToFreqMap() {
  // Given
  final ToFreqMap function = new ToFreqMap();
  final Object value = 1L;
  // When
  final FreqMap result = function.apply(value);
  // Then
  assertEquals(new FreqMap(value.toString()), result);
}
origin: gchq/Gaffer

@Test
public void shouldConvertStringToFreqMap() {
  // Given
  final ToFreqMap function = new ToFreqMap();
  final Object value = "value1";
  // When
  final FreqMap result = function.apply(value);
  // Then
  assertEquals(new FreqMap(value.toString()), result);
}
origin: gchq/Gaffer

  @Override
  public Pair<FreqMap, byte[]>[] getHistoricSerialisationPairs() {
    final FreqMap freqMap = new FreqMap();
    freqMap.put("x", 10L);
    freqMap.put("y", 5L);
    freqMap.put("z", 20L);
    return new Pair[]{
        new Pair(freqMap, new byte[]{120, 0, 10, 0, 121, 0, 5, 0, 122, 0, 20})
    };
  }
}
origin: gchq/Gaffer

@Test
public void shouldConvertNullToFreqMap() {
  // Given
  final ToFreqMap function = new ToFreqMap();
  final Object value = null;
  // When
  final FreqMap result = function.apply(value);
  // Then
  assertEquals(new FreqMap((String) null), result);
}
origin: gchq/Gaffer

@Test
public void canSerialiseEmptyFreqMap() throws SerialisationException {
  byte[] b = serialiser.serialise(new FreqMap());
  Object o = serialiser.deserialise(b);
  assertEquals(FreqMap.class, o.getClass());
  assertEquals(0, ((FreqMap) o).size());
}
origin: gchq/Gaffer

@Override
public FreqMap deserialise(final byte[] bytes) throws
    SerialisationException {
  FreqMap freqMap = new FreqMap();
  if (bytes.length == 0) {
    return freqMap;
origin: gchq/Gaffer

@Test
public void shouldMergeFreqMaps() {
  // Given
  final FreqMapAggregator aggregator = new FreqMapAggregator();
  final FreqMap freqMap1 = new FreqMap();
  freqMap1.put("1", 2L);
  freqMap1.put("2", 3L);
  final FreqMap freqMap2 = new FreqMap();
  freqMap2.put("2", 4L);
  freqMap2.put("3", 5L);
  // When
  final FreqMap result = aggregator.apply(freqMap1, freqMap2);
  // Then
  assertEquals((Long) 2L, result.get("1"));
  assertEquals((Long) 7L, result.get("2"));
  assertEquals((Long) 5L, result.get("3"));
}
origin: gchq/Gaffer

@Before
public void initFreqMap() {
  this.freqMap = new FreqMap();
  freqMap.upsert("cat");
  freqMap.upsert("cat");
  freqMap.upsert("dog");
  freqMap.upsert("cow");
  freqMap.upsert("cow");
  freqMap.upsert("catdog");
  freqMap.upsert("catdog");
  freqMap.upsert("catdog");
  freqMap.upsert("cat");
  freqMap.upsert("cat");
}
origin: gchq/Gaffer

@Test
public void shouldSerialiseDeserialiseFreqMapWithAnEmptyKey() throws SerialisationException {
  // Given
  final FreqMap freqMap = new FreqMap();
  freqMap.put("", 10L);
  freqMap.put("y", 5L);
  freqMap.put("z", 20L);
  // When
  final byte[] serialised = serialiser.serialise(freqMap);
  final FreqMap deserialised = serialiser.deserialise(serialised);
  assertEquals((Long) 10L, deserialised.get(""));
  assertEquals((Long) 5L, deserialised.get("y"));
  assertEquals((Long) 20L, deserialised.get("z"));
}
origin: gchq/Gaffer

@Test
public void shouldSkipEntryWithNullKey() throws SerialisationException {
  // Given
  final FreqMap freqMap = new FreqMap();
  freqMap.put(null, 10L);
  freqMap.put("y", 5L);
  freqMap.put("z", 20L);
  // When
  final byte[] serialised = serialiser.serialise(freqMap);
  final FreqMap deserialised = serialiser.deserialise(serialised);
  assertFalse(deserialised.containsKey("x"));
  assertEquals((Long) 5L, deserialised.get("y"));
  assertEquals((Long) 20L, deserialised.get("z"));
}
origin: gchq/Gaffer

@Test
public void shouldSerialiseDeserialiseFreqMapWithValues() throws SerialisationException {
  // Given
  final FreqMap freqMap = new FreqMap();
  freqMap.put("x", 10L);
  freqMap.put("y", 5L);
  freqMap.put("z", 20L);
  // When
  final byte[] serialised = serialiser.serialise(freqMap);
  final FreqMap deserialised = serialiser.deserialise(serialised);
  // Then
  assertEquals((Long) 10L, deserialised.get("x"));
  assertEquals((Long) 5L, deserialised.get("y"));
  assertEquals((Long) 20L, deserialised.get("z"));
}
origin: gchq/Gaffer

@Test
public void shouldSkipEntryWithNullValues() throws SerialisationException {
  // Given
  final FreqMap freqMap = new FreqMap();
  freqMap.put("v", null);
  freqMap.put("w", 5L);
  freqMap.put("x", null);
  freqMap.put("y", 20L);
  freqMap.put("z", null);
  // When
  final byte[] serialised = serialiser.serialise(freqMap);
  final FreqMap deserialised = serialiser.deserialise(serialised);
  assertFalse(deserialised.containsKey("v"));
  assertEquals((Long) 5L, deserialised.get("w"));
  assertFalse(deserialised.containsKey("x"));
  assertEquals((Long) 20L, deserialised.get("y"));
  assertFalse(deserialised.containsKey("z"));
}
origin: uk.gov.gchq.gaffer/type

  @Override
  public FreqMap deserialiseEmpty() {
    return new FreqMap();
  }
}
origin: uk.gov.gchq.gaffer/parquet-store

@Override
public FreqMap deserialise(final Object[] objects) throws SerialisationException {
  if (objects.length == 1) {
    if (objects[0] instanceof Map) {
      return new FreqMap((Map<String, Long>) objects[0]);
    } else if (null == objects[0]) {
      return null;
    }
  }
  throw new SerialisationException("Could not de-serialise objects to a FreqMap");
}
origin: uk.gov.gchq.gaffer/road-traffic-generators

  private FreqMap getVehicleCounts(final CSVRecord record) {
    final FreqMap freqMap = new FreqMap();
    for (final RoadTrafficDataField field : RoadTrafficDataField.VEHICLE_COUNTS) {
      final String value = record.get(field.fieldName());
      freqMap.upsert(field.name(), value.isEmpty() ? 0 : Long.parseLong(value));
    }
    return freqMap;
  }
}
uk.gov.gchq.gaffer.typesFreqMap<init>

Popular methods of FreqMap

  • put
  • upsert
    Adds a new key and value to the map if the key is not already there. If the key is already there, th
  • containsKey
  • get
  • entrySet
  • forEach
  • size
  • values

Popular in Java

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • putExtra (Intent)
  • BufferedInputStream (java.io)
    Wraps an existing InputStream and buffers the input. Expensive interaction with the underlying input
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
  • Option (scala)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now