Skip to content

Commit

Permalink
Remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
liurenjie1024 committed Oct 29, 2024
1 parent d7d756d commit 2db4365
Showing 1 changed file with 0 additions and 58 deletions.
58 changes: 0 additions & 58 deletions src/main/java/com/nvidia/spark/rapids/jni/TableUtils.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.nvidia.spark.rapids.jni;

import ai.rapids.cudf.*;

import java.util.Arrays;
import java.util.Iterator;
import java.util.function.Function;
Expand All @@ -10,51 +8,6 @@
import java.util.stream.Collectors;

public class TableUtils {
public static Schema schemaOf(Table t) {
Schema.Builder builder = Schema.builder();

for (int i = 0; i < t.getNumberOfColumns(); i++) {
ColumnVector cv = t.getColumn(i);
addToSchema(cv, "col_" + i + "_", builder);
}

return builder.build();
}

public static void addToSchema(ColumnView cv, String namePrefix, Schema.Builder builder) {
toSchemaInner(cv, 0, namePrefix, builder);
}

private static int toSchemaInner(ColumnView cv, int idx, String namePrefix,
Schema.Builder builder) {
String name = namePrefix + idx;

Schema.Builder thisBuilder = builder.addColumn(cv.getType(), name);
int lastIdx = idx;
for (int i = 0; i < cv.getNumChildren(); i++) {
lastIdx = toSchemaInner(cv.getChildColumnView(i), lastIdx + 1, namePrefix,
thisBuilder);
}

return lastIdx;
}

public static void addToSchema(HostColumnVectorCore cv, String namePrefix, Schema.Builder builder) {
toSchemaInner(cv, 0, namePrefix, builder);
}

private static int toSchemaInner(HostColumnVectorCore cv, int idx, String namePrefix,
Schema.Builder builder) {
String name = namePrefix + idx;

Schema.Builder thisBuilder = builder.addColumn(cv.getType(), name);
int lastIdx = idx;
for (int i=0; i < cv.getNumChildren(); i++) {
lastIdx = toSchemaInner(cv.getChildColumnView(i), lastIdx + 1, namePrefix, thisBuilder);
}

return lastIdx;
}

public static void ensure(boolean condition, String message) {
if (!condition) {
Expand All @@ -78,17 +31,6 @@ public static long getValidityLengthInBytes(long rows) {
return (rows + 7) / 8;
}

/**
* This method returns the allocation size of the validity vector which is 64-byte aligned
* e.g. getValidityAllocationSizeInBytes(5) => 64 bytes
* getValidityAllocationSizeInBytes(14) => 64 bytes
* getValidityAllocationSizeInBytes(65) => 128 bytes
*/
static long getValidityAllocationSizeInBytes(long rows) {
long numBytes = getValidityLengthInBytes(rows);
return ((numBytes + 63) / 64) * 64;
}

public static <R extends AutoCloseable, T> T closeIfException(R resource, Function<R, T> function) {
try {
return function.apply(resource);
Expand Down

0 comments on commit 2db4365

Please sign in to comment.