You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ra...@apache.org on 2017/04/28 09:15:09 UTC
hbase git commit: HBASE-17950 Write the chunkId also as Int instead
of long into the first byte of the chunk (Ram)
Repository: hbase
Updated Branches:
refs/heads/master 68b2e0f7d -> b401a35fd
HBASE-17950 Write the chunkId also as Int instead of long into the first
byte of the chunk (Ram)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b401a35f
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b401a35f
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b401a35f
Branch: refs/heads/master
Commit: b401a35fdc883c74847bc41131e5900939558dab
Parents: 68b2e0f
Author: Ramkrishna <ra...@intel.com>
Authored: Fri Apr 28 14:43:19 2017 +0530
Committer: Ramkrishna <ra...@intel.com>
Committed: Fri Apr 28 14:44:46 2017 +0530
----------------------------------------------------------------------
.../org/apache/hadoop/hbase/regionserver/Chunk.java | 4 ++--
.../apache/hadoop/hbase/regionserver/OffheapChunk.java | 2 +-
.../apache/hadoop/hbase/regionserver/OnheapChunk.java | 2 +-
.../hadoop/hbase/regionserver/TestDefaultMemStore.java | 4 ++--
.../hbase/regionserver/TestMemStoreChunkPool.java | 2 +-
.../hadoop/hbase/regionserver/TestMemStoreLAB.java | 12 ++++++------
.../hbase/regionserver/TestMemstoreLABWithoutPool.java | 8 ++++----
7 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/b401a35f/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Chunk.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Chunk.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Chunk.java
index fc4aa0b..a45d801 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Chunk.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Chunk.java
@@ -100,8 +100,8 @@ public abstract class Chunk {
throw e;
}
// Mark that it's ready for use
- // Move 8 bytes since the first 8 bytes are having the chunkid in it
- boolean initted = nextFreeOffset.compareAndSet(UNINITIALIZED, Bytes.SIZEOF_LONG);
+ // Move 4 bytes since the first 4 bytes are having the chunkid in it
+ boolean initted = nextFreeOffset.compareAndSet(UNINITIALIZED, Bytes.SIZEOF_INT);
// We should always succeed the above CAS since only one thread
// calls init()!
Preconditions.checkState(initted, "Multiple threads tried to init same chunk");
http://git-wip-us.apache.org/repos/asf/hbase/blob/b401a35f/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OffheapChunk.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OffheapChunk.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OffheapChunk.java
index e244a33..f5d4905 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OffheapChunk.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OffheapChunk.java
@@ -41,7 +41,7 @@ public class OffheapChunk extends Chunk {
void allocateDataBuffer() {
if (data == null) {
data = ByteBuffer.allocateDirect(this.size);
- data.putLong(0, this.getId());
+ data.putInt(0, this.getId());
}
}
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/b401a35f/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OnheapChunk.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OnheapChunk.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OnheapChunk.java
index da34e24..38001ea 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OnheapChunk.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OnheapChunk.java
@@ -39,7 +39,7 @@ public class OnheapChunk extends Chunk {
void allocateDataBuffer() {
if (data == null) {
data = ByteBuffer.allocate(this.size);
- data.putLong(0, this.getId());
+ data.putInt(0, this.getId());
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hbase/blob/b401a35f/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java
index 41b304b..3acb48b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java
@@ -140,8 +140,8 @@ public class TestDefaultMemStore {
// make sure chunk size increased even when writing the same cell, if using MSLAB
if (msLab instanceof MemStoreLABImpl) {
// since we add the chunkID at the 0th offset of the chunk and the
- // chunkid is a long we need to account for those 8 bytes
- assertEquals(2 * Segment.getCellLength(kv) + Bytes.SIZEOF_LONG,
+ // chunkid is an int we need to account for those 4 bytes
+ assertEquals(2 * Segment.getCellLength(kv) + Bytes.SIZEOF_INT,
((MemStoreLABImpl) msLab).getCurrentChunk().getNextFreeOffset());
}
} else {
http://git-wip-us.apache.org/repos/asf/hbase/blob/b401a35f/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreChunkPool.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreChunkPool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreChunkPool.java
index 1768801..aedb905 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreChunkPool.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreChunkPool.java
@@ -90,7 +90,7 @@ public class TestMemStoreChunkPool {
int size = KeyValueUtil.length(kv);
ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv);
if (newKv.getBuffer() != lastBuffer) {
- expectedOff = 8;
+ expectedOff = 4;
lastBuffer = newKv.getBuffer();
}
assertEquals(expectedOff, newKv.getOffset());
http://git-wip-us.apache.org/repos/asf/hbase/blob/b401a35f/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreLAB.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreLAB.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreLAB.java
index 63e63ea..7def2a7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreLAB.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreLAB.java
@@ -76,7 +76,7 @@ public class TestMemStoreLAB {
MemStoreLAB mslab = new MemStoreLABImpl();
int expectedOff = 0;
ByteBuffer lastBuffer = null;
- long lastChunkId = -1;
+ int lastChunkId = -1;
// 100K iterations by 0-1K alloc -> 50MB expected
// should be reasonable for unit test and also cover wraparound
// behavior
@@ -87,10 +87,10 @@ public class TestMemStoreLAB {
ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv);
if (newKv.getBuffer() != lastBuffer) {
// since we add the chunkID at the 0th offset of the chunk and the
- // chunkid is a long we need to account for those 8 bytes
- expectedOff = Bytes.SIZEOF_LONG;
+ // chunkid is an int we need to account for those 4 bytes
+ expectedOff = Bytes.SIZEOF_INT;
lastBuffer = newKv.getBuffer();
- long chunkId = newKv.getBuffer().getLong(0);
+ int chunkId = newKv.getBuffer().getInt(0);
assertTrue("chunkid should be different", chunkId != lastChunkId);
lastChunkId = chunkId;
}
@@ -172,8 +172,8 @@ public class TestMemStoreLAB {
// Now check each byte array to make sure allocations don't overlap
for (Map<Integer, AllocRecord> allocsInChunk : mapsByChunk.values()) {
// since we add the chunkID at the 0th offset of the chunk and the
- // chunkid is a long we need to account for those 8 bytes
- int expectedOff = Bytes.SIZEOF_LONG;
+ // chunkid is an int we need to account for those 4 bytes
+ int expectedOff = Bytes.SIZEOF_INT;
for (AllocRecord alloc : allocsInChunk.values()) {
assertEquals(expectedOff, alloc.offset);
assertTrue("Allocation overruns buffer",
http://git-wip-us.apache.org/repos/asf/hbase/blob/b401a35f/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemstoreLABWithoutPool.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemstoreLABWithoutPool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemstoreLABWithoutPool.java
index 1af98e9..96be8ec 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemstoreLABWithoutPool.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemstoreLABWithoutPool.java
@@ -66,7 +66,7 @@ public class TestMemstoreLABWithoutPool {
MemStoreLAB mslab = new MemStoreLABImpl();
int expectedOff = 0;
ByteBuffer lastBuffer = null;
- long lastChunkId = -1;
+ int lastChunkId = -1;
// 100K iterations by 0-1K alloc -> 50MB expected
// should be reasonable for unit test and also cover wraparound
// behavior
@@ -77,10 +77,10 @@ public class TestMemstoreLABWithoutPool {
ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv);
if (newKv.getBuffer() != lastBuffer) {
// since we add the chunkID at the 0th offset of the chunk and the
- // chunkid is a long we need to account for those 8 bytes
- expectedOff = Bytes.SIZEOF_LONG;
+ // chunkid is an int we need to account for those 4 bytes
+ expectedOff = Bytes.SIZEOF_INT;
lastBuffer = newKv.getBuffer();
- long chunkId = newKv.getBuffer().getLong(0);
+ int chunkId = newKv.getBuffer().getInt(0);
assertTrue("chunkid should be different", chunkId != lastChunkId);
lastChunkId = chunkId;
}