AMashenkov commented on a change in pull request #9118: URL: https://github.com/apache/ignite/pull/9118#discussion_r685408254
########## File path: modules/core/src/main/java/org/apache/ignite/cache/query/IndexQueryCriteriaBuilder.java ########## @@ -0,0 +1,77 @@ +/* + * 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.apache.ignite.cache.query; + +import org.apache.ignite.internal.cache.query.RangeIndexQueryCriterion; +import org.apache.ignite.internal.util.typedef.internal.A; + +/** + * Factory of {@link IndexQueryCriterion} for {@link IndexQuery}. + */ +public class IndexQueryCriteriaBuilder { + /** Object to mark a boundary if {@code null} is explicitly specified. */ + private static final Object NULL = new Null(); + + /** Equal To. */ + public static IndexQueryCriterion eq(String field, Object val) { + return between(field, val, val); + } + + /** Less Then. */ + public static IndexQueryCriterion lt(String field, Object val) { + A.notNullOrEmpty(field, "field"); + + return new RangeIndexQueryCriterion(field, null, wrapNull(val), true, false); + } + + /** Less Then or Equal. */ + public static IndexQueryCriterion lte(String field, Object val) { + A.notNullOrEmpty(field, "field"); + + return new RangeIndexQueryCriterion(field, null, wrapNull(val), true, true); + } + + /** Greater Then. */ + public static IndexQueryCriterion gt(String field, Object val) { + A.notNullOrEmpty(field, "field"); + + return new RangeIndexQueryCriterion(field, wrapNull(val), null, false, true); + } + + /** Greater Then or Equal. */ + public static IndexQueryCriterion gte(String field, Object val) { + A.notNullOrEmpty(field, "field"); + + return new RangeIndexQueryCriterion(field, wrapNull(val), null, true, true); + } + + /** Between. Lower and upper boundaries are inclusive. */ + public static IndexQueryCriterion between(String field, Object lower, Object upper) { + A.notNullOrEmpty(field, "field"); + + return new RangeIndexQueryCriterion(field, wrapNull(lower), wrapNull(upper), true, true); + } + + /** */ + private static Object wrapNull(Object val) { + return val == null ? NULL : val; + } + + /** Class to represent NULL value. */ + public static final class Null {} Review comment: But RangeIndexQueryCriterion already has the flags. 1Why you will need array of flags? RangeIndexQueryCriterion has all the information to answer whether Nulls should be included into the result or not. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
