private Record readInlineRecord(final InputStream in) throws IOException { final List<RecordField> schemaFields = schema.getFields(); final Map<RecordField, Object> fields = new HashMap<>(schemaFields.size()); for (final RecordField field : schema.getFields()) { final Object value = readField(in, field); fields.put(field, value); } return new FieldMapRecord(fields, schema); }
private void writeRecordFields(final Record record, final RecordSchema schema, final OutputStream out, final byte[] buffer) throws IOException { final DataOutputStream dos = out instanceof DataOutputStream ? (DataOutputStream) out : new DataOutputStream(out); for (final RecordField field : schema.getFields()) { final Object value = record.getFieldValue(field); try { writeFieldRepetitionAndValue(field, value, dos, buffer); } catch (final Exception e) { throw new IOException("Failed to write field '" + field.getFieldName() + "'", e); } } }
private NamedValue createExplicitSameOrNoneValue(final Record newValue, final Record oldValue, final Supplier<Record> recordSupplier) { if (newValue == null || EventFieldNames.NO_VALUE.equals(newValue.getSchema().getFields().get(0).getFieldName())) { final Map<RecordField, Object> lookupValues = Collections.singletonMap(LookupTableEventRecordFields.NO_VALUE, EventFieldNames.NO_VALUE); final Record record = new FieldMapRecord(lookupValues, LookupTableEventSchema.NO_VALUE_SCHEMA); final NamedValue namedValue = new NamedValue(EventFieldNames.NO_VALUE, record); return namedValue; } else if (newValue.equals(oldValue)) { final Map<RecordField, Object> lookupValues = Collections.singletonMap(LookupTableEventRecordFields.UNCHANGED_VALUE, EventFieldNames.UNCHANGED_VALUE); final Record record = new FieldMapRecord(lookupValues, LookupTableEventSchema.UNCHANGED_VALUE_SCHEMA); final NamedValue namedValue = new NamedValue(EventFieldNames.UNCHANGED_VALUE, record); return namedValue; } final Record record = recordSupplier.get(); final NamedValue namedValue = new NamedValue(EventFieldNames.EXPLICIT_VALUE, record); return namedValue; }
final RecordField contentsField = new ComplexRecordField(SwapSchema.FLOWFILE_CONTENTS, Repetition.ZERO_OR_MORE, FlowFileSchema.FLOWFILE_SCHEMA_V2.getFields()); final List<RecordField> fields = new ArrayList<>(2); fields.add(summaryField);