kishoreg commented on a change in pull request #5926: URL: https://github.com/apache/incubator-pinot/pull/5926#discussion_r477036505
########## File path: pinot-core/src/main/java/org/apache/pinot/core/query/utils/IdSet.java ########## @@ -0,0 +1,326 @@ +/** + * 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.pinot.core.query.utils; + +import com.google.common.base.Preconditions; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.Base64; +import java.util.Objects; +import javax.annotation.Nullable; +import org.apache.pinot.spi.data.FieldSpec.DataType; +import org.roaringbitmap.RoaringBitmap; +import org.roaringbitmap.longlong.Roaring64NavigableMap; + + +/** + * The {@code IdSet} represents a collection of ids. It can be used to optimize the query with huge IN clause. + */ +public class IdSet implements Comparable<IdSet> { + public static final IdSet EMPTY_ID_SET = new IdSet(Type.EMPTY, null, null); + + // Throw exception when the serialized IdSet is exceeding this threshold (32MB) + private static final int MAX_SIZE_IN_BYTES = 32 * 1024 * 1024; + + private enum Type { + // DO NOT change the index of the types as the ser/de relies on them + EMPTY(0), ROARING_BITMAP(1), ROARING_64_NAVIGABLE_MAP(2); + + private final int _index; + + Type(int index) { + _index = index; + } + } + + private final Type _type; + private final RoaringBitmap _bitmap; + private final Roaring64NavigableMap _longBitmap; + Review comment: Do you think this constructor is the only thing we need? If not, We should make this private and add static builders ########## File path: pinot-core/src/main/java/org/apache/pinot/core/query/utils/IdSet.java ########## @@ -0,0 +1,326 @@ +/** + * 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.pinot.core.query.utils; + +import com.google.common.base.Preconditions; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.Base64; +import java.util.Objects; +import javax.annotation.Nullable; +import org.apache.pinot.spi.data.FieldSpec.DataType; +import org.roaringbitmap.RoaringBitmap; +import org.roaringbitmap.longlong.Roaring64NavigableMap; + + +/** + * The {@code IdSet} represents a collection of ids. It can be used to optimize the query with huge IN clause. + */ +public class IdSet implements Comparable<IdSet> { Review comment: Let’s make this an interface with multiple implementations? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org