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 to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.dinky.shaded.paimon.predicate;
import org.dinky.shaded.paimon.annotation.Public;
import org.dinky.shaded.paimon.data.BinaryRow;
import org.dinky.shaded.paimon.data.BinaryString;
import org.dinky.shaded.paimon.data.Decimal;
import org.dinky.shaded.paimon.data.Timestamp;
import org.dinky.shaded.paimon.types.DataField;
import org.dinky.shaded.paimon.types.DataType;
import org.dinky.shaded.paimon.types.DecimalType;
import org.dinky.shaded.paimon.types.RowType;
import org.dinky.shaded.paimon.utils.Preconditions;
import org.dinky.shaded.paimon.utils.RowDataToObjectArrayConverter;
import org.dinky.shaded.paimon.utils.TypeUtils;
import javax.annotation.Nullable;
import java.math.BigDecimal;
import java.sql.Date;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import static java.util.Collections.singletonList;
/**
* A utility class to create {@link Predicate} object for common filter conditions.
*
* @since 0.4.0
*/
@Public
public class PredicateBuilder {
private final RowType rowType;
private final List fieldNames;
public PredicateBuilder(RowType rowType) {
this.rowType = rowType;
this.fieldNames = rowType.getFieldNames();
}
public int indexOf(String field) {
return fieldNames.indexOf(field);
}
public Predicate equal(int idx, Object literal) {
return leaf(Equal.INSTANCE, idx, literal);
}
public Predicate notEqual(int idx, Object literal) {
return leaf(NotEqual.INSTANCE, idx, literal);
}
public Predicate lessThan(int idx, Object literal) {
return leaf(LessThan.INSTANCE, idx, literal);
}
public Predicate lessOrEqual(int idx, Object literal) {
return leaf(LessOrEqual.INSTANCE, idx, literal);
}
public Predicate greaterThan(int idx, Object literal) {
return leaf(GreaterThan.INSTANCE, idx, literal);
}
public Predicate greaterOrEqual(int idx, Object literal) {
return leaf(GreaterOrEqual.INSTANCE, idx, literal);
}
public Predicate isNull(int idx) {
return leaf(IsNull.INSTANCE, idx);
}
public Predicate isNotNull(int idx) {
return leaf(IsNotNull.INSTANCE, idx);
}
public Predicate startsWith(int idx, Object patternLiteral) {
return leaf(StartsWith.INSTANCE, idx, patternLiteral);
}
public Predicate leaf(NullFalseLeafBinaryFunction function, int idx, Object literal) {
DataField field = rowType.getFields().get(idx);
return new LeafPredicate(function, field.type(), idx, field.name(), singletonList(literal));
}
public Predicate leaf(LeafUnaryFunction function, int idx) {
DataField field = rowType.getFields().get(idx);
return new LeafPredicate(
function, field.type(), idx, field.name(), Collections.emptyList());
}
public Predicate in(int idx, List