accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshelser <...@git.apache.org>
Subject [GitHub] accumulo pull request: ACCUMULO-4164 Avoid copying rfile index whe...
Date Sat, 19 Mar 2016 19:20:29 GMT
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<IndexEntry> implements
List<IndexEntry>, RandomAccess {
    +  private static abstract class SerializedIndexBase<T> extends AbstractList<T>
implements List<T>, 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.
---

Mime
View raw message