Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Apr 19, 2023
1 parent e2a47c3 commit 09f9df2
Showing 1 changed file with 50 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,15 @@
import java.util.function.BiFunction;
import java.util.function.Function;

/**
* An abstract representation of a data column.
*/
/** An abstract representation of a data column. */
public abstract class Storage<T> {
/**
* @return the number of elements in this column (including NAs)
*/
/** @return the number of elements in this column (including NAs) */
public abstract int size();

/**
* @return the number of NA elements in this column
*/
/** @return the number of NA elements in this column */
public abstract int countMissing();

/**
* @return the type tag of this column's storage.
*/
/** @return the type tag of this column's storage. */
public abstract StorageType getType();

/**
Expand All @@ -51,9 +43,7 @@ public abstract class Storage<T> {
*/
public abstract T getItemBoxed(int idx);

/**
* A container for names of vectorizable operation.
*/
/** A container for names of vectorizable operation. */
public static final class Maps {
public static final String EQ = "==";
public static final String LT = "<";
Expand Down Expand Up @@ -96,15 +86,16 @@ protected abstract Storage<?> runVectorizedZip(
/**
* Runs a function on each non-missing element in this storage and gathers the results.
*
* @param name a name of potential vectorized variant of the function that should be used if supported.
* If this argument is null, the vectorized operation will never be used.
* @param function the function to run.
* @param argument the argument to pass to each run of the function
* @param skipNulls specifies whether null values on the input should result in a null result without passing
* them through the function, this is useful if the function does not support the
* null-values, but it needs to be set to false if the function should handle them.
* @param expectedResultType the expected type for the result storage; it is ignored if the operation is vectorized
* @param problemBuilder a builder for reporting computation problems
* @param name a name of potential vectorized variant of the function that should be used if
* supported. If this argument is null, the vectorized operation will never be used.
* @param function the function to run.
* @param argument the argument to pass to each run of the function
* @param skipNulls specifies whether null values on the input should result in a null result
* without passing them through the function, this is useful if the function does not support
* the null-values, but it needs to be set to false if the function should handle them.
* @param expectedResultType the expected type for the result storage; it is ignored if the
* operation is vectorized
* @param problemBuilder a builder for reporting computation problems
* @return the result of running the function on all non-missing elements.
*/
public final Storage<?> bimap(
Expand Down Expand Up @@ -142,12 +133,13 @@ public final Storage<?> bimap(
/**
* Runs a function on each non-missing element in this storage and gathers the results.
*
* @param name a name of potential vectorized variant of the function that should be used if supported.
* If this argument is null, the vectorized operation will never be used.
* @param function the function to run.
* @param onMissing the value to place for missing cells, usually just null
* @param expectedResultType the expected type for the result storage; it is ignored if the operation is vectorized
* @param problemBuilder a builder for reporting computation problems
* @param name a name of potential vectorized variant of the function that should be used if
* supported. If this argument is null, the vectorized operation will never be used.
* @param function the function to run.
* @param onMissing the value to place for missing cells, usually just null
* @param expectedResultType the expected type for the result storage; it is ignored if the
* operation is vectorized
* @param problemBuilder a builder for reporting computation problems
* @return the result of running the function on all non-missing elements.
*/
public final Storage<?> map(
Expand Down Expand Up @@ -181,12 +173,13 @@ public final Storage<?> map(
/**
* Runs a function on each pair of non-missing elements in this and arg.
*
* @param name a name of potential vectorized variant of the function that should be used if supported.
* If this argument is null, the vectorized operation will never be used.
* @param function the function to run.
* @param skipNa whether rows containing missing values should be passed to the function.
* @param expectedResultType the expected type for the result storage; it is ignored if the operation is vectorized
* @param problemBuilder the builder used for reporting computation problems
* @param name a name of potential vectorized variant of the function that should be used if
* supported. If this argument is null, the vectorized operation will never be used.
* @param function the function to run.
* @param skipNa whether rows containing missing values should be passed to the function.
* @param expectedResultType the expected type for the result storage; it is ignored if the
* operation is vectorized
* @param problemBuilder the builder used for reporting computation problems
* @return the result of running the function on all non-missing elements.
*/
public final Storage<?> zip(
Expand Down Expand Up @@ -217,17 +210,23 @@ public final Storage<?> zip(
return storageBuilder.seal();
}

private static void checkFallback(Object fallback, StorageType storageType, String operationName) throws IllegalArgumentException {
private static void checkFallback(Object fallback, StorageType storageType, String operationName)
throws IllegalArgumentException {
if (fallback == null) {
if (operationName == null) {
throw new IllegalArgumentException("A function or name of vectorized operation must be specified. This is a bug in the Table library.");
throw new IllegalArgumentException(
"A function or name of vectorized operation must be specified. This is a bug in the Table library.");
} else {
throw new IllegalArgumentException("The operation " + operationName + " has no vectorized implementation for this storage type, but no fallback function was provided. This is a bug in the Table library.");
throw new IllegalArgumentException(
"The operation "
+ operationName
+ " has no vectorized implementation for this storage type, but no fallback function was provided. This is a bug in the Table library.");
}
}

if (storageType == null) {
throw new IllegalArgumentException("The expected result type must be specified if a fallback function is used. This is a bug in the Table library.");
throw new IllegalArgumentException(
"The expected result type must be specified if a fallback function is used. This is a bug in the Table library.");
}
}

Expand Down Expand Up @@ -276,7 +275,7 @@ protected final Storage<?> fillMissingHelper(Value arg, Builder builder) {
/**
* Return a new storage, containing only the items marked true in the mask.
*
* @param mask the mask to use
* @param mask the mask to use
* @param cardinality the number of true values in mask
* @return a new storage, masked with the given mask
*/
Expand All @@ -290,24 +289,24 @@ protected final Storage<?> fillMissingHelper(Value arg, Builder builder) {
public abstract Storage<T> applyMask(OrderMask mask);

/**
* Returns a new storage, resulting from applying the rules specified in a mask. The resulting storage should contain
* the elements of the original storage, in the same order. However, the number of consecutive copies of the i-th
* element of the original storage should be {@code counts[i]}.
* Returns a new storage, resulting from applying the rules specified in a mask. The resulting
* storage should contain the elements of the original storage, in the same order. However, the
* number of consecutive copies of the i-th element of the original storage should be {@code
* counts[i]}.
*
* @param counts the mask specifying elements duplication
* @param total the sum of all elements in the mask, also interpreted as the length of the resulting storage
* @param total the sum of all elements in the mask, also interpreted as the length of the
* resulting storage
* @return the storage masked according to the specified rules
*/
public abstract Storage<T> countMask(int[] counts, int total);

/**
* @return a copy of the storage containing a slice of the original data
*/
/** @return a copy of the storage containing a slice of the original data */
public abstract Storage<T> slice(int offset, int limit);

/**
* @return a new storage instance, containing the same elements as this one, with {@code count} nulls appended at the
* end
* @return a new storage instance, containing the same elements as this one, with {@code count}
* nulls appended at the end
*/
public Storage<?> appendNulls(int count) {
Builder builder = new InferredBuilder(size() + count);
Expand All @@ -323,9 +322,7 @@ public Storage<?> appendNulls(int count) {
*/
public abstract Builder createDefaultBuilderOfSameType(int capacity);

/**
* @return a copy of the storage consisting of slices of the original data
*/
/** @return a copy of the storage consisting of slices of the original data */
public abstract Storage<T> slice(List<SliceRange> ranges);

public List<Object> toList() {
Expand Down

0 comments on commit 09f9df2

Please sign in to comment.