-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae60022
commit 554ada6
Showing
10 changed files
with
311 additions
and
117 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
63 changes: 63 additions & 0 deletions
63
...uet/table/src/main/java/io/deephaven/parquet/table/location/ParquetColumnResolverMap.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,63 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.parquet.table.location; | ||
|
||
import io.deephaven.annotations.BuildableStyle; | ||
import org.apache.parquet.column.ColumnDescriptor; | ||
import org.apache.parquet.schema.MessageType; | ||
import org.immutables.value.Value; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** | ||
* A {@link ParquetColumnResolver} implementation based on a map from Deephaven column names to Parquet | ||
* {@link ColumnDescriptor column descriptors}. | ||
*/ | ||
@Value.Immutable | ||
@BuildableStyle | ||
public abstract class ParquetColumnResolverMap implements ParquetColumnResolver { | ||
|
||
public static Builder builder() { | ||
return ImmutableParquetColumnResolverMap.builder(); | ||
} | ||
|
||
/** | ||
* The Parquet schema. | ||
*/ | ||
public abstract MessageType schema(); | ||
|
||
/** | ||
* The map from Deephaven column name to {@link ColumnDescriptor}. The {@link #schema()} must contains the column | ||
* descriptors. | ||
*/ | ||
public abstract Map<String, ColumnDescriptor> mapping(); | ||
|
||
@Override | ||
public final Optional<ColumnDescriptor> of(String columnName) { | ||
return Optional.ofNullable(mapping().get(columnName)); | ||
} | ||
|
||
public interface Builder { | ||
Builder schema(MessageType schema); | ||
|
||
Builder putMapping(String key, ColumnDescriptor value); | ||
|
||
Builder putAllMapping(Map<String, ? extends ColumnDescriptor> entries); | ||
|
||
ParquetColumnResolverMap build(); | ||
} | ||
|
||
@Value.Check | ||
final void checkMapping() { | ||
for (Map.Entry<String, ColumnDescriptor> e : mapping().entrySet()) { | ||
final ColumnDescriptor columnDescriptor = e.getValue(); | ||
if (!ParquetUtil.contains(schema(), columnDescriptor)) { | ||
throw new IllegalArgumentException( | ||
String.format("schema does not contain Deephaven columnName=%s columnDescriptor=%s", e.getKey(), | ||
columnDescriptor)); | ||
} | ||
} | ||
} | ||
} |
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.