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

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

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

KeyMap.allocateTable介绍

暂无

代码示例

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

private void growTable() {
  final int newSize = table.length << 1;
  // only grow if there is still space to grow the table
  if (newSize > 0) {
    final Entry<K, V>[] oldTable = this.table;
    final Entry<K, V>[] newTable = allocateTable(newSize);
    final int newShift = shift - 1;
    final int newMask = newSize - 1;
    // go over all slots from the table. since we hash to adjacent positions in
    // the new hash table, this is actually cache efficient
    for (Entry<K, V> entry : oldTable) {
      // traverse the chain for each slot
      while (entry != null) {
        final int newPos = (entry.hashCode >> newShift) & newMask;
        Entry<K, V> nextEntry = entry.next;
        entry.next = newTable[newPos];
        newTable[newPos] = entry;
        entry = nextEntry;
      }
    }
    this.table = newTable;
    this.shift = newShift;
    this.rehashThreshold = getRehashThreshold(newSize);
    this.log2size += 1;
  }
}

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

/**
 * Creates a new table with a capacity tailored to the given expected number of elements.
 *
 * @param expectedNumberOfElements The number of elements to tailor the capacity to.
 */
public KeyMap(int expectedNumberOfElements) {
  if (expectedNumberOfElements < 0) {
    throw new IllegalArgumentException("Invalid capacity: " + expectedNumberOfElements);
  }
  // round up to the next power or two
  // guard against too small capacity and integer overflows
  int capacity = Integer.highestOneBit(expectedNumberOfElements) << 1;
  capacity = capacity >= 0 ? Math.max(MIN_CAPACITY, capacity) : MAX_CAPACITY;
  // this also acts as a sanity check
  log2size = MathUtils.log2strict(capacity);
  shift = FULL_BIT_RANGE - log2size;
  table = allocateTable(capacity);
  rehashThreshold = getRehashThreshold(capacity);
}

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

private void growTable() {
  final int newSize = table.length << 1;
  // only grow if there is still space to grow the table
  if (newSize > 0) {
    final Entry<K, V>[] oldTable = this.table;
    final Entry<K, V>[] newTable = allocateTable(newSize);
    final int newShift = shift - 1;
    final int newMask = newSize - 1;
    // go over all slots from the table. since we hash to adjacent positions in
    // the new hash table, this is actually cache efficient
    for (Entry<K, V> entry : oldTable) {
      // traverse the chain for each slot
      while (entry != null) {
        final int newPos = (entry.hashCode >> newShift) & newMask;
        Entry<K, V> nextEntry = entry.next;
        entry.next = newTable[newPos];
        newTable[newPos] = entry;
        entry = nextEntry;
      }
    }
    this.table = newTable;
    this.shift = newShift;
    this.rehashThreshold = getRehashThreshold(newSize);
    this.log2size += 1;
  }
}

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

private void growTable() {
  final int newSize = table.length << 1;
  // only grow if there is still space to grow the table
  if (newSize > 0) {
    final Entry<K, V>[] oldTable = this.table;
    final Entry<K, V>[] newTable = allocateTable(newSize);
    final int newShift = shift - 1;
    final int newMask = newSize - 1;
    // go over all slots from the table. since we hash to adjacent positions in
    // the new hash table, this is actually cache efficient
    for (Entry<K, V> entry : oldTable) {
      // traverse the chain for each slot
      while (entry != null) {
        final int newPos = (entry.hashCode >> newShift) & newMask;
        Entry<K, V> nextEntry = entry.next;
        entry.next = newTable[newPos];
        newTable[newPos] = entry;
        entry = nextEntry;
      }
    }
    this.table = newTable;
    this.shift = newShift;
    this.rehashThreshold = getRehashThreshold(newSize);
    this.log2size += 1;
  }
}

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

/**
 * Creates a new table with a capacity tailored to the given expected number of elements.
 *
 * @param expectedNumberOfElements The number of elements to tailor the capacity to.
 */
public KeyMap(int expectedNumberOfElements) {
  if (expectedNumberOfElements < 0) {
    throw new IllegalArgumentException("Invalid capacity: " + expectedNumberOfElements);
  }
  // round up to the next power or two
  // guard against too small capacity and integer overflows
  int capacity = Integer.highestOneBit(expectedNumberOfElements) << 1;
  capacity = capacity >= 0 ? Math.max(MIN_CAPACITY, capacity) : MAX_CAPACITY;
  // this also acts as a sanity check
  log2size = MathUtils.log2strict(capacity);
  shift = FULL_BIT_RANGE - log2size;
  table = allocateTable(capacity);
  rehashThreshold = getRehashThreshold(capacity);
}

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

/**
 * Creates a new table with a capacity tailored to the given expected number of elements.
 *
 * @param expectedNumberOfElements The number of elements to tailor the capacity to.
 */
public KeyMap(int expectedNumberOfElements) {
  if (expectedNumberOfElements < 0) {
    throw new IllegalArgumentException("Invalid capacity: " + expectedNumberOfElements);
  }
  // round up to the next power or two
  // guard against too small capacity and integer overflows
  int capacity = Integer.highestOneBit(expectedNumberOfElements) << 1;
  capacity = capacity >= 0 ? Math.max(MIN_CAPACITY, capacity) : MAX_CAPACITY;
  // this also acts as a sanity check
  log2size = MathUtils.log2strict(capacity);
  shift = FULL_BIT_RANGE - log2size;
  table = allocateTable(capacity);
  rehashThreshold = getRehashThreshold(capacity);
}

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

private void growTable() {
  final int newSize = table.length << 1;
  // only grow if there is still space to grow the table
  if (newSize > 0) {
    final Entry<K, V>[] oldTable = this.table;
    final Entry<K, V>[] newTable = allocateTable(newSize);
    final int newShift = shift - 1;
    final int newMask = newSize - 1;
    // go over all slots from the table. since we hash to adjacent positions in
    // the new hash table, this is actually cache efficient
    for (Entry<K, V> entry : oldTable) {
      // traverse the chain for each slot
      while (entry != null) {
        final int newPos = (entry.hashCode >> newShift) & newMask;
        Entry<K, V> nextEntry = entry.next;
        entry.next = newTable[newPos];
        newTable[newPos] = entry;
        entry = nextEntry;
      }
    }
    this.table = newTable;
    this.shift = newShift;
    this.rehashThreshold = getRehashThreshold(newSize);
    this.log2size += 1;
  }
}

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

/**
 * Creates a new table with a capacity tailored to the given expected number of elements.
 *
 * @param expectedNumberOfElements The number of elements to tailor the capacity to.
 */
public KeyMap(int expectedNumberOfElements) {
  if (expectedNumberOfElements < 0) {
    throw new IllegalArgumentException("Invalid capacity: " + expectedNumberOfElements);
  }
  // round up to the next power or two
  // guard against too small capacity and integer overflows
  int capacity = Integer.highestOneBit(expectedNumberOfElements) << 1;
  capacity = capacity >= 0 ? Math.max(MIN_CAPACITY, capacity) : MAX_CAPACITY;
  // this also acts as a sanity check
  log2size = MathUtils.log2strict(capacity);
  shift = FULL_BIT_RANGE - log2size;
  table = allocateTable(capacity);
  rehashThreshold = getRehashThreshold(capacity);
}

相关文章