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

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

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

KeyMap.hash介绍

暂无

代码示例

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

/**
 * Looks up the value mapped under the given key. Returns null if no value is mapped under this key.
 *
 * @param key The key to look up.
 * @return The value associated with the key, or null, if no value is found for the key.
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public V get(K key) {
  final int hash = hash(key);
  final int slot = indexOf(hash);
  // search the chain from the slot
  for (Entry<K, V> entry = table[slot]; entry != null; entry = entry.next) {
    if (entry.hashCode == hash && entry.key.equals(key)) {
      return entry.value;
    }
  }
  // not found
  return null;
}

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

/**
 * Inserts the given value, mapped under the given key. If the table already contains a value for
 * the key, the value is replaced and returned. If no value is contained, yet, the function
 * returns null.
 *
 * @param key The key to insert.
 * @param value The value to insert.
 * @return The previously mapped value for the key, or null, if no value was mapped for the key.
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public final V put(K key, V value) {
  final int hash = hash(key);
  final int slot = indexOf (hash);
  // search the chain from the slot
  for (Entry<K, V> e = table[slot]; e != null; e = e.next) {
    Object k;
    if (e.hashCode == hash && ((k = e.key) == key || key.equals(k))) {
      // found match
      V old = e.value;
      e.value = value;
      return old;
    }
  }
  // no match, insert a new value
  insertNewEntry(hash, key, value, slot);
  return null;
}

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

final int hash = hash(key);
final int slot = indexOf(hash);

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

/**
 * Inserts a value for the given key, if no value is yet contained for that key. Otherwise,
 * returns the value currently contained for the key.
 *
 * <p>The value that is inserted in case that the key is not contained, yet, is lazily created
 * using the given factory.
 *
 * @param key The key to insert.
 * @param factory The factory that produces the value, if no value is contained, yet, for the key.
 * @return The value in the map after this operation (either the previously contained value, or the
 *         newly created value).
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public final V putIfAbsent(K key, LazyFactory<V> factory) {
  final int hash = hash(key);
  final int slot = indexOf(hash);
  // search the chain from the slot
  for (Entry<K, V> entry = table[slot]; entry != null; entry = entry.next) {
    if (entry.hashCode == hash && entry.key.equals(key)) {
      // found match
      return entry.value;
    }
  }
  // no match, insert a new value
  V value = factory.create();
  insertNewEntry(hash, key, value, slot);
  // return the created value
  return value;
}

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

/**
 * Looks up the value mapped under the given key. Returns null if no value is mapped under this key.
 *
 * @param key The key to look up.
 * @return The value associated with the key, or null, if no value is found for the key.
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public V get(K key) {
  final int hash = hash(key);
  final int slot = indexOf(hash);
  // search the chain from the slot
  for (Entry<K, V> entry = table[slot]; entry != null; entry = entry.next) {
    if (entry.hashCode == hash && entry.key.equals(key)) {
      return entry.value;
    }
  }
  // not found
  return null;
}

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

/**
 * Looks up the value mapped under the given key. Returns null if no value is mapped under this key.
 *
 * @param key The key to look up.
 * @return The value associated with the key, or null, if no value is found for the key.
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public V get(K key) {
  final int hash = hash(key);
  final int slot = indexOf(hash);
  // search the chain from the slot
  for (Entry<K, V> entry = table[slot]; entry != null; entry = entry.next) {
    if (entry.hashCode == hash && entry.key.equals(key)) {
      return entry.value;
    }
  }
  // not found
  return null;
}

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

/**
 * Looks up the value mapped under the given key. Returns null if no value is mapped under this key.
 *
 * @param key The key to look up.
 * @return The value associated with the key, or null, if no value is found for the key.
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public V get(K key) {
  final int hash = hash(key);
  final int slot = indexOf(hash);
  // search the chain from the slot
  for (Entry<K, V> entry = table[slot]; entry != null; entry = entry.next) {
    if (entry.hashCode == hash && entry.key.equals(key)) {
      return entry.value;
    }
  }
  // not found
  return null;
}

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

/**
 * Inserts the given value, mapped under the given key. If the table already contains a value for
 * the key, the value is replaced and returned. If no value is contained, yet, the function
 * returns null.
 *
 * @param key The key to insert.
 * @param value The value to insert.
 * @return The previously mapped value for the key, or null, if no value was mapped for the key.
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public final V put(K key, V value) {
  final int hash = hash(key);
  final int slot = indexOf (hash);
  // search the chain from the slot
  for (Entry<K, V> e = table[slot]; e != null; e = e.next) {
    Object k;
    if (e.hashCode == hash && ((k = e.key) == key || key.equals(k))) {
      // found match
      V old = e.value;
      e.value = value;
      return old;
    }
  }
  // no match, insert a new value
  insertNewEntry(hash, key, value, slot);
  return null;
}

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

/**
 * Inserts the given value, mapped under the given key. If the table already contains a value for
 * the key, the value is replaced and returned. If no value is contained, yet, the function
 * returns null.
 *
 * @param key The key to insert.
 * @param value The value to insert.
 * @return The previously mapped value for the key, or null, if no value was mapped for the key.
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public final V put(K key, V value) {
  final int hash = hash(key);
  final int slot = indexOf (hash);
  // search the chain from the slot
  for (Entry<K, V> e = table[slot]; e != null; e = e.next) {
    Object k;
    if (e.hashCode == hash && ((k = e.key) == key || key.equals(k))) {
      // found match
      V old = e.value;
      e.value = value;
      return old;
    }
  }
  // no match, insert a new value
  insertNewEntry(hash, key, value, slot);
  return null;
}

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

/**
 * Inserts the given value, mapped under the given key. If the table already contains a value for
 * the key, the value is replaced and returned. If no value is contained, yet, the function
 * returns null.
 *
 * @param key The key to insert.
 * @param value The value to insert.
 * @return The previously mapped value for the key, or null, if no value was mapped for the key.
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public final V put(K key, V value) {
  final int hash = hash(key);
  final int slot = indexOf (hash);
  // search the chain from the slot
  for (Entry<K, V> e = table[slot]; e != null; e = e.next) {
    Object k;
    if (e.hashCode == hash && ((k = e.key) == key || key.equals(k))) {
      // found match
      V old = e.value;
      e.value = value;
      return old;
    }
  }
  // no match, insert a new value
  insertNewEntry(hash, key, value, slot);
  return null;
}

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

/**
 * Inserts a value for the given key, if no value is yet contained for that key. Otherwise,
 * returns the value currently contained for the key.
 *
 * <p>The value that is inserted in case that the key is not contained, yet, is lazily created
 * using the given factory.
 *
 * @param key The key to insert.
 * @param factory The factory that produces the value, if no value is contained, yet, for the key.
 * @return The value in the map after this operation (either the previously contained value, or the
 *         newly created value).
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public final V putIfAbsent(K key, LazyFactory<V> factory) {
  final int hash = hash(key);
  final int slot = indexOf(hash);
  // search the chain from the slot
  for (Entry<K, V> entry = table[slot]; entry != null; entry = entry.next) {
    if (entry.hashCode == hash && entry.key.equals(key)) {
      // found match
      return entry.value;
    }
  }
  // no match, insert a new value
  V value = factory.create();
  insertNewEntry(hash, key, value, slot);
  // return the created value
  return value;
}

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

final int hash = hash(key);
final int slot = indexOf(hash);

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

/**
 * Inserts a value for the given key, if no value is yet contained for that key. Otherwise,
 * returns the value currently contained for the key.
 *
 * <p>The value that is inserted in case that the key is not contained, yet, is lazily created
 * using the given factory.
 *
 * @param key The key to insert.
 * @param factory The factory that produces the value, if no value is contained, yet, for the key.
 * @return The value in the map after this operation (either the previously contained value, or the
 *         newly created value).
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public final V putIfAbsent(K key, LazyFactory<V> factory) {
  final int hash = hash(key);
  final int slot = indexOf(hash);
  // search the chain from the slot
  for (Entry<K, V> entry = table[slot]; entry != null; entry = entry.next) {
    if (entry.hashCode == hash && entry.key.equals(key)) {
      // found match
      return entry.value;
    }
  }
  // no match, insert a new value
  V value = factory.create();
  insertNewEntry(hash, key, value, slot);
  // return the created value
  return value;
}

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

final int hash = hash(key);
final int slot = indexOf(hash);

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

/**
 * Inserts a value for the given key, if no value is yet contained for that key. Otherwise,
 * returns the value currently contained for the key.
 *
 * <p>The value that is inserted in case that the key is not contained, yet, is lazily created
 * using the given factory.
 *
 * @param key The key to insert.
 * @param factory The factory that produces the value, if no value is contained, yet, for the key.
 * @return The value in the map after this operation (either the previously contained value, or the
 *         newly created value).
 *
 * @throws java.lang.NullPointerException Thrown, if the key is null.
 */
public final V putIfAbsent(K key, LazyFactory<V> factory) {
  final int hash = hash(key);
  final int slot = indexOf(hash);
  // search the chain from the slot
  for (Entry<K, V> entry = table[slot]; entry != null; entry = entry.next) {
    if (entry.hashCode == hash && entry.key.equals(key)) {
      // found match
      return entry.value;
    }
  }
  // no match, insert a new value
  V value = factory.create();
  insertNewEntry(hash, key, value, slot);
  // return the created value
  return value;
}

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

final int hash = hash(key);
final int slot = indexOf(hash);

相关文章