org.apache.flink.api.java.tuple.Tuple.getFieldNotNull()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(66)

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

Tuple.getFieldNotNull介绍

[英]Gets the field at the specified position, throws NullFieldException if the field is null. Used for comparing key fields.
[中]获取指定位置的字段,如果该字段为null,则引发NullFieldException。用于比较关键字段。

代码示例

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

Comparable comparable1 = value1.getFieldNotNull(position);
Comparable comparable2 = value2.getFieldNotNull(position);

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

Comparable comparable1 = value1.getFieldNotNull(position);
Comparable comparable2 = value2.getFieldNotNull(position);

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

@SuppressWarnings("unchecked")
@Override
public int compare(T first, T second) {
  int i = 0;
  try {
    for (; i < keyPositions.length; i++) {
      int keyPos = keyPositions[i];
      int cmp = comparators[i].compare(first.getFieldNotNull(keyPos), second.getFieldNotNull(keyPos));
      if (cmp != 0) {
        return cmp;
      }
    }
    return 0;
  } 
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

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

@SuppressWarnings("unchecked")
@Override
public int hash(T value) {
  int i = 0;
  try {
    int code = this.comparators[0].hash(value.getFieldNotNull(keyPositions[0]));
    for (i = 1; i < this.keyPositions.length; i++) {
      code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
      code += this.comparators[i].hash(value.getFieldNotNull(keyPositions[i]));
    }
    return code;
  }
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

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

@SuppressWarnings("unchecked")
@Override
public void setReference(T toCompare) {
  int i = 0;
  try {
    for (; i < this.keyPositions.length; i++) {
      this.comparators[i].setReference(toCompare.getFieldNotNull(this.keyPositions[i]));
    }
  }
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

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

@SuppressWarnings("unchecked")
@Override
public boolean equalToReference(T candidate) {
  int i = 0;
  try {
    for (; i < this.keyPositions.length; i++) {
      if (!this.comparators[i].equalToReference(candidate.getFieldNotNull(this.keyPositions[i]))) {
        return false;
      }
    }
    return true;
  }
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

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

@SuppressWarnings("unchecked")
@Override
public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) {
  int i = 0;
  try {
    for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) {
      int len = this.normalizedKeyLengths[i];
      len = numBytes >= len ? len : numBytes;
      this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len);
      numBytes -= len;
      offset += len;
    }
  } catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  } catch (NullPointerException npex) {
    throw new NullKeyFieldException(this.keyPositions[i]);
  }
}

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

@Override
public void reduce(Iterable<T> records, Collector<T> out) {
  final AggregationFunction<Object>[] aggFunctions = this.aggFunctions;
  final int[] fieldPositions = this.fieldPositions;
  // aggregators are initialized from before
  T outT = null;
  for (T record : records) {
    outT = record;
    for (int i = 0; i < fieldPositions.length; i++) {
      Object val = record.getFieldNotNull(fieldPositions[i]);
      aggFunctions[i].aggregate(val);
    }
  }
  for (int i = 0; i < fieldPositions.length; i++) {
    Object aggVal = aggFunctions[i].getAggregate();
    outT.setField(aggVal, fieldPositions[i]);
    aggFunctions[i].initializeAggregate();
  }
  out.collect(outT);
}

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

