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

Change JNI API to avoid loading native dependencies when creating sort order classes. [skip ci] #7729

Merged
merged 2 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
59 changes: 59 additions & 0 deletions java/src/main/java/ai/rapids/cudf/OrderByArg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
*
* Copyright (c) 2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package ai.rapids.cudf;

import java.io.Serializable;

/**
* Provides the ordering for specific columns.
*/
public final class OrderByArg implements Serializable {
final int index;
final boolean isDescending;
final boolean isNullSmallest;

OrderByArg(int index, boolean isDescending, boolean isNullSmallest) {
this.index = index;
this.isDescending = isDescending;
this.isNullSmallest = isNullSmallest;
}

public static OrderByArg asc(final int index) {
return new OrderByArg(index, false, false);
}

public static OrderByArg desc(final int index) {
return new OrderByArg(index, true, false);
}

public static OrderByArg asc(final int index, final boolean isNullSmallest) {
return new OrderByArg(index, false, isNullSmallest);
}

public static OrderByArg desc(final int index, final boolean isNullSmallest) {
return new OrderByArg(index, true, isNullSmallest);
}

@Override
public String toString() {
return "ORDER BY " + index +
(isDescending ? " DESC " : " ASC ") +
(isNullSmallest ? "NULL SMALLEST" : "NULL LARGEST");
}
}
38 changes: 1 addition & 37 deletions java/src/main/java/ai/rapids/cudf/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import ai.rapids.cudf.HostColumnVector.StructType;

import java.io.File;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -1444,7 +1443,7 @@ public ColumnVector sortOrder(OrderByArg... args) {
* responsible for cleaning up
* the {@link ColumnVector} returned as part of the output {@link Table}
* <p>
* Example usage: orderBy(true, Table.asc(0), Table.desc(3)...);
* Example usage: orderBy(true, OrderByArg.asc(0), OrderByArg.desc(3)...);
* @param args Suppliers to initialize sortKeys.
* @return Sorted Table
*/
Expand Down Expand Up @@ -1512,22 +1511,6 @@ public static Table merge(List<Table> tables, OrderByArg... args) {
return merge(tables.toArray(new Table[tables.size()]), args);
}

public static OrderByArg asc(final int index) {
jlowe marked this conversation as resolved.
Show resolved Hide resolved
return new OrderByArg(index, false, false);
}

public static OrderByArg desc(final int index) {
return new OrderByArg(index, true, false);
}

public static OrderByArg asc(final int index, final boolean isNullSmallest) {
return new OrderByArg(index, false, isNullSmallest);
}

public static OrderByArg desc(final int index, final boolean isNullSmallest) {
return new OrderByArg(index, true, isNullSmallest);
}

/**
* Returns count aggregation with only valid values.
* Null values are skipped.
Expand Down Expand Up @@ -2093,25 +2076,6 @@ public static Table fromPackedTable(ByteBuffer metadata, DeviceMemoryBuffer data
// HELPER CLASSES
/////////////////////////////////////////////////////////////////////////////

public static final class OrderByArg implements Serializable {
final int index;
final boolean isDescending;
final boolean isNullSmallest;

OrderByArg(int index, boolean isDescending, boolean isNullSmallest) {
this.index = index;
this.isDescending = isDescending;
this.isNullSmallest = isNullSmallest;
}

@Override
public String toString() {
return "ORDER BY " + index +
(isDescending ? " DESC " : " ASC ") +
(isNullSmallest ? "NULL SMALLEST" : "NULL LARGEST");
}
}

/**
* class to encapsulate indices and table
*/
Expand Down
Loading