Skip to content

Commit

Permalink
Decimal32 Build Fix (rapidsai#7544)
Browse files Browse the repository at this point in the history
This is a replacement of rapidsai#7542 which was held up because the changes weren't being reflected on it.

Authors:
  - Raza Jafri (@razajafri)

Approvers:
  - Gera Shegalov (@gerashegalov)
  - Niranjan Artal (@nartal1)

URL: rapidsai#7544
  • Loading branch information
razajafri authored and hyperbolic2346 committed Mar 23, 2021
1 parent 1f89144 commit b301977
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions java/src/main/java/ai/rapids/cudf/ColumnView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1394,9 +1394,13 @@ public ColumnView replaceChildrenWithViews(int[] indices,
List<ColumnView> newChildren = new ArrayList<>(getNumChildren());
IntStream.range(0, getNumChildren()).forEach(i -> {
ColumnView view = map.remove(i);
ColumnView child = getChildColumnView(i);
if (view == null) {
newChildren.add(getChildColumnView(i));
newChildren.add(child);
} else {
if (child.getRowCount() != view.getRowCount()) {
throw new IllegalArgumentException("Child row count doesn't match the old child");
}
newChildren.add(view);
}
});
Expand Down Expand Up @@ -1431,7 +1435,7 @@ public ColumnView replaceChildrenWithViews(int[] indices,
*/
public ColumnView replaceListChild(ColumnView child) {
assert(type == DType.LIST);
return replaceChildrenWithViews(new int[]{1}, new ColumnView[]{child});
return replaceChildrenWithViews(new int[]{0}, new ColumnView[]{child});
}

/**
Expand Down
9 changes: 6 additions & 3 deletions java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4005,7 +4005,7 @@ void testReplaceLeafNodeInList() {

@Test
void testReplaceLeafNodeInListWithIllegal() {
assertThrows(IllegalArgumentException.class, () -> {
Exception e = assertThrows(IllegalArgumentException.class, () -> {
try (ColumnVector child1 =
ColumnVector.decimalFromDoubles(DType.create(DType.DTypeEnum.DECIMAL64, 3),
RoundingMode.HALF_UP, 770.892, 961.110);
Expand All @@ -4023,6 +4023,7 @@ void testReplaceLeafNodeInListWithIllegal() {
ColumnView replacedView = created.replaceListChild(newChild)) {
}
});
assertTrue(e.getMessage().contains("Child row count doesn't match the old child"));
}

@Test
Expand All @@ -4049,7 +4050,7 @@ void testReplaceColumnInStruct() {

@Test
void testReplaceIllegalIndexColumnInStruct() {
assertThrows(IllegalArgumentException.class, () -> {
Exception e = assertThrows(IllegalArgumentException.class, () -> {
try (ColumnVector child1 = ColumnVector.fromInts(1, 4);
ColumnVector child2 = ColumnVector.fromInts(2, 5);
ColumnVector child3 = ColumnVector.fromInts(3, 6);
Expand All @@ -4059,11 +4060,12 @@ void testReplaceIllegalIndexColumnInStruct() {
new ColumnVector[]{replaceWith})) {
}
});
assertTrue(e.getMessage().contains("One or more invalid child indices passed to be replaced"));
}

@Test
void testReplaceSameIndexColumnInStruct() {
assertThrows(IllegalArgumentException.class, () -> {
Exception e = assertThrows(IllegalArgumentException.class, () -> {
try (ColumnVector child1 = ColumnVector.fromInts(1, 4);
ColumnVector child2 = ColumnVector.fromInts(2, 5);
ColumnVector child3 = ColumnVector.fromInts(3, 6);
Expand All @@ -4073,5 +4075,6 @@ void testReplaceSameIndexColumnInStruct() {
new ColumnVector[]{replaceWith, replaceWith})) {
}
});
assertTrue(e.getMessage().contains("Duplicate mapping found for replacing child index"));
}
}

0 comments on commit b301977

Please sign in to comment.