/** * Extracts the real event from the sharedBuffer with pre-extracted eventId. * * @param match the matched event's eventId. * @return the event associated with the eventId. */ public Map<String, List<V>> materializeMatch(Map<String, List<EventId>> match) { Map<String, List<V>> materializedMatch = new LinkedHashMap<>(match.size()); for (Map.Entry<String, List<EventId>> pattern : match.entrySet()) { List<V> events = new ArrayList<>(pattern.getValue().size()); for (EventId eventId : pattern.getValue()) { try { V event = sharedBuffer.getEvent(eventId).getElement(); events.add(event); } catch (Exception ex) { throw new WrappingRuntimeException(ex); } } materializedMatch.put(pattern.getKey(), events); } return materializedMatch; }
/** * Increases the reference counter for the given event so that it is not * accidentally removed. * * @param eventId id of the entry */ private void lockEvent(EventId eventId) { Lockable<V> eventWrapper = sharedBuffer.getEvent(eventId); checkState( eventWrapper != null, "Referring to non existent event with id %s", eventId); eventWrapper.lock(); sharedBuffer.upsertEvent(eventId, eventWrapper); }
/** * Decreases the reference counter for the given event so that it can be * removed once the reference counter reaches 0. * * @param eventId id of the event * @throws Exception Thrown if the system cannot access the state. */ public void releaseEvent(EventId eventId) throws Exception { Lockable<V> eventWrapper = sharedBuffer.getEvent(eventId); if (eventWrapper != null) { if (eventWrapper.release()) { sharedBuffer.removeEvent(eventId); } else { sharedBuffer.upsertEvent(eventId, eventWrapper); } } }
/** * Extracts the real event from the sharedBuffer with pre-extracted eventId. * * @param match the matched event's eventId. * @return the event associated with the eventId. */ public Map<String, List<V>> materializeMatch(Map<String, List<EventId>> match) { Map<String, List<V>> materializedMatch = new LinkedHashMap<>(match.size()); for (Map.Entry<String, List<EventId>> pattern : match.entrySet()) { List<V> events = new ArrayList<>(pattern.getValue().size()); for (EventId eventId : pattern.getValue()) { try { V event = sharedBuffer.getEvent(eventId).getElement(); events.add(event); } catch (Exception ex) { throw new WrappingRuntimeException(ex); } } materializedMatch.put(pattern.getKey(), events); } return materializedMatch; }
/** * Extracts the real event from the sharedBuffer with pre-extracted eventId. * * @param match the matched event's eventId. * @return the event associated with the eventId. */ public Map<String, List<V>> materializeMatch(Map<String, List<EventId>> match) { Map<String, List<V>> materializedMatch = new LinkedHashMap<>(match.size()); for (Map.Entry<String, List<EventId>> pattern : match.entrySet()) { List<V> events = new ArrayList<>(pattern.getValue().size()); for (EventId eventId : pattern.getValue()) { try { V event = sharedBuffer.getEvent(eventId).getElement(); events.add(event); } catch (Exception ex) { throw new WrappingRuntimeException(ex); } } materializedMatch.put(pattern.getKey(), events); } return materializedMatch; }
/** * Increases the reference counter for the given event so that it is not * accidentally removed. * * @param eventId id of the entry */ private void lockEvent(EventId eventId) { Lockable<V> eventWrapper = sharedBuffer.getEvent(eventId); checkState( eventWrapper != null, "Referring to non existent event with id %s", eventId); eventWrapper.lock(); sharedBuffer.upsertEvent(eventId, eventWrapper); }
/** * Increases the reference counter for the given event so that it is not * accidentally removed. * * @param eventId id of the entry */ private void lockEvent(EventId eventId) { Lockable<V> eventWrapper = sharedBuffer.getEvent(eventId); checkState( eventWrapper != null, "Referring to non existent event with id %s", eventId); eventWrapper.lock(); sharedBuffer.upsertEvent(eventId, eventWrapper); }
/** * Decreases the reference counter for the given event so that it can be * removed once the reference counter reaches 0. * * @param eventId id of the event * @throws Exception Thrown if the system cannot access the state. */ public void releaseEvent(EventId eventId) throws Exception { Lockable<V> eventWrapper = sharedBuffer.getEvent(eventId); if (eventWrapper != null) { if (eventWrapper.release()) { sharedBuffer.removeEvent(eventId); } else { sharedBuffer.upsertEvent(eventId, eventWrapper); } } }
/** * Decreases the reference counter for the given event so that it can be * removed once the reference counter reaches 0. * * @param eventId id of the event * @throws Exception Thrown if the system cannot access the state. */ public void releaseEvent(EventId eventId) throws Exception { Lockable<V> eventWrapper = sharedBuffer.getEvent(eventId); if (eventWrapper != null) { if (eventWrapper.release()) { sharedBuffer.removeEvent(eventId); } else { sharedBuffer.upsertEvent(eventId, eventWrapper); } } }