@Override public EventId copy(EventId from) { return new EventId(from.id, from.timestamp); }
@Override protected final boolean shouldPrune(EventId startEventID, EventId pruningId) { return startEventID != null && startEventID.compareTo(pruningId) <= 0; } }
@Override protected EventId getPruningId(Collection<Map<String, List<EventId>>> match) { EventId pruningId = null; for (Map<String, List<EventId>> resultMap : match) { List<EventId> pruningPattern = resultMap.get(patternName); if (pruningPattern == null || pruningPattern.isEmpty()) { if (shouldThrowException) { throw new FlinkRuntimeException(String.format( "Could not skip to %s. No such element in the found match %s", patternName, resultMap)); } } else { pruningId = max(pruningId, pruningPattern.get(getIndex(pruningPattern.size()))); } if (shouldThrowException) { EventId startEvent = resultMap.values() .stream() .flatMap(Collection::stream) .min(EventId::compareTo) .orElseThrow(() -> new IllegalStateException("Cannot prune based on empty match")); if (pruningId != null && pruningId.equals(startEvent)) { throw new FlinkRuntimeException("Could not skip to first element of a match."); } } } return pruningId; }
static EventId min(EventId o1, EventId o2) { if (o2 == null) { return o1; } if (o1 == null) { return o2; } if (o1.compareTo(o2) <= 0) { return o1; } else { return o2; } }
@Override public EventId deserialize(DataInputView source) throws IOException { int id = source.readInt(); long timestamp = source.readLong(); return new EventId(id, timestamp); }
@Override protected EventId getPruningId(Collection<Map<String, List<EventId>>> match) { EventId pruningId = null; for (Map<String, List<EventId>> resultMap : match) { List<EventId> pruningPattern = resultMap.get(patternName); if (pruningPattern == null || pruningPattern.isEmpty()) { if (shouldThrowException) { throw new FlinkRuntimeException(String.format( "Could not skip to %s. No such element in the found match %s", patternName, resultMap)); } } else { pruningId = max(pruningId, pruningPattern.get(getIndex(pruningPattern.size()))); } if (shouldThrowException) { EventId startEvent = resultMap.values() .stream() .flatMap(Collection::stream) .min(EventId::compareTo) .orElseThrow(() -> new IllegalStateException("Cannot prune based on empty match")); if (pruningId != null && pruningId.equals(startEvent)) { throw new FlinkRuntimeException("Could not skip to first element of a match."); } } } return pruningId; }
static EventId max(EventId o1, EventId o2) { if (o2 == null) { return o1; } if (o1 == null) { return o2; } if (o1.compareTo(o2) >= 0) { return o1; } else { return o2; } }
EventId registerEvent(V value, long timestamp) throws Exception { Integer id = eventsCount.get(timestamp); if (id == null) { id = 0; } EventId eventId = new EventId(id, timestamp); Lockable<V> lockableValue = new Lockable<>(value, 1); eventsCount.put(timestamp, id + 1); eventsBufferCache.put(eventId, lockableValue); return eventId; }
@Override protected EventId getPruningId(Collection<Map<String, List<EventId>>> match) { EventId pruningId = null; for (Map<String, List<EventId>> resultMap : match) { List<EventId> pruningPattern = resultMap.get(patternName); if (pruningPattern == null || pruningPattern.isEmpty()) { if (shouldThrowException) { throw new FlinkRuntimeException(String.format( "Could not skip to %s. No such element in the found match %s", patternName, resultMap)); } } else { pruningId = max(pruningId, pruningPattern.get(getIndex(pruningPattern.size()))); } if (shouldThrowException) { EventId startEvent = resultMap.values() .stream() .flatMap(Collection::stream) .min(EventId::compareTo) .orElseThrow(() -> new IllegalStateException("Cannot prune based on empty match")); if (pruningId != null && pruningId.equals(startEvent)) { throw new FlinkRuntimeException("Could not skip to first element of a match."); } } } return pruningId; }
@Override protected boolean shouldPrune(EventId startEventID, EventId pruningId) { return startEventID != null && startEventID.compareTo(pruningId) < 0; }
if (eventId == null) { int id = totalEventsPerTimestamp.computeIfAbsent(wrapper.timestamp, k -> 0); eventId = new EventId(id, wrapper.timestamp); values.put(wrapper, eventId); valuesWithIds.put(eventId, new Lockable<>(wrapper.value, 1));
static EventId max(EventId o1, EventId o2) { if (o2 == null) { return o1; } if (o1 == null) { return o2; } if (o1.compareTo(o2) >= 0) { return o1; } else { return o2; } }
@Override public EventId copy(EventId from) { return new EventId(from.id, from.timestamp); }
@Override protected final boolean shouldPrune(EventId startEventID, EventId pruningId) { return startEventID != null && startEventID.compareTo(pruningId) <= 0; } }
@Override public EventId copy(EventId from) { return new EventId(from.id, from.timestamp); }
@Override protected final boolean shouldPrune(EventId startEventID, EventId pruningId) { return startEventID != null && startEventID.compareTo(pruningId) <= 0; } }
@Override public EventId deserialize(DataInputView source) throws IOException { int id = IntSerializer.INSTANCE.deserialize(source); long timestamp = LongSerializer.INSTANCE.deserialize(source); return new EventId(id, timestamp); }
@Override protected boolean shouldPrune(EventId startEventID, EventId pruningId) { return startEventID != null && startEventID.compareTo(pruningId) < 0; }
@Override public EventId deserialize(DataInputView source) throws IOException { int id = IntSerializer.INSTANCE.deserialize(source); long timestamp = LongSerializer.INSTANCE.deserialize(source); return new EventId(id, timestamp); }
@Override protected boolean shouldPrune(EventId startEventID, EventId pruningId) { return startEventID != null && startEventID.compareTo(pruningId) < 0; }