org.apache.flink.streaming.runtime.operators.windowing.KeyMap.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.apache.flink.streaming.runtime.operators.windowing.KeyMap.<init>()方法的一些代码示例,展示了KeyMap.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyMap.<init>()方法的具体详情如下:
包路径:org.apache.flink.streaming.runtime.operators.windowing.KeyMap
类名称:KeyMap
方法名:<init>

KeyMap.<init>介绍

[英]Creates a new hash table with the default initial capacity.
[中]创建具有默认初始容量的新哈希表。

代码示例

代码示例来源:origin: apache/flink

@Test
public void testPutAndGetRandom() {
  try {
    final KeyMap<Integer, Integer> map = new KeyMap<>();
    final Random rnd = new Random();

代码示例来源:origin: apache/flink

@Test
public void testSizeComparator() {
  try {
    KeyMap<String, String> map1 = new KeyMap<>(5);
    KeyMap<String, String> map2 = new KeyMap<>(80);
    assertTrue(map1.getCurrentTableCapacity() < map2.getCurrentTableCapacity());
    assertTrue(KeyMap.CapacityDescendingComparator.INSTANCE.compare(map1, map1) == 0);
    assertTrue(KeyMap.CapacityDescendingComparator.INSTANCE.compare(map2, map2) == 0);
    assertTrue(KeyMap.CapacityDescendingComparator.INSTANCE.compare(map1, map2) > 0);
    assertTrue(KeyMap.CapacityDescendingComparator.INSTANCE.compare(map2, map1) < 0);
  }
  catch (Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}

代码示例来源:origin: apache/flink

final KeyMap<Integer, Integer>[] maps = (KeyMap<Integer, Integer>[]) new KeyMap<?, ?>[numMaps];
for (int i = 0; i < numMaps; i++) {
  maps[i] = new KeyMap<>();

代码示例来源:origin: apache/flink

@Test
public void testPutDuplicateKeysAndGrowth() {
  try {
    final KeyMap<Integer, Integer> map = new KeyMap<>();
    final int numElements = 1000000;

代码示例来源:origin: apache/flink

@Test
public void testPutIfAbsentDuplicateKeysAndGrowth() {
  try {
    KeyMap<Integer, Integer> map = new KeyMap<>();
    IntegerFactory factory = new IntegerFactory();
    final int numElements = 1000000;
    for (int i = 0; i < numElements; i++) {
      int val = 2 * i + 1;
      factory.set(val);
      Integer put = map.putIfAbsent(i, factory);
      assertEquals(val, put.intValue());
    }
    for (int i = 0; i < numElements; i += 3) {
      factory.set(2 * i);
      Integer put = map.putIfAbsent(i, factory);
      assertEquals(2 * i + 1, put.intValue());
    }
    for (int i = 0; i < numElements; i++) {
      assertEquals(2 * i + 1, map.get(i).intValue());
    }
    assertEquals(numElements, map.size());
    assertEquals(numElements, map.traverseAndCountElements());
    assertEquals(1 << 21, map.getCurrentTableCapacity());
    assertTrue(map.getLongestChainLength() <= 7);
  }
  catch (Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}

代码示例来源:origin: apache/flink

map = new KeyMap<>();
assertEquals(64, map.getCurrentTableCapacity());
assertEquals(6, map.getLog2TableCapacity());
map = new KeyMap<>(0);
assertEquals(64, map.getCurrentTableCapacity());
assertEquals(6, map.getLog2TableCapacity());
map = new KeyMap<>(1);
assertEquals(64, map.getCurrentTableCapacity());
assertEquals(6, map.getLog2TableCapacity());
map = new KeyMap<>(9);
assertEquals(64, map.getCurrentTableCapacity());
assertEquals(6, map.getLog2TableCapacity());
map = new KeyMap<>(63);
assertEquals(64, map.getCurrentTableCapacity());
assertEquals(6, map.getLog2TableCapacity());
map = new KeyMap<>(64);
assertEquals(128, map.getCurrentTableCapacity());
assertEquals(7, map.getLog2TableCapacity());
map = new KeyMap<>(500);
assertEquals(512, map.getCurrentTableCapacity());
assertEquals(9, map.getLog2TableCapacity());
map = new KeyMap<>(127);

代码示例来源:origin: apache/flink

@Test
public void testPutUniqueKeysAndGrowth() {
  try {
    KeyMap<Integer, Integer> map = new KeyMap<>();

代码示例来源:origin: apache/flink

@Test
public void testPutIfAbsentUniqueKeysAndGrowth() {
  try {
    KeyMap<Integer, Integer> map = new KeyMap<>();
    IntegerFactory factory = new IntegerFactory();

代码示例来源:origin: org.apache.flink/flink-streaming-java_2.10

public void slidePanes(int panesToKeep) {
  if (panesToKeep > 1) {
    // the current pane becomes the latest previous pane
    previousPanes.addLast(latestPane);
    // truncate the history
    while (previousPanes.size() >= panesToKeep) {
      previousPanes.removeFirst();
    }
  }
  // we need a new latest pane
  latestPane = new KeyMap<>();
}

代码示例来源:origin: org.apache.flink/flink-streaming-java_2.10

public void readFromInput(
    final DataInputView input,
    final TypeSerializer<Key> keySerializer,
    final TypeSerializer<Aggregate> aggSerializer) throws IOException {
  validateMagicNumber(BEGIN_OF_STATE_MAGIC_NUMBER, input.readInt());
  int numPanes = input.readInt();
  // read from the past towards the presence
  while (numPanes > 0) {
    validateMagicNumber(BEGIN_OF_PANE_MAGIC_NUMBER, input.readInt());
    KeyMap<Key, Aggregate> pane = (numPanes == 1) ? latestPane : new KeyMap<Key, Aggregate>();
    final int numElementsInPane = input.readInt();
    for (int i = numElementsInPane - 1; i >= 0; i--) {
      Key k = keySerializer.deserialize(input);
      Aggregate a = aggSerializer.deserialize(input);
      pane.put(k, a);
    }
    if (numPanes > 1) {
      previousPanes.addLast(pane);
    }
    numPanes--;
  }
}

相关文章