Skip to content

Commit 17c13c8

Browse files
committed
updates
1 parent d1a2d5a commit 17c13c8

File tree

5 files changed

+33
-36
lines changed

5 files changed

+33
-36
lines changed

src/main/java/com/arangodb/velocypack/VPackBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ private <T> VPackBuilder addInternal(final String attribute, final long tag, fin
651651
if (VPackSlice.attributeTranslator != null) {
652652
final VPackSlice translate = VPackSlice.attributeTranslator.translate(attribute);
653653
if (translate != null) {
654-
final byte[] trValue = translate.getRawVPack();
654+
final byte[] trValue = translate.getBuffer();
655655
int trValueLength = translate.getByteSize();
656656
int trValueStart = translate.getStart();
657657
ensureCapacity(size + trValueLength);
@@ -838,7 +838,7 @@ private void appendBinary(final byte[] value) {
838838
}
839839

840840
private void appendVPack(final VPackSlice value) {
841-
final byte[] vpack = value.getRawVPack();
841+
final byte[] vpack = value.getBuffer();
842842
int length = value.getByteSize();
843843
ensureCapacity(size + length);
844844
System.arraycopy(vpack, value.getStart(), buffer, size, length);

src/main/java/com/arangodb/velocypack/VPackSlice.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.math.BigInteger;
2626
import java.nio.charset.StandardCharsets;
2727
import java.util.ArrayList;
28-
import java.util.Arrays;
2928
import java.util.Collections;
3029
import java.util.Date;
3130
import java.util.Iterator;
@@ -544,7 +543,7 @@ private int getByteSize(int start) {
544543
break;
545544
default:
546545
// TODO
547-
throw new VPackException("Invalid type for byteSize()");
546+
throw new IllegalStateException("Invalid type for byteSize()");
548547
}
549548
}
550549
return (int) size;
@@ -885,18 +884,6 @@ public Iterator<Entry<String, VPackSlice>> objectIterator() {
885884
}
886885
}
887886

888-
protected byte[] getVPack() {
889-
if(start == 0 && vpack.length == getByteSize()) {
890-
return vpack;
891-
}
892-
893-
return Arrays.copyOfRange(vpack, start, start + getByteSize());
894-
}
895-
896-
protected byte[] getRawVPack() {
897-
return vpack;
898-
}
899-
900887
@Override
901888
public String toString() {
902889
try {

src/main/java/com/arangodb/velocypack/exception/VPackException.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
2424
* @author Mark Vollmary
2525
*
2626
*/
27-
public class VPackException extends RuntimeException {
27+
protected class VPackException extends RuntimeException {
2828

2929
private static final long serialVersionUID = 3547943271830879415L;
3030

31-
public VPackException() {
31+
protected VPackException() {
3232
super();
3333
}
3434

35-
public VPackException(final String message) {
35+
protected VPackException(final String message) {
3636
super(message);
3737
}
3838

39-
public VPackException(final Throwable cause) {
39+
protected VPackException(final Throwable cause) {
4040
super(cause);
4141
}
4242

src/test/java/com/arangodb/velocypack/VPackSliceTest.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,37 +1462,47 @@ public void maxNegativeIntFromIntAsLong() {
14621462

14631463
@Test
14641464
public void testReadTag() {
1465+
testReadTag(1);
1466+
testReadTag(10000);
1467+
}
1468+
1469+
@Test
1470+
public void testReadTags() {
1471+
testReadTags(1);
1472+
testReadTags(10000);
1473+
}
1474+
1475+
protected void testReadTag(int size) {
14651476
VPackBuilder b = new VPackBuilder();
1466-
b.addTagged(42, 5);
1477+
b.addTagged(42 * size, 5);
14671478

14681479
VPackSlice s = b.slice();
14691480

14701481
assertTrue(s.isTagged());
1471-
assertEquals(s.getFirstTag(), 42);
1472-
assertEquals((long) s.getTags().get(0), 42);
1482+
assertEquals(s.getFirstTag(), 42 * size);
1483+
assertEquals((long) s.getTags().get(0), 42 * size);
14731484
assertEquals(s.getTags().size(), 1);
1474-
assertTrue(s.hasTag(42));
1475-
assertFalse(s.hasTag(49));
1485+
assertTrue(s.hasTag(42 * size));
1486+
assertFalse(s.hasTag(49 * size));
14761487
assertEquals(s.value().getAsInt(), 5);
14771488
}
14781489

1479-
@Test
1480-
public void testReadTags() {
1490+
protected void testReadTags(int size) {
14811491
VPackBuilder b = new VPackBuilder();
1482-
b.addTagged(42, 5);
1492+
b.addTagged(42 * size, 5);
14831493

14841494
VPackBuilder bb = new VPackBuilder();
1485-
bb.addTagged(49, b.slice());
1495+
bb.addTagged(49 * size, b.slice());
14861496

14871497
VPackSlice s = bb.slice();
14881498

14891499
assertTrue(s.isTagged());
1490-
assertEquals(s.getFirstTag(), 49);
1500+
assertEquals(s.getFirstTag(), 49 * size);
14911501
assertEquals(s.getTags().size(), 2);
1492-
assertEquals((long) s.getTags().get(0), 49);
1493-
assertEquals((long) s.getTags().get(1), 42);
1494-
assertTrue(s.hasTag(42));
1495-
assertTrue(s.hasTag(49));
1496-
assertFalse(s.hasTag(50));
1502+
assertEquals((long) s.getTags().get(0), 49 * size);
1503+
assertEquals((long) s.getTags().get(1), 42 * size);
1504+
assertTrue(s.hasTag(42 * size));
1505+
assertTrue(s.hasTag(49 * size));
1506+
assertFalse(s.hasTag(50 * size));
14971507
}
14981508
}

src/test/java/com/arangodb/velocypack/VPackUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class VPackUtil {
2929
private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
3030

3131
public static String toHex(final VPackSlice vpack) {
32-
final byte[] bytes = vpack.getRawVPack();
32+
final byte[] bytes = vpack.getBuffer();
3333
final int bytesLength = vpack.getByteSize();
3434
final int bytesStart = vpack.getStart();
3535
final char[] hexChars = new char[bytesLength * 2];

0 commit comments

Comments
 (0)