Search in sources :

Example 1 with ComparablePartitionValue

use of org.apache.flink.connector.file.table.PartitionFetcher.Context.ComparablePartitionValue in project flink by apache.

the class HiveContinuousPartitionFetcher method fetchPartitions.

@Override
@SuppressWarnings("unchecked")
public List<Tuple2<Partition, T>> fetchPartitions(Context<Partition, T> context, T previousOffset) throws Exception {
    List<Tuple2<Partition, T>> partitions = new ArrayList<>();
    List<ComparablePartitionValue> partitionValueList = context.getComparablePartitionValueList();
    for (ComparablePartitionValue<List<String>, T> partitionValue : partitionValueList) {
        T partitionOffset = partitionValue.getComparator();
        if (partitionOffset.compareTo(previousOffset) >= 0) {
            Partition partition = context.getPartition(partitionValue.getPartitionValue()).orElseThrow(() -> new IllegalArgumentException(String.format("Fetch partition fail for hive table %s.", context.getTablePath())));
            partitions.add(new Tuple2<>(partition, partitionValue.getComparator()));
        }
    }
    return partitions;
}
Also used : ComparablePartitionValue(org.apache.flink.connector.file.table.PartitionFetcher.Context.ComparablePartitionValue) Partition(org.apache.hadoop.hive.metastore.api.Partition) Tuple2(org.apache.flink.api.java.tuple.Tuple2) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with ComparablePartitionValue

use of org.apache.flink.connector.file.table.PartitionFetcher.Context.ComparablePartitionValue in project flink by splunk.

the class HiveContinuousPartitionFetcher method fetchPartitions.

@Override
@SuppressWarnings("unchecked")
public List<Tuple2<Partition, T>> fetchPartitions(Context<Partition, T> context, T previousOffset) throws Exception {
    List<Tuple2<Partition, T>> partitions = new ArrayList<>();
    List<ComparablePartitionValue> partitionValueList = context.getComparablePartitionValueList();
    for (ComparablePartitionValue<List<String>, T> partitionValue : partitionValueList) {
        T partitionOffset = partitionValue.getComparator();
        if (partitionOffset.compareTo(previousOffset) >= 0) {
            Partition partition = context.getPartition(partitionValue.getPartitionValue()).orElseThrow(() -> new IllegalArgumentException(String.format("Fetch partition fail for hive table %s.", context.getTablePath())));
            partitions.add(new Tuple2<>(partition, partitionValue.getComparator()));
        }
    }
    return partitions;
}
Also used : ComparablePartitionValue(org.apache.flink.connector.file.table.PartitionFetcher.Context.ComparablePartitionValue) Partition(org.apache.hadoop.hive.metastore.api.Partition) Tuple2(org.apache.flink.api.java.tuple.Tuple2) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with ComparablePartitionValue

use of org.apache.flink.connector.file.table.PartitionFetcher.Context.ComparablePartitionValue in project flink-mirror by flink-ci.

the class HiveContinuousPartitionFetcher method fetchPartitions.

@Override
@SuppressWarnings("unchecked")
public List<Tuple2<Partition, T>> fetchPartitions(Context<Partition, T> context, T previousOffset) throws Exception {
    List<Tuple2<Partition, T>> partitions = new ArrayList<>();
    List<ComparablePartitionValue> partitionValueList = context.getComparablePartitionValueList();
    for (ComparablePartitionValue<List<String>, T> partitionValue : partitionValueList) {
        T partitionOffset = partitionValue.getComparator();
        if (partitionOffset.compareTo(previousOffset) >= 0) {
            Partition partition = context.getPartition(partitionValue.getPartitionValue()).orElseThrow(() -> new IllegalArgumentException(String.format("Fetch partition fail for hive table %s.", context.getTablePath())));
            partitions.add(new Tuple2<>(partition, partitionValue.getComparator()));
        }
    }
    return partitions;
}
Also used : ComparablePartitionValue(org.apache.flink.connector.file.table.PartitionFetcher.Context.ComparablePartitionValue) Partition(org.apache.hadoop.hive.metastore.api.Partition) Tuple2(org.apache.flink.api.java.tuple.Tuple2) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)3 List (java.util.List)3 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)3 ComparablePartitionValue (org.apache.flink.connector.file.table.PartitionFetcher.Context.ComparablePartitionValue)3 Partition (org.apache.hadoop.hive.metastore.api.Partition)3