Return-Path: X-Original-To: apmail-accumulo-dev-archive@www.apache.org Delivered-To: apmail-accumulo-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C3C5319A99 for ; Sat, 19 Mar 2016 19:20:32 +0000 (UTC) Received: (qmail 96347 invoked by uid 500); 19 Mar 2016 19:20:30 -0000 Delivered-To: apmail-accumulo-dev-archive@accumulo.apache.org Received: (qmail 96313 invoked by uid 500); 19 Mar 2016 19:20:30 -0000 Mailing-List: contact dev-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list dev@accumulo.apache.org Received: (qmail 96023 invoked by uid 99); 19 Mar 2016 19:20:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Mar 2016 19:20:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D5745DFB7D; Sat, 19 Mar 2016 19:20:29 +0000 (UTC) From: joshelser To: dev@accumulo.apache.org Reply-To: dev@accumulo.apache.org References: In-Reply-To: Subject: [GitHub] accumulo pull request: ACCUMULO-4164 Avoid copying rfile index whe... Content-Type: text/plain Message-Id: <20160319192029.D5745DFB7D@git1-us-west.apache.org> Date: Sat, 19 Mar 2016 19:20:29 +0000 (UTC) Github user joshelser commented on a diff in the pull request: https://github.com/apache/accumulo/pull/80#discussion_r56753765 --- Diff: core/src/main/java/org/apache/accumulo/core/file/rfile/MultiLevelIndex.java --- @@ -129,85 +130,114 @@ public int hashCode() { } } - // a list that deserializes index entries on demand - private static class SerializedIndex extends AbstractList implements List, RandomAccess { + private static abstract class SerializedIndexBase extends AbstractList implements List, RandomAccess { + protected int[] offsets; + protected byte[] data; - private int[] offsets; - private byte[] data; - private boolean newFormat; + protected SeekableByteArrayInputStream sbais; + protected DataInputStream dis; + protected int offsetsOffset; + protected int indexOffset; + protected int numOffsets; + protected int indexSize; - SerializedIndex(int[] offsets, byte[] data, boolean newFormat) { + SerializedIndexBase(int[] offsets, byte[] data) { this.offsets = offsets; this.data = data; - this.newFormat = newFormat; + sbais = new SeekableByteArrayInputStream(data); + dis = new DataInputStream(sbais); } - @Override - public IndexEntry get(int index) { - int len; - if (index == offsets.length - 1) - len = data.length - offsets[index]; - else - len = offsets[index + 1] - offsets[index]; + SerializedIndexBase(byte[] data, int offsetsOffset, int numOffsets, int indexOffset, int indexSize) { + sbais = new SeekableByteArrayInputStream(data, indexOffset + indexSize); + dis = new DataInputStream(sbais); + this.offsetsOffset = offsetsOffset; + this.indexOffset = indexOffset; + this.numOffsets = numOffsets; + this.indexSize = indexSize; + } - ByteArrayInputStream bais = new ByteArrayInputStream(data, offsets[index], len); - DataInputStream dis = new DataInputStream(bais); + protected abstract T newValue() throws IOException; --- End diff -- Add javadoc for what implementations should do with this abstract method. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---