aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/slime/BufferedInput.java
diff options
context:
space:
mode:
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/slime/BufferedInput.java')
-rw-r--r--vespajlib/src/main/java/com/yahoo/slime/BufferedInput.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/slime/BufferedInput.java b/vespajlib/src/main/java/com/yahoo/slime/BufferedInput.java
index ddbb25196b5..5c994d7f793 100644
--- a/vespajlib/src/main/java/com/yahoo/slime/BufferedInput.java
+++ b/vespajlib/src/main/java/com/yahoo/slime/BufferedInput.java
@@ -59,7 +59,7 @@ final class BufferedInput {
return ret;
}
- byte [] getBacking() { return source; }
+ byte[] getBacking() { return source; }
int getPosition() { return position; }
void skip(int size) {
if (position + size > end) {
@@ -80,4 +80,32 @@ final class BufferedInput {
}
return ret;
}
+
+ int read_cmpr_int() {
+ long next = getByte();
+ long value = (next & 0x7f);
+ int shift = 7;
+ while (shift < 32 && (next & 0x80) != 0) {
+ next = getByte();
+ value |= ((next & 0x7f) << shift);
+ shift += 7;
+ }
+ if (value > 0x7fff_ffffL) {
+ fail("compressed int overflow");
+ value = 0;
+ }
+ return (int)value;
+ }
+
+ int skip_cmpr_int() {
+ int extBits = 0;
+ while ((getByte() & 0x80) != 0) {
+ ++extBits;
+ }
+ return extBits;
+ }
+
+ int read_size(int meta) {
+ return (meta == 0) ? read_cmpr_int() : (meta - 1);
+ }
}