com.facebook.presto.iceberg.IcebergSplit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of presto-iceberg Show documentation
Show all versions of presto-iceberg Show documentation
Presto - Iceberg Connector
The newest version!
/*
* 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.iceberg;
import com.facebook.presto.hive.HivePartitionKey;
import com.facebook.presto.iceberg.changelog.ChangelogSplitInfo;
import com.facebook.presto.iceberg.delete.DeleteFile;
import com.facebook.presto.spi.ConnectorSplit;
import com.facebook.presto.spi.HostAddress;
import com.facebook.presto.spi.NodeProvider;
import com.facebook.presto.spi.SplitWeight;
import com.facebook.presto.spi.schedule.NodeSelectionStrategy;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static com.facebook.presto.spi.schedule.NodeSelectionStrategy.SOFT_AFFINITY;
import static com.google.common.base.MoreObjects.toStringHelper;
import static java.util.Objects.requireNonNull;
public class IcebergSplit
implements ConnectorSplit
{
private final String path;
private final long start;
private final long length;
private final FileFormat fileFormat;
private final List addresses;
private final Map partitionKeys;
private final String partitionSpecAsJson;
private final Optional partitionDataJson;
private final NodeSelectionStrategy nodeSelectionStrategy;
private final SplitWeight splitWeight;
private final List deletes;
private final Optional changelogSplitInfo;
private final long dataSequenceNumber;
@JsonCreator
public IcebergSplit(
@JsonProperty("path") String path,
@JsonProperty("start") long start,
@JsonProperty("length") long length,
@JsonProperty("fileFormat") FileFormat fileFormat,
@JsonProperty("addresses") List addresses,
@JsonProperty("partitionKeys") Map partitionKeys,
@JsonProperty("partitionSpecAsJson") String partitionSpecAsJson,
@JsonProperty("partitionDataJson") Optional partitionDataJson,
@JsonProperty("nodeSelectionStrategy") NodeSelectionStrategy nodeSelectionStrategy,
@JsonProperty("splitWeight") SplitWeight splitWeight,
@JsonProperty("deletes") List deletes,
@JsonProperty("changelogSplitInfo") Optional changelogSplitInfo,
@JsonProperty("dataSequenceNumber") long dataSequenceNumber)
{
requireNonNull(nodeSelectionStrategy, "nodeSelectionStrategy is null");
this.path = requireNonNull(path, "path is null");
this.start = start;
this.length = length;
this.fileFormat = requireNonNull(fileFormat, "fileFormat is null");
this.addresses = ImmutableList.copyOf(requireNonNull(addresses, "addresses is null"));
this.partitionKeys = Collections.unmodifiableMap(requireNonNull(partitionKeys, "partitionKeys is null"));
this.partitionSpecAsJson = requireNonNull(partitionSpecAsJson, "partitionSpecAsJson is null");
this.partitionDataJson = partitionDataJson;
this.nodeSelectionStrategy = nodeSelectionStrategy;
this.splitWeight = requireNonNull(splitWeight, "splitWeight is null");
this.deletes = ImmutableList.copyOf(requireNonNull(deletes, "deletes is null"));
this.changelogSplitInfo = requireNonNull(changelogSplitInfo, "changelogSplitInfo is null");
this.dataSequenceNumber = dataSequenceNumber;
}
@JsonProperty
public List getAddresses()
{
return addresses;
}
@JsonProperty
public String getPath()
{
return path;
}
@JsonProperty
public long getStart()
{
return start;
}
@JsonProperty
public long getLength()
{
return length;
}
@JsonProperty
public FileFormat getFileFormat()
{
return fileFormat;
}
@JsonProperty
public Map getPartitionKeys()
{
return partitionKeys;
}
@JsonProperty
public String getPartitionSpecAsJson()
{
return partitionSpecAsJson;
}
@JsonProperty
public Optional getPartitionDataJson()
{
return partitionDataJson;
}
@JsonProperty
@Override
public NodeSelectionStrategy getNodeSelectionStrategy()
{
return nodeSelectionStrategy;
}
@Override
public List getPreferredNodes(NodeProvider nodeProvider)
{
if (getNodeSelectionStrategy() == SOFT_AFFINITY) {
return nodeProvider.get(path);
}
return addresses;
}
@JsonProperty
@Override
public SplitWeight getSplitWeight()
{
return splitWeight;
}
@JsonProperty
public List getDeletes()
{
return deletes;
}
@JsonProperty
public Optional getChangelogSplitInfo()
{
return changelogSplitInfo;
}
@JsonProperty
public long getDataSequenceNumber()
{
return dataSequenceNumber;
}
@Override
public Object getInfo()
{
return ImmutableMap.builder()
.put("path", path)
.put("start", start)
.put("length", length)
.put("nodeSelectionStrategy", nodeSelectionStrategy)
.put("splitWeight", splitWeight)
.put("changelogSplitInfo", changelogSplitInfo)
.build();
}
@Override
public String toString()
{
return toStringHelper(this)
.addValue(path)
.addValue(start)
.addValue(length)
.addValue(nodeSelectionStrategy)
.addValue(splitWeight)
.addValue(changelogSplitInfo)
.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy