-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
e584343
commit f659f3c
Showing
12 changed files
with
369 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
177 changes: 128 additions & 49 deletions
177
extensions/parquet/table/src/main/java/io/deephaven/parquet/table/ParquetTools.java
Large diffs are not rendered by default.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
extensions/parquet/table/src/main/java/io/deephaven/parquet/table/ParquetUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.deephaven.parquet.table; | ||
|
||
import java.nio.file.Path; | ||
|
||
public final class ParquetUtils { | ||
|
||
public static final String METADATA_FILE_NAME = "_metadata"; | ||
public static final String COMMON_METADATA_FILE_NAME = "_common_metadata"; | ||
public static final String PARQUET_FILE_EXTENSION = ".parquet"; | ||
|
||
/** | ||
* Used as a filter to select relevant parquet files while reading all files in a directory. | ||
*/ | ||
public static boolean fileNameMatches(final Path path) { | ||
final String fileName = path.getFileName().toString(); | ||
return fileName.endsWith(PARQUET_FILE_EXTENSION) && fileName.charAt(0) != '.'; | ||
} | ||
} |
134 changes: 134 additions & 0 deletions
134
extensions/parquet/table/src/main/java/io/deephaven/parquet/table/PartitionFormatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
package io.deephaven.parquet.table; | ||
|
||
import io.deephaven.time.DateTimeUtils; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.time.Instant; | ||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* This class takes an object read from a parquet file and formats it to a string, only for the supported types. | ||
*/ | ||
enum PartitionFormatter { | ||
ForString { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return (String) obj; | ||
} | ||
}, | ||
ForBoolean { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((Boolean) obj).toString(); | ||
} | ||
}, | ||
ForChar { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((Character) obj).toString(); | ||
} | ||
}, | ||
ForByte { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((Byte) obj).toString(); | ||
} | ||
}, | ||
ForShort { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((Short) obj).toString(); | ||
} | ||
}, | ||
ForInt { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((Integer) obj).toString(); | ||
} | ||
}, | ||
ForLong { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((Long) obj).toString(); | ||
} | ||
}, | ||
ForFloat { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((Float) obj).toString(); | ||
} | ||
}, | ||
ForDouble { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((Double) obj).toString(); | ||
} | ||
}, | ||
ForBigInteger { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((BigInteger) obj).toString(); | ||
} | ||
}, | ||
ForBigDecimal { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((BigDecimal) obj).toString(); | ||
} | ||
}, | ||
ForInstant { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((Instant) obj).toString(); | ||
} | ||
}, | ||
ForLocalDate { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return DateTimeUtils.formatDate((LocalDate) obj); | ||
} | ||
}, | ||
ForLocalTime { | ||
@Override | ||
public String format(@NotNull final Object obj) { | ||
return ((LocalTime) obj).toString(); | ||
} | ||
}; | ||
|
||
private static final Map<Class<?>, PartitionFormatter> typeMap = new HashMap<>(); | ||
static { | ||
typeMap.put(String.class, ForString); | ||
typeMap.put(Boolean.class, ForBoolean); | ||
typeMap.put(Character.class, ForChar); | ||
typeMap.put(Byte.class, ForByte); | ||
typeMap.put(Short.class, ForShort); | ||
typeMap.put(Integer.class, ForInt); | ||
typeMap.put(Long.class, ForLong); | ||
typeMap.put(Float.class, ForFloat); | ||
typeMap.put(Double.class, ForDouble); | ||
typeMap.put(BigInteger.class, ForBigInteger); | ||
typeMap.put(BigDecimal.class, ForBigDecimal); | ||
typeMap.put(Instant.class, ForInstant); | ||
typeMap.put(LocalDate.class, ForLocalDate); | ||
typeMap.put(LocalTime.class, ForLocalTime); | ||
} | ||
|
||
abstract String format(@NotNull Object obj); | ||
|
||
static String formatToString(final Object obj) { | ||
if (obj == null) { | ||
return "null"; | ||
} | ||
final PartitionFormatter formatter = typeMap.get(obj.getClass()); | ||
if (formatter != null) { | ||
return formatter.format(obj); | ||
} else { | ||
throw new UnsupportedOperationException("Unsupported type: " + obj.getClass().getSimpleName()); | ||
} | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
...ions/parquet/table/src/main/java/io/deephaven/parquet/table/layout/ParquetFileHelper.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.