Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Oct 14, 2022
1 parent eb120cc commit bc5b520
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.enso.table.data.column.storage;

import java.time.LocalDate;
import org.enso.table.data.column.operation.map.MapOpStorage;
import org.enso.table.data.column.operation.map.SpecializedIsInOp;

import java.time.LocalDate;

public final class DateStorage extends SpecializedStorage<LocalDate> {
/**
* @param data the underlying data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ public DateTimeStorage(ZonedDateTime[] data, int size) {
super(data, size, ops);
}

private static final MapOpStorage<ZonedDateTime, SpecializedStorage<ZonedDateTime>> ops = buildOps();
private static final MapOpStorage<ZonedDateTime, SpecializedStorage<ZonedDateTime>> ops =
buildOps();

private static MapOpStorage<ZonedDateTime, SpecializedStorage<ZonedDateTime>> buildOps() {
MapOpStorage<ZonedDateTime, SpecializedStorage<ZonedDateTime>> t = ObjectStorage.buildObjectOps();
MapOpStorage<ZonedDateTime, SpecializedStorage<ZonedDateTime>> t =
ObjectStorage.buildObjectOps();
t.add(SpecializedIsInOp.makeForTimeColumns(ZonedDateTime.class));
return t;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.enso.table.data.column.storage;

import java.util.BitSet;
import java.util.HashSet;
import java.util.List;
import org.enso.base.polyglot.NumericConverter;
import org.enso.table.data.column.builder.object.NumericBuilder;
import org.enso.table.data.column.operation.map.MapOpStorage;
Expand All @@ -12,10 +15,6 @@
import org.enso.table.data.mask.SliceRange;
import org.graalvm.polyglot.Value;

import java.util.BitSet;
import java.util.HashSet;
import java.util.List;

/** A column containing floating point numbers. */
public final class DoubleStorage extends NumericStorage<Double> {
private final long[] data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.enso.table.data.column.storage;

import java.util.BitSet;
import java.util.HashSet;
import java.util.List;
import java.util.OptionalLong;
import java.util.stream.LongStream;
import org.enso.base.polyglot.NumericConverter;
import org.enso.table.data.column.builder.object.NumericBuilder;
import org.enso.table.data.column.operation.aggregate.Aggregator;
Expand All @@ -14,12 +19,6 @@
import org.enso.table.data.mask.SliceRange;
import org.graalvm.polyglot.Value;

import java.util.BitSet;
import java.util.HashSet;
import java.util.List;
import java.util.OptionalLong;
import java.util.stream.LongStream;

/** A column storing 64-bit integers. */
public final class LongStorage extends NumericStorage<Long> {
private final long[] data;
Expand All @@ -43,13 +42,17 @@ public LongStorage(long[] data) {
this(data, data.length, new BitSet());
}

/** @inheritDoc */
/**
* @inheritDoc
*/
@Override
public int size() {
return size;
}

/** @inheritDoc */
/**
* @inheritDoc
*/
@Override
public int countMissing() {
return isMissing.cardinality();
Expand All @@ -73,13 +76,17 @@ public Long getItemBoxed(int idx) {
return isMissing.get(idx) ? null : data[idx];
}

/** @inheritDoc */
/**
* @inheritDoc
*/
@Override
public int getType() {
return Type.LONG;
}

/** @inheritDoc */
/**
* @inheritDoc
*/
@Override
public boolean isNa(long idx) {
return isMissing.get((int) idx);
Expand Down Expand Up @@ -367,18 +374,20 @@ public BoolStorage run(LongStorage storage) {
return new BoolStorage(storage.isMissing, new BitSet(), storage.size, false);
}
})
.add(SpecializedIsInOp.make(list -> {
HashSet<Long> set = new HashSet<>();
boolean hasNulls = false;
for (Object o : list) {
hasNulls |= o == null;
Long x = NumericConverter.tryConvertingToLong(o);
if (x != null) {
set.add(x);
}
}
return new SpecializedIsInOp.CompactRepresentation<>(set, hasNulls);
}));
.add(
SpecializedIsInOp.make(
list -> {
HashSet<Long> set = new HashSet<>();
boolean hasNulls = false;
for (Object o : list) {
hasNulls |= o == null;
Long x = NumericConverter.tryConvertingToLong(o);
if (x != null) {
set.add(x);
}
}
return new SpecializedIsInOp.CompactRepresentation<>(set, hasNulls);
}));
return ops;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.enso.table.data.column.storage;

import java.util.stream.DoubleStream;
import org.enso.table.data.column.operation.aggregate.Aggregator;
import org.enso.table.data.column.operation.aggregate.numeric.NumericAggregator;

import java.util.stream.DoubleStream;

/** A storage containing items representable as a {@code double}. */
public abstract class NumericStorage<T> extends Storage<T> {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.enso.table.data.column.storage;

import java.util.BitSet;
import org.enso.table.data.column.operation.map.MapOpStorage;
import org.enso.table.data.column.operation.map.UnaryMapOperation;

import java.util.BitSet;

/** A column storing arbitrary objects. */
public final class ObjectStorage extends SpecializedStorage<Object> {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.enso.table.data.column.storage;

import java.util.BitSet;
import java.util.List;
import org.enso.table.data.column.operation.map.MapOpStorage;
import org.enso.table.data.index.Index;
import org.enso.table.data.mask.OrderMask;
import org.enso.table.data.mask.SliceRange;

import java.util.BitSet;
import java.util.List;

public abstract class SpecializedStorage<T> extends Storage<T> {

protected abstract SpecializedStorage<T> newInstance(T[] data, int size);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.enso.table.data.column.storage;

import java.util.BitSet;
import java.util.HashMap;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.enso.base.polyglot.Polyglot_Utils;
import org.enso.table.data.column.builder.object.Builder;
import org.enso.table.data.column.builder.object.InferredBuilder;
Expand All @@ -11,12 +16,6 @@
import org.enso.table.data.mask.SliceRange;
import org.graalvm.polyglot.Value;

import java.util.BitSet;
import java.util.HashMap;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;

/** An abstract representation of a data column. */
public abstract class Storage<T> {
/** @return the number of elements in this column (including NAs) */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.BitSet;
import java.util.HashSet;

import org.enso.base.Text_Utils;
import org.enso.table.data.column.builder.object.StringBuilder;
import org.enso.table.data.column.operation.map.MapOpStorage;
Expand Down Expand Up @@ -134,17 +133,19 @@ protected boolean doString(String a, String b) {
}
});
t.add(new LikeOp());
t.add(SpecializedIsInOp.make(list -> {
HashSet<String> set = new HashSet<>();
boolean hasNulls = false;
for (Object o : list) {
hasNulls |= o == null;
if (o instanceof String s) {
set.add(s);
}
}
return new SpecializedIsInOp.CompactRepresentation<>(set, hasNulls);
}));
t.add(
SpecializedIsInOp.make(
list -> {
HashSet<String> set = new HashSet<>();
boolean hasNulls = false;
for (Object o : list) {
hasNulls |= o == null;
if (o instanceof String s) {
set.add(s);
}
}
return new SpecializedIsInOp.CompactRepresentation<>(set, hasNulls);
}));
return t;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.enso.table.data.column.storage;

import java.time.LocalTime;
import org.enso.table.data.column.operation.map.MapOpStorage;
import org.enso.table.data.column.operation.map.SpecializedIsInOp;

import java.time.LocalTime;

public final class TimeOfDayStorage extends SpecializedStorage<LocalTime> {
/**
* @param data the underlying data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public static BitSet buildDistinctRowsMask(
if (keyColumns.length != 0) {
HashSet<MultiValueKeyBase> visitedRows = new HashSet<>();
int size = keyColumns[0].getSize();
Storage<?>[] storage = Arrays.stream(keyColumns).map(Column::getStorage).toArray(Storage[]::new);
Storage<?>[] storage =
Arrays.stream(keyColumns).map(Column::getStorage).toArray(Storage[]::new);
for (int i = 0; i < size; i++) {
UnorderedMultiValueKey key = new UnorderedMultiValueKey(storage, i, textFoldingStrategy);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ public WithProblems<Object> parseIndependentValue(String text) {
* Parses a column of texts (represented as a {@code StringStorage}) and returns a new storage,
* containing the parsed elements.
*/
public abstract WithProblems<Storage<?>> parseColumn(String columnName, Storage<String> sourceStorage);
public abstract WithProblems<Storage<?>> parseColumn(
String columnName, Storage<String> sourceStorage);
}

0 comments on commit bc5b520

Please sign in to comment.