Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A802E200CDA for ; Fri, 21 Jul 2017 00:07:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A35CE16C395; Thu, 20 Jul 2017 22:07:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 963E016C38D for ; Fri, 21 Jul 2017 00:07:16 +0200 (CEST) Received: (qmail 53649 invoked by uid 500); 20 Jul 2017 22:07:15 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 53583 invoked by uid 99); 20 Jul 2017 22:07:14 -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; Thu, 20 Jul 2017 22:07:14 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 75E31DFF9F; Thu, 20 Jul 2017 22:07:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: git-site-role@apache.org To: commits@hbase.apache.org Date: Thu, 20 Jul 2017 22:07:14 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/19] hbase-site git commit: Published site at 82d554e3783372cc6b05489452c815b57c06f6cd. archived-at: Thu, 20 Jul 2017 22:07:17 -0000 Repository: hbase-site Updated Branches: refs/heads/asf-site 95b5168b3 -> 9e6e3360a http://git-wip-us.apache.org/repos/asf/hbase-site/blob/9e6e3360/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestByteBufferArray.DummyByteBufferArray.html ---------------------------------------------------------------------- diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestByteBufferArray.DummyByteBufferArray.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestByteBufferArray.DummyByteBufferArray.html new file mode 100644 index 0000000..59b1c7c --- /dev/null +++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestByteBufferArray.DummyByteBufferArray.html @@ -0,0 +1,193 @@ + + + +Source code + + + +
+
001/**
+002 * Licensed to the Apache Software Foundation (ASF) under one
+003 * or more contributor license agreements.  See the NOTICE file
+004 * distributed with this work for additional information
+005 * regarding copyright ownership.  The ASF licenses this file
+006 * to you under the Apache License, Version 2.0 (the
+007 * "License"); you may not use this file except in compliance
+008 * with the License.  You may obtain a copy of the License at
+009 *
+010 *     http://www.apache.org/licenses/LICENSE-2.0
+011 *
+012 * Unless required by applicable law or agreed to in writing, software
+013 * distributed under the License is distributed on an "AS IS" BASIS,
+014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+015 * See the License for the specific language governing permissions and
+016 * limitations under the License.
+017 */
+018package org.apache.hadoop.hbase.util;
+019
+020import static org.junit.Assert.assertEquals;
+021import static org.junit.Assert.assertFalse;
+022import static org.junit.Assert.assertTrue;
+023
+024import java.io.IOException;
+025import java.nio.ByteBuffer;
+026
+027import org.apache.hadoop.hbase.nio.ByteBuff;
+028import org.apache.hadoop.hbase.testclassification.MiscTests;
+029import org.apache.hadoop.hbase.testclassification.SmallTests;
+030import org.junit.Test;
+031import org.junit.experimental.categories.Category;
+032
+033@Category({MiscTests.class, SmallTests.class})
+034public class TestByteBufferArray {
+035
+036  @Test
+037  public void testAsSubBufferWhenEndOffsetLandInLastBuffer() throws Exception {
+038    int capacity = 4 * 1024 * 1024;
+039    ByteBufferAllocator allocator = new ByteBufferAllocator() {
+040      @Override
+041      public ByteBuffer allocate(long size, boolean directByteBuffer)
+042          throws IOException {
+043        if (directByteBuffer) {
+044          return ByteBuffer.allocateDirect((int) size);
+045        } else {
+046          return ByteBuffer.allocate((int) size);
+047        }
+048      }
+049    };
+050    ByteBufferArray array = new ByteBufferArray(capacity, false, allocator);
+051    ByteBuff subBuf = array.asSubByteBuff(0, capacity);
+052    subBuf.position(capacity - 1);// Position to the last byte
+053    assertTrue(subBuf.hasRemaining());
+054    // Read last byte
+055    subBuf.get();
+056    assertFalse(subBuf.hasRemaining());
+057  }
+058
+059  @Test
+060  public void testByteBufferCreation() throws Exception {
+061    int capacity = 470 * 1021 * 1023;
+062    ByteBufferAllocator allocator = new ByteBufferAllocator() {
+063      @Override
+064      public ByteBuffer allocate(long size, boolean directByteBuffer) throws IOException {
+065        if (directByteBuffer) {
+066          return ByteBuffer.allocateDirect((int) size);
+067        } else {
+068          return ByteBuffer.allocate((int) size);
+069        }
+070      }
+071    };
+072    ByteBufferArray array = new ByteBufferArray(capacity, false, allocator);
+073    assertEquals(119, array.buffers.length);
+074    for (int i = 0; i < array.buffers.length; i++) {
+075      if (i == array.buffers.length - 1) {
+076        assertEquals(array.buffers[i].capacity(), 0);
+077      } else {
+078        assertEquals(array.buffers[i].capacity(), ByteBufferArray.DEFAULT_BUFFER_SIZE);
+079      }
+080    }
+081  }
+082
+083  @Test
+084  public void testByteBufferCreation1() throws Exception {
+085    ByteBufferAllocator allocator = new ByteBufferAllocator() {
+086      @Override
+087      public ByteBuffer allocate(long size, boolean directByteBuffer) throws IOException {
+088        if (directByteBuffer) {
+089          return ByteBuffer.allocateDirect((int) size);
+090        } else {
+091          return ByteBuffer.allocate((int) size);
+092        }
+093      }
+094    };
+095    ByteBufferArray array = new DummyByteBufferArray(7 * 1024 * 1024, false, allocator);
+096    // overwrite
+097    array.bufferCount = 25;
+098    array.buffers = new ByteBuffer[array.bufferCount + 1];
+099    array.createBuffers(true, allocator);
+100    for (int i = 0; i < array.buffers.length; i++) {
+101      if (i == array.buffers.length - 1) {
+102        assertEquals(array.buffers[i].capacity(), 0);
+103      } else {
+104        assertEquals(array.buffers[i].capacity(), 458752);
+105      }
+106    }
+107  }
+108
+109  private static class DummyByteBufferArray extends ByteBufferArray {
+110
+111    public DummyByteBufferArray(long capacity, boolean directByteBuffer,
+112        ByteBufferAllocator allocator) throws IOException {
+113      super(capacity, directByteBuffer, allocator);
+114    }
+115
+116    @Override
+117    int getThreadCount() {
+118      return 16;
+119    }
+120  }
+121}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + http://git-wip-us.apache.org/repos/asf/hbase-site/blob/9e6e3360/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestByteBufferArray.html ---------------------------------------------------------------------- diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestByteBufferArray.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestByteBufferArray.html index 6112641..59b1c7c 100644 --- a/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestByteBufferArray.html +++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestByteBufferArray.html @@ -87,7 +87,46 @@ 079 } 080 } 081 } -082} +082 +083 @Test +084 public void testByteBufferCreation1() throws Exception { +085 ByteBufferAllocator allocator = new ByteBufferAllocator() { +086 @Override +087 public ByteBuffer allocate(long size, boolean directByteBuffer) throws IOException { +088 if (directByteBuffer) { +089 return ByteBuffer.allocateDirect((int) size); +090 } else { +091 return ByteBuffer.allocate((int) size); +092 } +093 } +094 }; +095 ByteBufferArray array = new DummyByteBufferArray(7 * 1024 * 1024, false, allocator); +096 // overwrite +097 array.bufferCount = 25; +098 array.buffers = new ByteBuffer[array.bufferCount + 1]; +099 array.createBuffers(true, allocator); +100 for (int i = 0; i < array.buffers.length; i++) { +101 if (i == array.buffers.length - 1) { +102 assertEquals(array.buffers[i].capacity(), 0); +103 } else { +104 assertEquals(array.buffers[i].capacity(), 458752); +105 } +106 } +107 } +108 +109 private static class DummyByteBufferArray extends ByteBufferArray { +110 +111 public DummyByteBufferArray(long capacity, boolean directByteBuffer, +112 ByteBufferAllocator allocator) throws IOException { +113 super(capacity, directByteBuffer, allocator); +114 } +115 +116 @Override +117 int getThreadCount() { +118 return 16; +119 } +120 } +121}