You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by yz...@apache.org on 2015/11/16 13:54:42 UTC
ignite git commit: fixing compaction
Repository: ignite
Updated Branches:
refs/heads/ignite-direct-marsh-opt 045bb6b57 -> f33e64309
fixing compaction
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f33e6430
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f33e6430
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f33e6430
Branch: refs/heads/ignite-direct-marsh-opt
Commit: f33e64309787e18a26adb46c080a6147a0c54469
Parents: 045bb6b
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Mon Nov 16 15:53:18 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Mon Nov 16 15:53:18 2015 +0300
----------------------------------------------------------------------
.../internal/direct/DirectByteBufferStream.java | 39 ++++++++++++++------
1 file changed, 28 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f33e6430/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
index 0201298..ccbfe09 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
@@ -289,6 +289,9 @@ public class DirectByteBufferStream {
private long prim;
/** */
+ private int primShift;
+
+ /** */
private boolean lastFinished;
/** */
@@ -365,17 +368,17 @@ public class DirectByteBufferStream {
* @param val Value.
*/
public void writeInt(int val) {
- if (val == Integer.MAX_VALUE)
- val = Integer.MIN_VALUE;
- else
- val++;
-
lastFinished = buf.remaining() >= 5;
if (lastFinished) {
+ if (val == Integer.MAX_VALUE)
+ val = Integer.MIN_VALUE;
+ else
+ val++;
+
int pos = buf.position();
- while ((val & 0xFFFFFF80) != 0) {
+ while ((val & 0xFFFF_FF80) != 0) {
byte b = (byte)(val | 0x80);
UNSAFE.putByte(heapArr, baseOff + pos++, b);
@@ -383,7 +386,7 @@ public class DirectByteBufferStream {
val >>>= 7;
}
- UNSAFE.putByte(heapArr, baseOff + pos++, (byte) val);
+ UNSAFE.putByte(heapArr, baseOff + pos++, (byte)val);
buf.position(pos);
}
@@ -396,9 +399,14 @@ public class DirectByteBufferStream {
lastFinished = buf.remaining() >= 10;
if (lastFinished) {
+ if (val == Long.MAX_VALUE)
+ val = Long.MIN_VALUE;
+ else
+ val++;
+
int pos = buf.position();
- while ((val & 0xFFFFFFFFFFFFFF80L) != 0) {
+ while ((val & 0xFFFF_FFFF_FFFF_FF80L) != 0) {
byte b = (byte)(val | 0x80);
UNSAFE.putByte(heapArr, baseOff + pos++, b);
@@ -406,7 +414,7 @@ public class DirectByteBufferStream {
val >>>= 7;
}
- UNSAFE.putByte(heapArr, baseOff + pos++, (byte) val);
+ UNSAFE.putByte(heapArr, baseOff + pos++, (byte)val);
buf.position(pos);
}
@@ -781,12 +789,14 @@ public class DirectByteBufferStream {
while (buf.hasRemaining()) {
byte b = UNSAFE.getByte(heapArr, baseOff + initPos + shift);
- prim |= ((long)b & 0x7F) << (7 * shift);
+ prim |= ((long)b & 0x7F) << (7 * primShift);
+ primShift++;
shift++;
if ((b & 0x80) == 0) {
lastFinished = true;
+ primShift = 0;
val = (int)prim;
@@ -820,15 +830,22 @@ public class DirectByteBufferStream {
while (buf.hasRemaining()) {
byte b = UNSAFE.getByte(heapArr, baseOff + initPos + shift);
- prim |= ((long)b & 0x7F) << (7 * shift);
+ prim |= ((long)b & 0x7F) << (7 * primShift);
shift++;
+ primShift++;
if ((b & 0x80) == 0) {
lastFinished = true;
+ primShift = 0;
val = prim;
+ if (val == Long.MIN_VALUE)
+ val = Long.MAX_VALUE;
+ else
+ val--;
+
prim = 0;
break;