org.apache.nifi.serialization.record.Record.getRawFieldNames()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(140)

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

Record.getRawFieldNames介绍

[英]Returns a Set that contains the names of all of the fields that are present in the Record, regardless of whether or not those fields are contained in the schema. To determine which fields exist in the Schema, use #getSchema(). RecordSchema#getFieldNames() instead.
[中]返回一个集合,该集合包含记录中所有字段的名称,无论这些字段是否包含在架构中。要确定架构中存在哪些字段,请使用#getSchema()。改为RecordSchema#getFieldNames()。

代码示例

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

private String[] getFieldNames(final Record record) {
  if (fieldNames != null) {
    return fieldNames;
  }
  final Set<String> allFields = new LinkedHashSet<>();
  allFields.addAll(record.getRawFieldNames());
  allFields.addAll(recordSchema.getFieldNames());
  fieldNames = allFields.toArray(new String[0]);
  return fieldNames;
}

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

private boolean isFieldPresent(final RecordField field, final Record record) {
  final Set<String> rawFieldNames = record.getRawFieldNames();
  if (rawFieldNames.contains(field.getFieldName())) {
    return true;
  }
  for (final String alias : field.getAliases()) {
    if (rawFieldNames.contains(alias)) {
      return true;
    }
  }
  return false;
}

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

private boolean recordHasField(RecordField field, Record record) {
    Set<String> recordFieldNames = record.getRawFieldNames();
    if (recordFieldNames.contains(field.getFieldName())) {
      return true;
    }

    for (String alias : field.getAliases()) {
      if (recordFieldNames.contains(alias)) {
        return true;
      }
    }

    return false;
  }
}

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

private void writeRecord(final Record record, final RecordSchema writeSchema, final JsonGenerator generator)
    throws IOException {
  RecordSchema schema = record.getSchema();
  generator.writeStartObject();
  for (int i = 0; i < schema.getFieldCount(); i++) {
    final RecordField field = schema.getField(i);
    final String fieldName = field.getFieldName();
    final Object value = record.getValue(field);
    if (value == null) {
      if (nullSuppression.equals(NEVER_SUPPRESS.getValue()) || (nullSuppression.equals(SUPPRESS_MISSING.getValue())) && record.getRawFieldNames().contains(fieldName)) {
        generator.writeNullField(fieldName);
      }
      continue;
    }
    generator.writeFieldName(fieldName);
    final DataType dataType = schema.getDataType(fieldName).get();
    writeValue(generator, value, fieldName, dataType);
  }
  generator.writeEndObject();
}

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

private boolean iterateThroughRecordWithoutSchema(Deque<String> tagsToOpen, Record record) throws XMLStreamException {
  boolean loopHasWritten = false;
  for (String fieldName : record.getRawFieldNames()) {
    Object value = record.getValue(fieldName);
    if (value != null) {
      boolean hasWritten = writeUnknownField(tagsToOpen, value, fieldName);
      if (hasWritten) {
        loopHasWritten = true;
      }
    } else {
      if (nullSuppression.equals(NullSuppression.NEVER_SUPPRESS) || nullSuppression.equals(NullSuppression.SUPPRESS_MISSING)) {
        writeAllTags(tagsToOpen, fieldName);
        writer.writeEndElement();
        loopHasWritten = true;
      }
    }
  }
  return loopHasWritten;
}

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

final Record destinationRecord = (Record) destinationValue;
for (final String fieldName : lookupRecord.getRawFieldNames()) {
  final Object value = lookupRecord.getValue(fieldName);
  destinationRecord.setValue(fieldName, value);

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

for (final String fieldName : record.getRawFieldNames()) {
  final Object value = record.getValue(fieldName);
  if (value == null) {
    if (nullSuppression == NullSuppression.NEVER_SUPPRESS || (nullSuppression == NullSuppression.SUPPRESS_MISSING) && record.getRawFieldNames().contains(fieldName)) {
      generator.writeNullField(fieldName);

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

for (final String fieldName : record.getRawFieldNames()) {
  if (!schema.getDataType(fieldName).isPresent()) {
    result.addValidationError(new StandardValidationError(fieldPrefix + "/" + fieldName, ValidationErrorType.EXTRA_FIELD, "Field is not present in the schema"));

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

final DataType valueDataType = mapDataType.getValueType();
for (final String fieldName : record.getRawFieldNames()) {
  final Object fieldValue = record.getValue(fieldName);
  if (!isTypeCorrect(fieldValue, valueDataType)) {

代码示例来源:origin: org.apache.nifi/nifi-standard-processors

final Record destinationRecord = (Record) destinationValue;
for (final String fieldName : lookupRecord.getRawFieldNames()) {
  final Object value = lookupRecord.getValue(fieldName);
  destinationRecord.setValue(fieldName, value);

代码示例来源:origin: org.apache.nifi/nifi-standard-record-utils

for (final String fieldName : record.getRawFieldNames()) {
  if (!schema.getDataType(fieldName).isPresent()) {
    result.addValidationError(new StandardValidationError(fieldPrefix + "/" + fieldName, ValidationErrorType.EXTRA_FIELD, "Field is not present in the schema"));

代码示例来源:origin: org.apache.nifi/nifi-standard-record-utils

final DataType valueDataType = mapDataType.getValueType();
for (final String fieldName : record.getRawFieldNames()) {
  final Object fieldValue = record.getValue(fieldName);
  if (!isTypeCorrect(fieldValue, valueDataType)) {

相关文章