Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces the concept of a TableLayout, which represents a physical organization of a Table. A table can have multiple physical layouts with different properties (partitioning, grouping, predicate, columns, etc). Presto will be able to take advantage of this information to pick the layout most suitable to satisfy a given query plan based on desired properties. Partition/ConnectorPartition/etc. are now deprecated, but there's an adaptation layer that allows existing connectors to work seamlessly with the new APIs. Once all connectors are migrated, those APIs will be removed.
- Loading branch information
Showing
50 changed files
with
1,324 additions
and
673 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
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
85 changes: 85 additions & 0 deletions
85
presto-main/src/main/java/com/facebook/presto/metadata/LegacyTableLayoutHandle.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,85 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.facebook.presto.metadata; | ||
|
||
import com.facebook.presto.spi.ConnectorPartition; | ||
import com.facebook.presto.spi.ConnectorTableHandle; | ||
import com.facebook.presto.spi.ConnectorTableLayoutHandle; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import static com.google.common.base.Preconditions.checkState; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
// Adaptation layer for connectors that implement the old getPartitions and getPartitionSplits API | ||
// TODO: remove once all connectors migrate to getTableLayouts/getSplits API | ||
public final class LegacyTableLayoutHandle | ||
implements ConnectorTableLayoutHandle | ||
{ | ||
private final ConnectorTableHandle table; | ||
private final List<ConnectorPartition> partitions; | ||
|
||
@JsonCreator | ||
public LegacyTableLayoutHandle(@JsonProperty("table") ConnectorTableHandle table) | ||
{ | ||
requireNonNull(table, "table is null"); | ||
|
||
this.table = table; | ||
this.partitions = null; | ||
} | ||
|
||
public LegacyTableLayoutHandle(ConnectorTableHandle table, List<ConnectorPartition> partitions) | ||
{ | ||
requireNonNull(table, "table is null"); | ||
requireNonNull(partitions, "partitions is null"); | ||
|
||
this.table = table; | ||
this.partitions = partitions; | ||
} | ||
|
||
@JsonProperty | ||
public ConnectorTableHandle getTable() | ||
{ | ||
return table; | ||
} | ||
|
||
public List<ConnectorPartition> getPartitions() | ||
{ | ||
checkState(partitions != null, "Partitions dropped by serialization"); | ||
return partitions; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
LegacyTableLayoutHandle that = (LegacyTableLayoutHandle) o; | ||
return Objects.equals(table, that.table) && | ||
Objects.equals(partitions, that.partitions); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return Objects.hash(table, partitions); | ||
} | ||
} |
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.