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

Make HostColumnVector.DataType accessor methods public #15157

Merged
merged 6 commits into from
Feb 28, 2024
Merged
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
46 changes: 27 additions & 19 deletions java/src/main/java/ai/rapids/cudf/HostColumnVector.java
jlowe marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
* Copyright (c) 2020-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1179,12 +1179,12 @@ public final ColumnBuilder appendNull() {
private ColumnBuilder append(StructData structData) {
assert type.isNestedType();
if (type.equals(DType.STRUCT)) {
if (structData == null || structData.dataRecord == null) {
if (structData == null || structData.isNull()) {
return appendNull();
} else {
for (int i = 0; i < structData.getNumFields(); i++) {
ColumnBuilder childBuilder = childBuilders.get(i);
appendChildOrNull(childBuilder, structData.dataRecord.get(i));
appendChildOrNull(childBuilder, structData.getField(i));
}
endStruct();
}
Expand Down Expand Up @@ -2077,10 +2077,10 @@ public String toString() {
}

public static abstract class DataType {
abstract DType getType();
abstract boolean isNullable();
abstract DataType getChild(int index);
abstract int getNumChildren();
public abstract DType getType();
public abstract boolean isNullable();
public abstract DataType getChild(int index);
public abstract int getNumChildren();
}

public static class ListType extends HostColumnVector.DataType {
Expand All @@ -2093,25 +2093,25 @@ public ListType(boolean isNullable, DataType child) {
}

@Override
DType getType() {
public DType getType() {
return DType.LIST;
}

@Override
boolean isNullable() {
public boolean isNullable() {
return isNullable;
}

@Override
HostColumnVector.DataType getChild(int index) {
public HostColumnVector.DataType getChild(int index) {
if (index > 0) {
return null;
}
return child;
}

@Override
int getNumChildren() {
public int getNumChildren() {
return 1;
}
}
Expand All @@ -2134,6 +2134,14 @@ public int getNumFields() {
return 0;
}
}

public boolean isNull() {
return (this.dataRecord == null);
}

public Object getField(int index) {
return this.dataRecord.get(index);
}
}

public static class StructType extends HostColumnVector.DataType {
Expand All @@ -2150,22 +2158,22 @@ public StructType(boolean isNullable, DataType... children) {
}

@Override
DType getType() {
public DType getType() {
return DType.STRUCT;
}

@Override
boolean isNullable() {
public boolean isNullable() {
return isNullable;
}

@Override
HostColumnVector.DataType getChild(int index) {
public HostColumnVector.DataType getChild(int index) {
return children.get(index);
}

@Override
int getNumChildren() {
public int getNumChildren() {
return children.size();
}
}
Expand All @@ -2180,22 +2188,22 @@ public BasicType(boolean isNullable, DType type) {
}

@Override
DType getType() {
public DType getType() {
return type;
}

@Override
boolean isNullable() {
public boolean isNullable() {
return isNullable;
}

@Override
HostColumnVector.DataType getChild(int index) {
public HostColumnVector.DataType getChild(int index) {
return null;
}

@Override
int getNumChildren() {
public int getNumChildren() {
return 0;
}
}
Expand Down
Loading