Jackie-Jiang commented on a change in pull request #6286: URL: https://github.com/apache/incubator-pinot/pull/6286#discussion_r537795504
########## File path: pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java ########## @@ -58,6 +58,7 @@ public static TableConfig fromZNRecord(ZNRecord znRecord) String tableName = znRecord.getId(); String tableType = simpleFields.get(TableConfig.TABLE_TYPE_KEY); + String isDimTable = simpleFields.get(TableConfig.IS_DIM_TABLE_KEY); Review comment: Store as boolean for clarity? ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/assignment/segment/OfflineDimTableSegmentAssignment.java ########## @@ -0,0 +1,94 @@ +/** + * 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.controller.helix.core.assignment.segment; + +import com.google.common.base.Preconditions; +import org.apache.commons.configuration.Configuration; +import org.apache.helix.HelixManager; +import org.apache.pinot.common.assignment.InstancePartitions; +import org.apache.pinot.common.tier.Tier; +import org.apache.pinot.common.utils.CommonConstants; +import org.apache.pinot.common.utils.config.TagNameUtils; +import org.apache.pinot.common.utils.helix.HelixHelper; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.config.table.TenantConfig; +import org.apache.pinot.spi.config.table.assignment.InstancePartitionsType; + +import javax.annotation.Nullable; + +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + + +/** + * Segment assignment for an offline dimension table. + * <ul> + * <li> + * <p>This segment assignment strategy is used when {@link TableConfig#IS_DIM_TABLE_KEY}is + * set to "true".</p> + * </li> + * <li> + * <p>For a dimension table we assign the segment to all the hosts Thus for this assignment + * strategy we simply return all the hosts under a given tag as the assigned hosts for + * a given segment.</p> + * </li> + * </ul> + */ +public class OfflineDimTableSegmentAssignment implements SegmentAssignment { + + private HelixManager _helixManager; + private String _offlineTableName; + private boolean _isDimTable; Review comment: No need to keep this member variable ########## File path: pinot-core/src/main/java/org/apache/pinot/core/data/manager/config/TableDataManagerConfig.java ########## @@ -35,6 +35,7 @@ private static final String TABLE_DATA_MANAGER_DATA_DIRECTORY = "directory"; private static final String TABLE_DATA_MANAGER_CONSUMER_DIRECTORY = "consumerDirectory"; private static final String TABLE_DATA_MANAGER_NAME = "name"; + private static final String TABLE_IS_DIMENSION = "isDimTable"; Review comment: We should not have this config on instance level. It does not make sense for a server to only serve dimension table ########## File path: pinot-spi/src/main/java/org/apache/pinot/spi/utils/builder/TableConfigBuilder.java ########## @@ -55,6 +55,7 @@ private final TableType _tableType; private String _tableName; + private String _isDimTable; Review comment: Store boolean ########## File path: pinot-tools/src/main/java/org/apache/pinot/tools/JoinQuickStart.java ########## @@ -0,0 +1,127 @@ +/** + * 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.tools; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import org.apache.commons.io.FileUtils; +import org.apache.pinot.spi.plugin.PluginManager; +import org.apache.pinot.tools.admin.command.QuickstartRunner; + +import java.io.File; +import java.net.URL; + +import static org.apache.pinot.tools.Quickstart.prettyPrintResponse; +import static org.apache.pinot.tools.Quickstart.printStatus; + + +public class JoinQuickStart { Review comment: Don't add this quick start yet. We can add it along with the lookup feature support ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/assignment/segment/OfflineDimTableSegmentAssignment.java ########## @@ -0,0 +1,94 @@ +/** + * 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.controller.helix.core.assignment.segment; + +import com.google.common.base.Preconditions; +import org.apache.commons.configuration.Configuration; +import org.apache.helix.HelixManager; +import org.apache.pinot.common.assignment.InstancePartitions; +import org.apache.pinot.common.tier.Tier; +import org.apache.pinot.common.utils.CommonConstants; +import org.apache.pinot.common.utils.config.TagNameUtils; +import org.apache.pinot.common.utils.helix.HelixHelper; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.config.table.TenantConfig; +import org.apache.pinot.spi.config.table.assignment.InstancePartitionsType; + +import javax.annotation.Nullable; + +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + + +/** + * Segment assignment for an offline dimension table. + * <ul> + * <li> + * <p>This segment assignment strategy is used when {@link TableConfig#IS_DIM_TABLE_KEY}is + * set to "true".</p> + * </li> + * <li> + * <p>For a dimension table we assign the segment to all the hosts Thus for this assignment + * strategy we simply return all the hosts under a given tag as the assigned hosts for + * a given segment.</p> + * </li> + * </ul> + */ +public class OfflineDimTableSegmentAssignment implements SegmentAssignment { + + private HelixManager _helixManager; + private String _offlineTableName; + private boolean _isDimTable; + private TenantConfig _tenantConfig; + + @Override + public void init(HelixManager helixManager, TableConfig tableConfig) { + _helixManager = helixManager; + _offlineTableName = tableConfig.getTableName(); + _tenantConfig = tableConfig.getTenantConfig(); + _isDimTable = Boolean.parseBoolean(tableConfig.getIsDimTable()); + Preconditions.checkState(_isDimTable, "Not a dimension table: %s" + _offlineTableName); + } + + @Override + public List<String> assignSegment(String segmentName, Map<String, Map<String, String>> currentAssignment, + Map<InstancePartitionsType, InstancePartitions> instancePartitionsMap) { + String serverTag = TagNameUtils.extractOfflineServerTag(_tenantConfig); + + List<String> instances = HelixHelper.getInstancesWithTag(_helixManager, serverTag); + int numInstances = instances.size(); + Preconditions.checkState(numInstances > 0, "No instance found with tag: %s", serverTag); + + return instances; + } + + @Override + public Map<String, Map<String, String>> rebalanceTable(Map<String, Map<String, String>> currentAssignment, + Map<InstancePartitionsType, InstancePartitions> instancePartitionsMap, @Nullable List<Tier> sortedTiers, + @Nullable Map<String, InstancePartitions> tierInstancePartitionsMap, Configuration config) { + Map<String, Map<String, String>> newAssignment = new TreeMap<>(); + for (String segment : currentAssignment.keySet()) { Review comment: No need to assign per segment. Fetch the instances with the tag once, and construct the new assignment ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/assignment/segment/SegmentAssignmentFactory.java ########## @@ -32,7 +32,9 @@ private SegmentAssignmentFactory() { public static SegmentAssignment getSegmentAssignment(HelixManager helixManager, TableConfig tableConfig) { SegmentAssignment segmentAssignment; - if (tableConfig.getTableType() == TableType.OFFLINE) { + if (tableConfig.getTableType() == TableType.OFFLINE && Boolean.parseBoolean(tableConfig.getIsDimTable())) { + segmentAssignment = new OfflineDimTableSegmentAssignment(); + } else if (tableConfig.getTableType() == TableType.OFFLINE) { Review comment: (nit) ```suggestion if (tableConfig.getTableType() == TableType.OFFLINE) { return tableConfig.isDimTable() ? new OfflineDimTableSegmentAssignment() : new OfflineSegmentAssignment(); } ``` ########## File path: pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableConfig.java ########## @@ -62,6 +63,9 @@ @JsonPropertyDescription(value = "The type of the table (OFFLINE|REALTIME) (mandatory)") private final TableType _tableType; + @JsonPropertyDescription("Indicates whether the table is a dimension table or not") + private final String _isDimTable; Review comment: Store boolean instead of String ########## File path: pinot-spi/src/main/java/org/apache/pinot/spi/config/table/TableConfig.java ########## @@ -142,6 +148,11 @@ public TableType getTableType() { return _tableType; } + @JsonProperty(IS_DIM_TABLE_KEY) + public String getIsDimTable() { Review comment: ```suggestion public boolean isDimTable() { ``` ---------------------------------------------------------------- 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