本文整理了Java中org.apache.nifi.serialization.record.Record.getAsString
方法的一些代码示例,展示了Record.getAsString
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Record.getAsString
方法的具体详情如下:
包路径:org.apache.nifi.serialization.record.Record
类名称:Record
方法名:getAsString
暂无
代码示例来源:origin: apache/nifi
private void write(final Record record, final OutputStream out, final List<String> columnNames) throws IOException {
final int numCols = columnNames.size();
final Map<String, String> values = new HashMap<>(numCols);
for (int i = 0; i < numCols; i++) {
final String columnName = columnNames.get(i);
final String columnValue = record.getAsString(columnName);
values.put(columnName, columnValue);
}
final String evaluated = propertyValue.evaluateAttributeExpressions(values).getValue();
out.write(evaluated.getBytes(charset));
out.write(NEW_LINE);
}
代码示例来源:origin: apache/nifi
@Override
public WriteResult write(Record record) throws IOException {
if (++recordCount > failAfterN && failAfterN > -1) {
throw new IOException("Unit Test intentionally throwing IOException after " + failAfterN + " records were written");
}
if (header != null && !headerWritten) {
out.write(header.getBytes());
out.write("\n".getBytes());
headerWritten = true;
}
final int numCols = record.getSchema().getFieldCount();
int i = 0;
for (final String fieldName : record.getSchema().getFieldNames()) {
final String val = record.getAsString(fieldName);
if (val != null) {
if (quoteValues) {
out.write("\"".getBytes());
out.write(val.getBytes());
out.write("\"".getBytes());
} else {
out.write(val.getBytes());
}
}
if (i++ < numCols - 1) {
out.write(",".getBytes());
}
}
out.write("\n".getBytes());
return WriteResult.of(1, Collections.emptyMap());
}
代码示例来源:origin: apache/nifi
final String val = record.getAsString(fieldName);
if (val != null) {
if (quoteValues) {
代码示例来源:origin: apache/nifi
private byte[] handleComplexField(Record record, String field, String complexFieldStrategy) throws PutCreationFailedInvokedException {
switch (complexFieldStrategy) {
case FAIL_VALUE:
getLogger().error("Complex value found for {}; routing to failure", new Object[]{field});
throw new PutCreationFailedInvokedException(String.format("Complex value found for %s; routing to failure", field));
case WARN_VALUE:
getLogger().warn("Complex value found for {}; skipping", new Object[]{field});
return null;
case TEXT_VALUE:
final String value = record.getAsString(field);
return clientService.toBytes(value);
case IGNORE_VALUE:
// silently skip
return null;
default:
return null;
}
}
代码示例来源:origin: apache/nifi
@Override
public WriteResult writeRawRecord(final Record record) throws IOException {
// If we are not writing an active record set, then we need to ensure that we write the
// schema information.
if (!isActiveRecordSet()) {
schemaWriter.writeHeader(recordSchema, getOutputStream());
}
includeHeaderIfNecessary(record, false);
final String[] fieldNames = getFieldNames(record);
// Avoid creating a new Object[] for every Record if we can. But if the record has a different number of columns than does our
// schema, we don't have a lot of options here, so we just create a new Object[] in that case.
final Object[] recordFieldValues = (fieldNames.length == this.fieldValues.length) ? this.fieldValues : new String[fieldNames.length];
int i = 0;
for (final String fieldName : fieldNames) {
final Optional<RecordField> recordField = recordSchema.getField(fieldName);
if (recordField.isPresent()) {
recordFieldValues[i++] = record.getAsString(fieldName, getFormat(recordField.get()));
} else {
recordFieldValues[i++] = record.getAsString(fieldName);
}
}
printer.printRecord(recordFieldValues);
final Map<String, String> attributes = schemaWriter.getAttributes(recordSchema);
return WriteResult.of(incrementRecordCount(), attributes);
}
代码示例来源:origin: apache/nifi
final String key = messageKeyField == null ? null : record.getAsString(messageKeyField);
final byte[] messageKey = (key == null) ? null : key.getBytes(StandardCharsets.UTF_8);
代码示例来源:origin: apache/nifi
final String key = messageKeyField == null ? null : record.getAsString(messageKeyField);
final byte[] messageKey = (key == null) ? null : key.getBytes(StandardCharsets.UTF_8);
代码示例来源:origin: apache/nifi
final String key = messageKeyField == null ? null : record.getAsString(messageKeyField);
final byte[] messageKey = (key == null) ? null : key.getBytes(StandardCharsets.UTF_8);
代码示例来源:origin: apache/nifi
final String key = messageKeyField == null ? null : record.getAsString(messageKeyField);
final byte[] messageKey = (key == null) ? null : key.getBytes(StandardCharsets.UTF_8);
代码示例来源:origin: apache/nifi
break;
case BINARY:
row.addBinary(colIdx, record.getAsString(colName).getBytes());
break;
case INT8:
break;
case STRING:
row.addString(colIdx, record.getAsString(colName));
break;
case DECIMAL32:
case DECIMAL64:
case DECIMAL128:
row.addDecimal(colIdx, new BigDecimal(record.getAsString(colName)));
break;
default:
代码示例来源:origin: apache/nifi
@Override
public Map<String, String> writeRecord(final Record record) throws IOException {
// If we are not writing an active record set, then we need to ensure that we write the
// schema information.
if (!isActiveRecordSet()) {
schemaWriter.writeHeader(recordSchema, getOutputStream());
}
includeHeaderIfNecessary(record, true);
int i = 0;
for (final RecordField recordField : recordSchema.getFields()) {
fieldValues[i++] = record.getAsString(recordField, getFormat(recordField));
}
printer.printRecord(fieldValues);
return schemaWriter.getAttributes(recordSchema);
}
代码示例来源:origin: apache/nifi
String rowIdValue = record.getAsString(rowFieldName);
if (rowIdValue == null) {
throw new PutCreationFailedInvokedException(String.format("Row ID was null for flowfile with ID %s", flowFile.getAttribute("uuid")));
代码示例来源:origin: apache/nifi
break;
default:
final String value = record.getAsString(field);
retVal = clientService.toBytes(value);
break;
break;
default:
final String value = record.getAsString(field);
retVal = clientService.toBytes(value);
break;
代码示例来源:origin: apache/nifi
case VARCHAR:
case CHAR:
val = record.getAsString(fieldName);
break;
case BINARY:
代码示例来源:origin: org.apache.nifi/nifi-kafka-0-10-processors
final String key = messageKeyField == null ? null : record.getAsString(messageKeyField);
final byte[] messageKey = (key == null) ? null : key.getBytes(StandardCharsets.UTF_8);
代码示例来源:origin: org.apache.nifi/nifi-kafka-1-0-processors
final String key = messageKeyField == null ? null : record.getAsString(messageKeyField);
final byte[] messageKey = (key == null) ? null : key.getBytes(StandardCharsets.UTF_8);
代码示例来源:origin: org.apache.nifi/nifi-kafka-2-0-processors
final String key = messageKeyField == null ? null : record.getAsString(messageKeyField);
final byte[] messageKey = (key == null) ? null : key.getBytes(StandardCharsets.UTF_8);
内容来源于网络,如有侵权,请联系作者删除!