/** * Construct an accessor to deal with this sharedBuffer. * * @return an accessor to deal with this sharedBuffer. */ public SharedBufferAccessor<V> getAccessor() { return new SharedBufferAccessor<>(this); }
@Override protected final boolean shouldPrune(EventId startEventID, EventId pruningId) { return startEventID != null && startEventID.compareTo(pruningId) <= 0; } }
@Override public Lockable<E> copy( Lockable<E> from, Lockable<E> reuse) { return copy(from); }
/** * Removes the {@code SharedBufferNode}, when the ref is decreased to zero, and also * decrease the ref of the edge on this node. * * @param node id of the entry * @param sharedBufferNode the node body to be removed * @throws Exception Thrown if the system cannot access the state. */ private void removeNode(NodeId node, SharedBufferNode sharedBufferNode) throws Exception { sharedBuffer.removeEntry(node); EventId eventId = node.getEventId(); releaseEvent(eventId); for (SharedBufferEdge sharedBufferEdge : sharedBufferNode.getEdges()) { releaseNode(sharedBufferEdge.getTarget()); } }
/** * Increases the reference counter for the given entry so that it is not * accidentally removed. * * @param node id of the entry */ public void lockNode(final NodeId node) { Lockable<SharedBufferNode> sharedBufferNode = sharedBuffer.getEntry(node); if (sharedBufferNode != null) { sharedBufferNode.lock(); sharedBuffer.upsertEntry(node, sharedBufferNode); } }
@Override protected TypeSerializer<?>[] getNestedSerializers(Lockable.LockableTypeSerializer outerSerializer) { return new TypeSerializer<?>[] { outerSerializer.getElementSerializer() }; } }
@Override protected Lockable.LockableTypeSerializer createOuterSerializerWithNestedSerializers(TypeSerializer<?>[] nestedSerializers) { @SuppressWarnings("unchecked") TypeSerializer<E> elementSerializer = (TypeSerializer<E>) nestedSerializers[0]; return new Lockable.LockableTypeSerializer<>(elementSerializer); }
/** * Notifies shared buffer that there will be no events with timestamp <&eq; the given value. It allows to clear * internal counters for number of events seen so far per timestamp. * * @param timestamp watermark, no earlier events will arrive * @throws Exception Thrown if the system cannot access the state. */ public void advanceTime(long timestamp) throws Exception { sharedBuffer.advanceTime(timestamp); }
@Override public Lockable<E> deserialize( Lockable<E> reuse, DataInputView source) throws IOException { return deserialize(source); }
/** * Persists the entry in the cache to the underlay state. * * @throws Exception Thrown if the system cannot access the state. */ public void close() throws Exception { sharedBuffer.flushCache(); }
@Override public EventId copy(EventId from, EventId reuse) { return copy(from); }
@Override public NodeId copy(NodeId from) { return new NodeId(from.eventId, from.pageName); }
@Override public SharedBufferNode deserialize(SharedBufferNode reuse, DataInputView source) throws IOException { return deserialize(source); }
@Override @SuppressWarnings("unchecked") protected SharedBufferNodeSerializer createOuterSerializerWithNestedSerializers(TypeSerializer<?>[] nestedSerializers) { return new SharedBufferNodeSerializer((ListSerializer<SharedBufferEdge>) nestedSerializers[0]); }
public NFAStateSerializer() { this.versionSerializer = DeweyNumber.DeweyNumberSerializer.INSTANCE; this.eventIdSerializer = EventId.EventIdSerializer.INSTANCE; this.nodeIdSerializer = new NodeId.NodeIdSerializer(); }
@Override protected SharedBufferEdgeSerializer createOuterSerializerWithNestedSerializers(TypeSerializer<?>[] nestedSerializers) { return new SharedBufferEdgeSerializer( (NodeId.NodeIdSerializer) nestedSerializers[0], (DeweyNumber.DeweyNumberSerializer) nestedSerializers[1]); }
@Override public TypeSerializerSnapshot<NodeId> snapshotConfiguration() { return new NodeIdSerializerSnapshot(this); }
@Override public TypeSerializerSnapshot<EventId> snapshotConfiguration() { return new EventIdSerializerSnapshot(); }
@Override public SharedBufferEdge copy(SharedBufferEdge from, SharedBufferEdge reuse) { return copy(from); }
@Override protected boolean shouldPrune(EventId startEventID, EventId pruningId) { return startEventID != null && startEventID.compareTo(pruningId) < 0; }