@SuppressWarnings("unchecked")
@Override
public int compare(T first, T second) {
  int i = 0;
  try {
    for (; i < keyPositions.length; i++) {
      int keyPos = keyPositions[i];
      int cmp = comparators[i].compare(first.getFieldNotNull(keyPos), second.getFieldNotNull(keyPos));
      if (cmp != 0) {
        return cmp;
      }
    }
    return 0;
  } 
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-core

@SuppressWarnings("unchecked")
@Override
public int compare(T first, T second) {
  int i = 0;
  try {
    for (; i < keyPositions.length; i++) {
      int keyPos = keyPositions[i];
      int cmp = comparators[i].compare(first.getFieldNotNull(keyPos), second.getFieldNotNull(keyPos));
      if (cmp != 0) {
        return cmp;
      }
    }
    return 0;
  } 
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-core

@SuppressWarnings("unchecked")
@Override
public int hash(T value) {
  int i = 0;
  try {
    int code = this.comparators[0].hash(value.getFieldNotNull(keyPositions[0]));
    for (i = 1; i < this.keyPositions.length; i++) {
      code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
      code += this.comparators[i].hash(value.getFieldNotNull(keyPositions[i]));
    }
    return code;
  }
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

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

@SuppressWarnings("unchecked")
@Override
public int hash(T value) {
  int i = 0;
  try {
    int code = this.comparators[0].hash(value.getFieldNotNull(keyPositions[0]));
    for (i = 1; i < this.keyPositions.length; i++) {
      code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
      code += this.comparators[i].hash(value.getFieldNotNull(keyPositions[i]));
    }
    return code;
  }
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-core

@SuppressWarnings("unchecked")
@Override
public void setReference(T toCompare) {
  int i = 0;
  try {
    for (; i < this.keyPositions.length; i++) {
      this.comparators[i].setReference(toCompare.getFieldNotNull(this.keyPositions[i]));
    }
  }
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

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

@SuppressWarnings("unchecked")
@Override
public void setReference(T toCompare) {
  int i = 0;
  try {
    for (; i < this.keyPositions.length; i++) {
      this.comparators[i].setReference(toCompare.getFieldNotNull(this.keyPositions[i]));
    }
  }
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-core

@SuppressWarnings("unchecked")
@Override
public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) {
  int i = 0;
  try {
    for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) {
      int len = this.normalizedKeyLengths[i];
      len = numBytes >= len ? len : numBytes;
      this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len);
      numBytes -= len;
      offset += len;
    }
  } catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  } catch (NullPointerException npex) {
    throw new NullKeyFieldException(this.keyPositions[i]);
  }
}

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

@SuppressWarnings("unchecked")
@Override
public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) {
  int i = 0;
  try {
    for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) {
      int len = this.normalizedKeyLengths[i];
      len = numBytes >= len ? len : numBytes;
      this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len);
      numBytes -= len;
      offset += len;
    }
  } catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  } catch (NullPointerException npex) {
    throw new NullKeyFieldException(this.keyPositions[i]);
  }
}

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

@SuppressWarnings("unchecked")
@Override
public boolean equalToReference(T candidate) {
  int i = 0;
  try {
    for (; i < this.keyPositions.length; i++) {
      if (!this.comparators[i].equalToReference(candidate.getFieldNotNull(this.keyPositions[i]))) {
        return false;
      }
    }
    return true;
  }
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-core

@SuppressWarnings("unchecked")
@Override
public boolean equalToReference(T candidate) {
  int i = 0;
  try {
    for (; i < this.keyPositions.length; i++) {
      if (!this.comparators[i].equalToReference(candidate.getFieldNotNull(this.keyPositions[i]))) {
        return false;
      }
    }
    return true;
  }
  catch (NullFieldException nfex) {
    throw new NullKeyFieldException(nfex);
  }
  catch (IndexOutOfBoundsException iobex) {
    throw new KeyFieldOutOfBoundsException(keyPositions[i]);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-java

@Override
public void reduce(Iterable<T> records, Collector<T> out) {
  final AggregationFunction<Object>[] aggFunctions = this.aggFunctions;
  final int[] fieldPositions = this.fieldPositions;
  // aggregators are initialized from before
  T outT = null;
  for (T record : records) {
    outT = record;
    for (int i = 0; i < fieldPositions.length; i++) {
      Object val = record.getFieldNotNull(fieldPositions[i]);
      aggFunctions[i].aggregate(val);
    }
  }
  for (int i = 0; i < fieldPositions.length; i++) {
    Object aggVal = aggFunctions[i].getAggregate();
    outT.setField(aggVal, fieldPositions[i]);
    aggFunctions[i].initializeAggregate();
  }
  out.collect(outT);
}

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

@Override
public void reduce(Iterable<T> records, Collector<T> out) {
  final AggregationFunction<Object>[] aggFunctions = this.aggFunctions;
  final int[] fieldPositions = this.fieldPositions;
  // aggregators are initialized from before
  T outT = null;
  for (T record : records) {
    outT = record;
    for (int i = 0; i < fieldPositions.length; i++) {
      Object val = record.getFieldNotNull(fieldPositions[i]);
      aggFunctions[i].aggregate(val);
    }
  }
  for (int i = 0; i < fieldPositions.length; i++) {
    Object aggVal = aggFunctions[i].getAggregate();
    outT.setField(aggVal, fieldPositions[i]);
    aggFunctions[i].initializeAggregate();
  }
  out.collect(outT);
}

相关文章