Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.spi.predicate;
import com.facebook.presto.spi.ConnectorSession;
import com.facebook.presto.spi.block.Block;
import com.facebook.presto.spi.type.Type;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.util.Collections.unmodifiableCollection;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
/**
* A set containing values that are uniquely identifiable.
* Assumes an infinite number of possible values. The values may be collectively included (aka whitelist)
* or collectively excluded (aka !whitelist).
*/
public class EquatableValueSet
implements ValueSet
{
private final Type type;
private final boolean whiteList;
private final Set entries;
@JsonCreator
public EquatableValueSet(
@JsonProperty("type") Type type,
@JsonProperty("whiteList") boolean whiteList,
@JsonProperty("entries") Set entries)
{
requireNonNull(type, "type is null");
requireNonNull(entries, "entries is null");
if (!type.isComparable()) {
throw new IllegalArgumentException("Type is not comparable: " + type);
}
if (type.isOrderable()) {
throw new IllegalArgumentException("Use SortedRangeSet instead");
}
this.type = type;
this.whiteList = whiteList;
this.entries = Collections.unmodifiableSet(new HashSet<>(entries));
}
static EquatableValueSet none(Type type)
{
return new EquatableValueSet(type, true, Collections.emptySet());
}
static EquatableValueSet all(Type type)
{
return new EquatableValueSet(type, false, Collections.emptySet());
}
static EquatableValueSet of(Type type, Object first, Object... rest)
{
HashSet set = new HashSet<>(rest.length + 1);
set.add(ValueEntry.create(type, first));
for (Object value : rest) {
set.add(ValueEntry.create(type, value));
}
return new EquatableValueSet(type, true, set);
}
static EquatableValueSet copyOf(Type type, Collection