本文整理了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
暂无
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!