markap14 commented on issue #3930: NIFI-6851: Added FlowFileAcquisitionMethod 
to fetch/receive methods i…
URL: https://github.com/apache/nifi/pull/3930#issuecomment-571789004
 
 
   @m-hogue  I think the way that the data is serialized is correct for both 
event types and acquisition types. The problem that I see is in the 
deserialization. In the EventIdFirstSchemaRecordReader, we read the list of 
Event Types as they were when the data was serialized: 
https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/EventIdFirstSchemaRecordReader.java#L119
   
   Then, when we deserialize the data, we provide that list of Event Types to 
the LookupTableEventRecord 
(https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/EventIdFirstSchemaRecordReader.java#L143).
  This is the important piece that I think this PR is missing.
   
   LookupTableEventRecord determines the ProvenanceEventType like this, roughly 
(here, I've removed error handling, renamed variables for clarity, etc.):
   
   ```
   // Get the integer value that was stored in the file.
   final Integer eventTypeOrdinal = (Integer) 
record.getFieldValue(EventFieldNames.EVENT_TYPE);
   // Get the name of the event. This is based on the List of Event Names that 
were stored in the file header.
   String eventTypeName = eventTypes.get(eventTypeOrdinal);
   // Get the ProvenanceEventType with that name.
   ProvenanceEventType eventType = ProvenanceEventType.valueOf(eventTypeName);
   ```
   
   However, what I believe this PR is doing is more like this:
   ```
   // Get the integer value that was stored in the file.
   final Integer acquisitionType = (Integer) 
record.getFieldValue(EventFieldNames.FLOWFILE_ACQUISITION_METHOD);
   // Get the name of the acquisition type NOT from the List of Acquisition 
Types that were stored in the headers, but rather from the Enumeration (i.e., 
the current mapping of integer to name, rather than the mapping that makes 
sense for the data in the file) - this, I believe, is the problem.
   String acquisitionName = 
FlowFileAcquisitionMethod.flowFileAcquisitionMethodNames().get(flowFileAcquisitionOrdinal);
   // Get the acquisition method based on the name
   flowFileAcquisitionMethod = 
FlowFileAcquisitionMethod.valueOf(acquisitionName);
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to