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
/*
* 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.spi.ConnectorSplit;
import com.facebook.presto.spi.HostAddress;
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 org.apache.iceberg.FileFormat;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static com.facebook.presto.spi.schedule.NodeSelectionStrategy.NO_PREFERENCE;
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;
@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)
{
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"));
}
@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;
}
@Override
public NodeSelectionStrategy getNodeSelectionStrategy()
{
return NO_PREFERENCE;
}
@Override
public List getPreferredNodes(List sortedCandidates)
{
return addresses;
}
@Override
public Object getInfo()
{
return ImmutableMap.builder()
.put("path", path)
.put("start", start)
.put("length", length)
.build();
}
@Override
public String toString()
{
return toStringHelper(this)
.addValue(path)
.addValue(start)
.addValue(length)
.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy