From issues-return-153849-archive-asf-public=cust-asf.ponee.io@flink.apache.org Mon Feb 19 14:46:07 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 220D0180607 for ; Mon, 19 Feb 2018 14:46:06 +0100 (CET) Received: (qmail 23514 invoked by uid 500); 19 Feb 2018 13:46:06 -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 23505 invoked by uid 99); 19 Feb 2018 13:46:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Feb 2018 13:46:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id BD82B1A07D9 for ; Mon, 19 Feb 2018 13:46:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -101.511 X-Spam-Level: X-Spam-Status: No, score=-101.511 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id YjFkoiz-dTgZ for ; Mon, 19 Feb 2018 13:46:04 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id E13055F659 for ; Mon, 19 Feb 2018 13:46:03 +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 3E2A6E0350 for ; Mon, 19 Feb 2018 13:46:03 +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 AD39D22948 for ; Mon, 19 Feb 2018 13:46:00 +0000 (UTC) Date: Mon, 19 Feb 2018 13:46:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-8679) RocksDBKeyedBackend.getKeys(stateName, namespace) doesn't filter data with namespace MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLINK-8679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369129#comment-16369129 ] ASF GitHub Bot commented on FLINK-8679: --------------------------------------- Github user StefanRRichter commented on a diff in the pull request: https://github.com/apache/flink/pull/5518#discussion_r169074775 --- Diff: flink-contrib/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBKeyedStateBackend.java --- @@ -1991,43 +1999,71 @@ public int numStateEntries() { return count; } + /** + * This class is not thread safety. + */ private static class RocksIteratorWrapper implements Iterator { private final RocksIterator iterator; private final String state; private final TypeSerializer keySerializer; private final int keyGroupPrefixBytes; + private final byte[] namespaceBytes; + private K nextKey; public RocksIteratorWrapper( RocksIterator iterator, String state, TypeSerializer keySerializer, - int keyGroupPrefixBytes) { + int keyGroupPrefixBytes, + byte[] namespaceBytes) { this.iterator = Preconditions.checkNotNull(iterator); this.state = Preconditions.checkNotNull(state); this.keySerializer = Preconditions.checkNotNull(keySerializer); this.keyGroupPrefixBytes = Preconditions.checkNotNull(keyGroupPrefixBytes); + this.namespaceBytes = Preconditions.checkNotNull(namespaceBytes); + this.nextKey = null; } @Override public boolean hasNext() { - return iterator.isValid(); + final int namespaceBytesLength = namespaceBytes.length; + while (nextKey == null && iterator.isValid()) { + try { + boolean namespaceValid = true; + byte[] key = iterator.key(); + if (key.length >= namespaceBytesLength + keyGroupPrefixBytes) { + for (int i = 1; i <= namespaceBytesLength; ++i) { + if (key[key.length - i] != namespaceBytes[namespaceBytesLength - i]) { + namespaceValid = false; + break; + } + } + if (namespaceValid) { + DataInputViewStreamWrapper dataInput = new DataInputViewStreamWrapper( --- End diff -- This creates a lot of short-lived objects, and the `ByteArrayInputStreamWithPos` can also grow internally. I wonder if we could not just reuse always the same `ByteArrayInputStreamWithPos` at least? This could also let the internal array eventually be at good size. > RocksDBKeyedBackend.getKeys(stateName, namespace) doesn't filter data with namespace > ------------------------------------------------------------------------------------ > > Key: FLINK-8679 > URL: https://issues.apache.org/jira/browse/FLINK-8679 > Project: Flink > Issue Type: Bug > Components: State Backends, Checkpointing > Affects Versions: 1.5.0 > Reporter: Sihua Zhou > Assignee: Sihua Zhou > Priority: Blocker > Fix For: 1.5.0 > > > Currently, `RocksDBKeyedBackend.getKeys(stateName, namespace)` is odds. It doesn't use the namespace to filter data. And `HeapKeyedBackend.getKeys(stateName, namespace)` has done that, I think they should be consistent at least. -- This message was sent by Atlassian JIRA (v7.6.3#76005)