private static Record createPreviousContentClaimRecord(final RecordSchema contentClaimSchema, final String container, final String section, final String identifier, final Long offset, final Long size) { if (container == null || section == null || identifier == null) { return null; } final Map<RecordField, Object> fieldValues = new HashMap<>(); fieldValues.put(EventRecordFields.CONTENT_CLAIM_CONTAINER, container); fieldValues.put(EventRecordFields.CONTENT_CLAIM_SECTION, section); fieldValues.put(EventRecordFields.CONTENT_CLAIM_IDENTIFIER, identifier); fieldValues.put(EventRecordFields.CONTENT_CLAIM_OFFSET, offset); fieldValues.put(EventRecordFields.CONTENT_CLAIM_SIZE, size); return new FieldMapRecord(fieldValues, contentClaimSchema); }
public FieldMapRecord(final Map<RecordField, Object> values, final RecordSchema schema) { this.schema = schema; this.values = convertFieldToName(values); }
private static Record createContentClaimRecord(final RecordSchema contentClaimSchema, final String container, final String section, final String identifier, final Long offset, final Long size) { if (container == null || section == null || identifier == null) { return null; } final Map<RecordField, Object> fieldValues = new HashMap<>(); fieldValues.put(EventRecordFields.CONTENT_CLAIM_CONTAINER, container); fieldValues.put(EventRecordFields.CONTENT_CLAIM_SECTION, section); fieldValues.put(EventRecordFields.CONTENT_CLAIM_IDENTIFIER, identifier); fieldValues.put(EventRecordFields.CONTENT_CLAIM_OFFSET, offset); fieldValues.put(EventRecordFields.CONTENT_CLAIM_SIZE, size); return new FieldMapRecord(fieldValues, contentClaimSchema); }
private NamedValue createLookupValue(final String literalValue, final Map<String, Integer> lookup) { if (literalValue == null) { 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; } final Integer index = lookup.get(literalValue); if (index == null) { final Map<RecordField, Object> lookupValues = Collections.singletonMap(LookupTableEventRecordFields.EXPLICIT_STRING, literalValue); final Record record = new FieldMapRecord(lookupValues, LookupTableEventSchema.EXPLICIT_STRING_SCHEMA); final NamedValue namedValue = new NamedValue(EventFieldNames.EXPLICIT_VALUE, record); return namedValue; } else { final Map<RecordField, Object> lookupValues = Collections.singletonMap(LookupTableEventRecordFields.LOOKUP_VALUE, index); final Record record = new FieldMapRecord(lookupValues, LookupTableEventSchema.LOOKUP_VALUE_SCHEMA); final NamedValue namedValue = new NamedValue(EventFieldNames.LOOKUP_VALUE, record); return namedValue; } }
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 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; }
private static Record createContentClaimRecord(final RecordSchema contentClaimSchema, final String container, final String section, final String identifier, final Long offset, final Long size) { if (container == null || section == null || identifier == null) { final Map<RecordField, Object> lookupValues = Collections.singletonMap(LookupTableEventRecordFields.NO_VALUE, EventFieldNames.NO_VALUE); final List<RecordField> noValueFields = Collections.singletonList(contentClaimSchema.getField(EventFieldNames.NO_VALUE)); return new FieldMapRecord(lookupValues, new RecordSchema(noValueFields)); } final Map<RecordField, Object> fieldValues = new HashMap<>(); fieldValues.put(EventRecordFields.CONTENT_CLAIM_CONTAINER, container); fieldValues.put(EventRecordFields.CONTENT_CLAIM_SECTION, section); fieldValues.put(EventRecordFields.CONTENT_CLAIM_IDENTIFIER, identifier); fieldValues.put(EventRecordFields.CONTENT_CLAIM_OFFSET, offset); fieldValues.put(EventRecordFields.CONTENT_CLAIM_SIZE, size); final List<RecordField> explicitClaimFields = contentClaimSchema.getField(EventFieldNames.EXPLICIT_VALUE).getSubFields(); final Record explicitClaimRecord = new FieldMapRecord(fieldValues, new RecordSchema(explicitClaimFields)); return explicitClaimRecord; }
@Override protected synchronized void writeHeader(final long firstEventId, final DataOutputStream out) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); eventSchema.writeTo(baos); out.writeInt(baos.size()); baos.writeTo(out); baos.reset(); headerSchema.writeTo(baos); out.writeInt(baos.size()); baos.writeTo(out); this.firstEventId = firstEventId; this.systemTimeOffset = System.currentTimeMillis(); final Map<String, Object> headerValues = new HashMap<>(); headerValues.put(EventIdFirstHeaderSchema.FieldNames.FIRST_EVENT_ID, firstEventId); headerValues.put(EventIdFirstHeaderSchema.FieldNames.TIMESTAMP_OFFSET, systemTimeOffset); headerValues.put(EventIdFirstHeaderSchema.FieldNames.COMPONENT_IDS, idLookup.getComponentIdentifiers()); headerValues.put(EventIdFirstHeaderSchema.FieldNames.COMPONENT_TYPES, idLookup.getComponentTypes()); headerValues.put(EventIdFirstHeaderSchema.FieldNames.QUEUE_IDS, idLookup.getQueueIdentifiers()); headerValues.put(EventIdFirstHeaderSchema.FieldNames.EVENT_TYPES, eventTypeNames); final FieldMapRecord headerInfo = new FieldMapRecord(headerSchema, headerValues); schemaRecordWriter.writeRecord(headerInfo, out); }
return new FieldMapRecord(subFieldValues, new RecordSchema(subFields));
swapFileMap.put(summaryField, summaryRecord); swapFileMap.put(contentsField, flowFileRecords); final Record swapFileRecord = new FieldMapRecord(swapFileMap, new RecordSchema(fields));