Copilot commented on code in PR #17291:
URL: https://github.com/apache/pinot/pull/17291#discussion_r2649756663


##########
pinot-plugins/pinot-system-table/src/main/java/org/apache/pinot/common/systemtable/datasource/InMemorySystemTableSegment.java:
##########
@@ -0,0 +1,723 @@
+/**
+ * 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.common.systemtable.datasource;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import java.io.File;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
+import java.util.function.IntFunction;
+import javax.annotation.Nullable;
+import org.apache.pinot.segment.spi.ColumnMetadata;
+import org.apache.pinot.segment.spi.Constants;
+import org.apache.pinot.segment.spi.IndexSegment;
+import org.apache.pinot.segment.spi.SegmentMetadata;
+import org.apache.pinot.segment.spi.creator.SegmentVersion;
+import org.apache.pinot.segment.spi.datasource.DataSource;
+import org.apache.pinot.segment.spi.datasource.DataSourceMetadata;
+import org.apache.pinot.segment.spi.index.IndexReader;
+import org.apache.pinot.segment.spi.index.IndexType;
+import org.apache.pinot.segment.spi.index.StandardIndexes;
+import org.apache.pinot.segment.spi.index.column.ColumnIndexContainer;
+import 
org.apache.pinot.segment.spi.index.multicolumntext.MultiColumnTextMetadata;
+import org.apache.pinot.segment.spi.index.reader.BloomFilterReader;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.segment.spi.index.reader.ForwardIndexReader;
+import org.apache.pinot.segment.spi.index.reader.ForwardIndexReaderContext;
+import org.apache.pinot.segment.spi.index.reader.H3IndexReader;
+import org.apache.pinot.segment.spi.index.reader.InvertedIndexReader;
+import org.apache.pinot.segment.spi.index.reader.JsonIndexReader;
+import org.apache.pinot.segment.spi.index.reader.NullValueVectorReader;
+import org.apache.pinot.segment.spi.index.reader.RangeIndexReader;
+import org.apache.pinot.segment.spi.index.reader.TextIndexReader;
+import org.apache.pinot.segment.spi.index.reader.VectorIndexReader;
+import org.apache.pinot.segment.spi.index.startree.StarTreeV2;
+import org.apache.pinot.segment.spi.index.startree.StarTreeV2Metadata;
+import org.apache.pinot.segment.spi.partition.PartitionFunction;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.joda.time.Duration;
+import org.joda.time.Interval;
+
+
+/**
+ * In-memory {@link IndexSegment} implementation intended for system table 
queries.
+ * <p>
+ * This segment is backed by per-column value functions (docId -&gt; value) 
and exposes raw forward indexes (no
+ * dictionaries/inverted indexes) so that the standard v1 query engine can 
operate on it.
+ */
+public final class InMemorySystemTableSegment implements IndexSegment {
+  private final String _segmentName;
+  private final Schema _schema;
+  private final int _numDocs;
+  private final Map<String, IntFunction<Object>> _valueProvidersByColumn;
+  private final Map<String, DataSource> _dataSourcesByColumn;
+  private final SegmentMetadata _segmentMetadata;
+
+  public InMemorySystemTableSegment(String segmentName, Schema schema, int 
numDocs,
+      Map<String, IntFunction<Object>> valueProvidersByColumn) {
+    _segmentName = segmentName;
+    _schema = schema;
+    _numDocs = numDocs;
+    _valueProvidersByColumn = new HashMap<>(valueProvidersByColumn);
+    _dataSourcesByColumn = new HashMap<>(schema.getColumnNames().size());
+    for (String column : schema.getColumnNames()) {
+      FieldSpec fieldSpec = schema.getFieldSpecFor(column);
+      if (fieldSpec == null) {
+        continue;
+      }
+      IntFunction<Object> provider = _valueProvidersByColumn.get(column);
+      if (provider == null) {
+        provider = docId -> defaultValue(fieldSpec.getDataType());
+        _valueProvidersByColumn.put(column, provider);
+      }
+      _dataSourcesByColumn.put(column, new FunctionBasedDataSource(fieldSpec, 
numDocs, provider));
+    }
+    _segmentMetadata = new InMemorySegmentMetadata(segmentName, schema, 
numDocs);
+  }
+
+  @Override
+  public String getSegmentName() {
+    return _segmentName;
+  }
+
+  @Override
+  public SegmentMetadata getSegmentMetadata() {
+    return _segmentMetadata;
+  }
+
+  @Override
+  public Set<String> getColumnNames() {
+    return _schema.getColumnNames();
+  }
+
+  @Override
+  public Set<String> getPhysicalColumnNames() {
+    return _schema.getPhysicalColumnNames();
+  }
+
+  @Nullable
+  @Override
+  public DataSource getDataSourceNullable(String column) {
+    return _dataSourcesByColumn.get(column);
+  }
+
+  @Override
+  public DataSource getDataSource(String column, Schema schema) {
+    DataSource dataSource = getDataSourceNullable(column);
+    if (dataSource != null) {
+      return dataSource;
+    }
+    throw new IllegalStateException("Failed to find data source for column: " 
+ column);
+  }
+
+  @Nullable
+  @Override
+  public List<StarTreeV2> getStarTrees() {
+    return null;
+  }
+
+  @Nullable
+  @Override
+  public TextIndexReader getMultiColumnTextIndex() {
+    return null;
+  }
+
+  @Nullable
+  @Override
+  public 
org.apache.pinot.segment.spi.index.mutable.ThreadSafeMutableRoaringBitmap 
getValidDocIds() {
+    return null;
+  }
+
+  @Nullable
+  @Override
+  public 
org.apache.pinot.segment.spi.index.mutable.ThreadSafeMutableRoaringBitmap 
getQueryableDocIds() {

Review Comment:
   Use import statements for `ThreadSafeMutableRoaringBitmap` instead of fully 
qualified names on lines 152 and 158.



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotSegmentAdminClient.java:
##########
@@ -36,6 +38,10 @@ public class PinotSegmentAdminClient {
   private final String _controllerAddress;
   private final Map<String, String> _headers;
 
+  private static String encodePathSegment(String segment) {
+    return URLEncoder.encode(segment, StandardCharsets.UTF_8);

Review Comment:
   URLEncoder.encode uses form encoding (application/x-www-form-urlencoded) 
which converts spaces to '+' rather than '%20'. For URL path segments, use 
`URLEncoder.encode().replace(\"+\", \"%20\")` or a dedicated URI encoding 
utility to ensure RFC 3986 compliance.
   ```suggestion
       return URLEncoder.encode(segment, StandardCharsets.UTF_8).replace("+", 
"%20");
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to