Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closes #12 - Create copy constructors for LongArrayOutput and ByteBuf… #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ public ByteBufferBitOutput() {
this(DEFAULT_ALLOCATION);
}

/*
* Creates a deep copy of this object
*/
public ByteBufferBitOutput(ByteBufferBitOutput other) {
ByteBuffer otherBB = other.getByteBuffer();
this.bb = ByteBuffer.allocateDirect(otherBB.capacity());
otherBB.flip();
this.bb.put(otherBB);
this.bb.limit(bb.capacity());
otherBB.limit(otherBB.capacity());
this.b = other.b;
this.bitsLeft = other.bitsLeft;
}

/**
* Give an initialSize different than DEFAULT_ALLOCATIONS. Recommended to use values which are dividable by 4096.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fi.iki.yak.ts.compression.gorilla;

import java.util.Arrays;

/**
* An implementation of BitOutput interface that uses on-heap long array.
*
Expand Down Expand Up @@ -35,6 +37,15 @@ public class LongArrayOutput implements BitOutput {
}
}

/*
* Creates a deep copy of this object
*/
public LongArrayOutput(LongArrayOutput other) {
this.longArray = Arrays.copyOf(other.longArray, other.longArray.length);
this.position = other.position;
this.lB = other.lB;
this.bitsLeft = other.bitsLeft;
}

/**
* Creates a new ByteBufferBitOutput with a default allocated size of 4096 bytes.
Expand Down