/** * Creates a {@link StreamEvent} that will be used as a template for all events consumable from this reader. */ private StreamEvent createEventTemplate(Map<String, String> properties) throws IOException { long timestamp = -1L; // See if all events in the file are of the same timestamp String uniTimestamp = properties.get(StreamDataFileConstants.Property.Key.UNI_TIMESTAMP); if (StreamDataFileConstants.Property.Value.CLOSE_TIMESTAMP.equals(uniTimestamp)) { // Seek to the end - 8 of the stream to read the close timestamp long pos = eventInput.getPos(); eventInput.seek(eventInput.size() - 8); timestamp = Math.abs(readTimestamp()); eventInput.seek(pos); } else if (uniTimestamp != null) { timestamp = Long.parseLong(uniTimestamp); } // Grab the set of default headers for all events ImmutableMap.Builder<String, String> headers = ImmutableMap.builder(); String prefix = StreamDataFileConstants.Property.Key.EVENT_HEADER_PREFIX; for (Map.Entry<String, String> entry : properties.entrySet()) { if (entry.getKey().startsWith(prefix)) { headers.put(entry.getKey().substring(prefix.length()), entry.getValue()); } } return new StreamEvent(headers.build(), ByteBuffers.EMPTY_BUFFER, timestamp); }