diff options
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/slime/BufferedOutput.java')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/slime/BufferedOutput.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/slime/BufferedOutput.java b/vespajlib/src/main/java/com/yahoo/slime/BufferedOutput.java index 20ed0fc8018..61a00185e76 100644 --- a/vespajlib/src/main/java/com/yahoo/slime/BufferedOutput.java +++ b/vespajlib/src/main/java/com/yahoo/slime/BufferedOutput.java @@ -1,22 +1,24 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.slime; -final class BufferedOutput { +import com.yahoo.compress.Compressor; + +class BufferedOutput { private byte[] buf; private int capacity; private int pos; - public BufferedOutput(int cap) { + BufferedOutput(int cap) { capacity = (cap < 64) ? 64 : cap; buf = new byte[capacity]; } - public BufferedOutput() { + BufferedOutput() { this(4096); } - public void reset() { + void reset() { pos = 0; } @@ -31,7 +33,7 @@ final class BufferedOutput { } } - public int position() { return pos; } + int position() { return pos; } void put(byte b) { reserve(1); @@ -49,9 +51,12 @@ final class BufferedOutput { } } - public byte[] toArray() { + byte[] toArray() { byte[] ret = new byte[pos]; System.arraycopy(buf, 0, ret, 0, pos); return ret; } + Compressor.Compression compress(Compressor compressor) { + return compressor.compress(buf, pos); + } } |