You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2019/06/12 08:30:48 UTC

[GitHub] [hbase] openinx commented on a change in pull request #268: HBASE-22491 Separate the heap HFileBlock and offheap HFileBlock because the heap block won't need refCnt and save into prevBlocks list before shipping

openinx commented on a change in pull request #268: HBASE-22491 Separate the heap HFileBlock and offheap HFileBlock because the heap block won't need refCnt and save into prevBlocks list before shipping
URL: https://github.com/apache/hbase/pull/268#discussion_r292798239
 
 

 ##########
 File path: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockBuilder.java
 ##########
 @@ -0,0 +1,108 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.io.hfile;
+
+import static javax.swing.Spring.UNSET;
+import static org.apache.hadoop.hbase.io.ByteBuffAllocator.HEAP;
+
+import org.apache.hadoop.hbase.io.ByteBuffAllocator;
+import org.apache.hadoop.hbase.nio.ByteBuff;
+import org.apache.yetus.audience.InterfaceAudience;
+
+@InterfaceAudience.Private
+public class HFileBlockBuilder {
+
+  private BlockType blockType;
+  private int onDiskSizeWithoutHeader;
+  private int onDiskDataSizeWithHeader;
+  private int uncompressedSizeWithoutHeader;
+  private long prevBlockOffset;
+  private ByteBuff buf;
+  private boolean fillHeader = false;
+  private long offset = UNSET;
+  private int nextBlockOnDiskSize = UNSET;
+  private HFileContext fileContext;
+  private ByteBuffAllocator allocator = HEAP;
+
+  public HFileBlockBuilder withBlockType(BlockType blockType) {
+    this.blockType = blockType;
+    return this;
+  }
+
+  public HFileBlockBuilder withOnDiskSizeWithoutHeader(int onDiskSizeWithoutHeader) {
+    this.onDiskSizeWithoutHeader = onDiskSizeWithoutHeader;
+    return this;
+  }
+
+  public HFileBlockBuilder withOnDiskDataSizeWithHeader(int onDiskDataSizeWithHeader) {
+    this.onDiskDataSizeWithHeader = onDiskDataSizeWithHeader;
+    return this;
+  }
+
+  public HFileBlockBuilder withUncompressedSizeWithoutHeader(int uncompressedSizeWithoutHeader) {
+    this.uncompressedSizeWithoutHeader = uncompressedSizeWithoutHeader;
+    return this;
+  }
+
+  public HFileBlockBuilder withPrevBlockOffset(long prevBlockOffset) {
+    this.prevBlockOffset = prevBlockOffset;
+    return this;
+  }
+
+  public HFileBlockBuilder withByteBuff(ByteBuff buf) {
+    this.buf = buf;
+    return this;
+  }
+
+  public HFileBlockBuilder withFillHeader(boolean fillHeader) {
+    this.fillHeader = fillHeader;
+    return this;
+  }
+
+  public HFileBlockBuilder withOffset(long offset) {
+    this.offset = offset;
+    return this;
+  }
+
+  public HFileBlockBuilder withNextBlockOnDiskSize(int nextBlockOnDiskSize) {
+    this.nextBlockOnDiskSize = nextBlockOnDiskSize;
+    return this;
+  }
+
+  public HFileBlockBuilder withHFileContext(HFileContext fileContext) {
+    this.fileContext = fileContext;
+    return this;
+  }
+
+  public HFileBlockBuilder withByteBuffAllocator(ByteBuffAllocator allocator) {
+    this.allocator = allocator;
+    return this;
+  }
+
+  public HFileBlock build() {
+    if (buf.hasArray()) {
 
 Review comment:
   OK,  will do. Thanks.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services