From issues-return-173429-archive-asf-public=cust-asf.ponee.io@flink.apache.org Tue Jun 26 15:26:06 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 49189180636 for ; Tue, 26 Jun 2018 15:26:05 +0200 (CEST) Received: (qmail 85132 invoked by uid 500); 26 Jun 2018 13:26:04 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 85119 invoked by uid 99); 26 Jun 2018 13:26:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jun 2018 13:26:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 017C918093F for ; Tue, 26 Jun 2018 13:26:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.31 X-Spam-Level: X-Spam-Status: No, score=-110.31 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 00373_7B_Vl3 for ; Tue, 26 Jun 2018 13:26:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id DFAD15F30B for ; Tue, 26 Jun 2018 13:26:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 8446BE0DE9 for ; Tue, 26 Jun 2018 13:26:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 41EC823F99 for ; Tue, 26 Jun 2018 13:26:00 +0000 (UTC) Date: Tue, 26 Jun 2018 13:26:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-9642) Reduce the count to deal with state during a CEP process MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLINK-9642?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1652= 3712#comment-16523712 ]=20 ASF GitHub Bot commented on FLINK-9642: --------------------------------------- Github user sihuazhou commented on a diff in the pull request: https://github.com/apache/flink/pull/6205#discussion_r198136425 =20 --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/= nfa/sharedbuffer/SharedBuffer.java --- @@ -346,16 +351,87 @@ private void lockEvent(EventId eventId) throws Ex= ception { =09 * @throws Exception Thrown if the system cannot access the state. =09 */ =09public void releaseEvent(EventId eventId) throws Exception { -=09=09Lockable eventWrapper =3D eventsBuffer.get(eventId); +=09=09Lockable eventWrapper =3D getEvent(eventId); =09=09if (eventWrapper !=3D null) { =09=09=09if (eventWrapper.release()) { =09=09=09=09eventsBuffer.remove(eventId); +=09=09=09=09eventsBufferCache.remove(eventId); =09=09=09} else { -=09=09=09=09eventsBuffer.put(eventId, eventWrapper); +=09=09=09=09cacheEvent(eventId, eventWrapper); =09=09=09} =09=09} =09} =20 +=09// Cache related method + +=09///////////////////////////////////////////// +=09// Put +=09///////////////////////////////////////////// + +=09/** +=09 * Put an event to cache. +=09 * @param eventId id of the event +=09 * @param event event body +=09 */ +=09private void cacheEvent(EventId eventId, Lockable event) { +=09=09this.eventsBufferCache.put(eventId, event); +=09} + +=09/** +=09 * Put a ShareBufferNode to cache. +=09 * @param nodeId id of the event +=09 * @param entry SharedBufferNode +=09 */ +=09private void cacheEntry(NodeId nodeId, Lockable e= ntry) { +=09=09this.entryCache.put(nodeId, entry); +=09} + +=09///////////////////////////////////////////// +=09// Get +=09///////////////////////////////////////////// + +=09/** +=09 * Try to get the sharedBufferNode from state iff the node has not = been quered during this turn process. +=09 * @param nodeId id of the event +=09 * @return SharedBufferNode +=09 * @throws Exception Thrown if the system cannot access the state. +=09 */ +=09private Lockable getEntry(NodeId nodeId) throws E= xception { +=09=09Lockable entry =3D entryCache.get(nodeId); +=09=09return entry !=3D null ? entry : entries.get(nodeId); +=09} + +=09private Lockable getEvent(EventId eventId) throws Exception { +=09=09Lockable event =3D eventsBufferCache.get(eventId); +=09=09return event !=3D null ? event : eventsBuffer.get(eventId); +=09} + +=09/** +=09 * Flush the event and node in map to state. +=09 * @throws Exception Thrown if the system cannot access the state. +=09 */ +=09public void flushCache() throws Exception { +=09=09entryCache.forEach((k, v) -> { +=09=09=09=09try { +=09=09=09=09=09entries.put(k, v); +=09=09=09=09} catch (Exception e) { +=09=09=09=09=09throw new RuntimeException(); +=09=09=09=09} +=09=09=09} +=09=09); + +=09=09eventsBufferCache.forEach((k, v) -> { +=09=09=09=09try { +=09=09=09=09=09eventsBuffer.put(k, v); +=09=09=09=09} catch (Exception e) { +=09=09=09=09=09throw new RuntimeException(); --- End diff -- =20 Same here, do not swallow the original Exception. > Reduce the count to deal with state during a CEP process=20 > --------------------------------------------------------- > > Key: FLINK-9642 > URL: https://issues.apache.org/jira/browse/FLINK-9642 > Project: Flink > Issue Type: Improvement > Components: CEP > Affects Versions: 1.6.0 > Reporter: aitozi > Assignee: aitozi > Priority: Major > Labels: pull-request-available > > With the rework of sharedBuffer Flink-9418, the lock & release operation = is deal with rocksdb state which is different from the previous version whi= ch will read the state of sharedBuffer all to memory, i think we can add a = cache or variable in sharedbuffer to cache the LockAble Object to mark the = ref change in once process in NFA, this will reduce the count when the even= ts point to the same NodeId.. And flush the result to MapState at the end o= f process.=C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005)