Skip to content

Commit

Permalink
ARROW-5918: [Java] Add get to BaseIntVector interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tianchen92 committed Jul 12, 2019
1 parent ab7ff65 commit 5739cc4
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ public interface BaseIntVector extends ValueVector {
* set value at specific index, note this value may need to be need truncated.
*/
void setWithPossibleTruncate(int index, long value);

/**
* get value at specific index, note this value may haven been extended to long.
*/
long getValueAsLong(int index);
}
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ public void setWithPossibleTruncate(int index, long value) {
this.setSafe(index, value);
}

@Override
public long getValueAsLong(int index) {
return this.get(index);
}

private class TransferImpl implements TransferPair {
BigIntVector to;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ public void setWithPossibleTruncate(int index, long value) {
this.setSafe(index, (int) value);
}

@Override
public long getValueAsLong(int index) {
return this.get(index);
}

private class TransferImpl implements TransferPair {
IntVector to;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ public void setWithPossibleTruncate(int index, long value) {
this.setSafe(index, (int) value);
}

@Override
public long getValueAsLong(int index) {
return 0;
}

private class TransferImpl implements TransferPair {
SmallIntVector to;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ public void setWithPossibleTruncate(int index, long value) {
this.setSafe(index, (int) value);
}

@Override
public long getValueAsLong(int index) {
return this.get(index);
}

private class TransferImpl implements TransferPair {
TinyIntVector to;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ public void setWithPossibleTruncate(int index, long value) {
this.setSafe(index, (int) value);
}

@Override
public long getValueAsLong(int index) {
return this.get(index);
}



private class TransferImpl implements TransferPair {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ public void setWithPossibleTruncate(int index, long value) {
this.setSafe(index, (int) value);
}

@Override
public long getValueAsLong(int index) {
return this.get(index);
}

private class TransferImpl implements TransferPair {
UInt2Vector to;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ public void setWithPossibleTruncate(int index, long value) {
this.setSafe(index, (int) value);
}

@Override
public long getValueAsLong(int index) {
return this.get(index);
}

private class TransferImpl implements TransferPair {
UInt4Vector to;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ public void setWithPossibleTruncate(int index, long value) {
this.setSafe(index, value);
}

@Override
public long getValueAsLong(int index) {
return this.get(index);
}

private class TransferImpl implements TransferPair {
UInt8Vector to;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ public static ValueVector decode(ValueVector indices, Dictionary dictionary) {
// copy the dictionary values into the decoded vector
TransferPair transfer = dictionaryVector.getTransferPair(indices.getAllocator());
transfer.getTo().allocateNewSafe();

BaseIntVector baseIntVector = (BaseIntVector) indices;
for (int i = 0; i < count; i++) {
Object index = indices.getObject(i);
if (index != null) {
int indexAsInt = ((Number) index).intValue();
if (!baseIntVector.isNull(i)) {
int indexAsInt = (int) baseIntVector.getValueAsLong(i);
if (indexAsInt > dictionaryCount) {
throw new IllegalArgumentException("Provided dictionary does not contain value for index " + indexAsInt);
}
Expand Down

0 comments on commit 5739cc4

Please sign in to comment.