Code review comment: How about also abstracting the condition to a variable, since it is too long? ```suggestion                 boolean isAssignedByRowCount = Config.enable_schedule_insert_query_by_row_count && isLoad                         && scanRangeLocations.getScan_range().isSetInternal_scan_range()                         && scanRangeLocations.getScan_range().getInternal_scan_range().isSetRow_count()                         && scanRangeLocations.getScan_range().getInternal_scan_range().getRow_count() > 0;                 if (isAssignedByRowCount) { ```

Code before review:
public void computeScanRangeAssignment() throws Exception {
HashMap<TNetworkAddress, Long> assignedRowCountPerHost = Maps.newHashMap();
if (Config.enable_schedule_insert_query_by_row_count && isLoad
&& locations.size() < 10240 && locations.size() > 0
&& locations.get(0).getScan_range().isSetInternal_scan_range()) {
locations.sort(new Comparator<TScanRangeLocations>() {
@Override
public int compare(TScanRangeLocations l, TScanRangeLocations r) {
return Long.compare(r.getScan_range().getInternal_scan_range().getRow_count(),
l.getScan_range().getInternal_scan_range().getRow_count());
}
});
}
for (TScanRangeLocations scanRangeLocations : locations) {
Long minAssignedBytes = Long.MAX_VALUE;
TScanRangeLocation minLocation = null;
for (final TScanRangeLocation location : scanRangeLocations.getLocations()) {
Long assignedBytes = BackendSelector.findOrInsert(assignedRowCountPerHost, location.server, 0L);
if (assignedBytes < minAssignedBytes) {
minAssignedBytes = assignedBytes;
minLocation = location;
}
}
if (minLocation == null) {
throw new UserException("Scan range not found" + backendInfosString(false));
}
if (Config.enable_schedule_insert_query_by_row_count && isLoad
&& scanRangeLocations.getScan_range().isSetInternal_scan_range()
&& scanRangeLocations.getScan_range().getInternal_scan_range().isSetRow_count()
&& scanRangeLocations.getScan_range().getInternal_scan_range().getRow_count() > 0) {
assignedRowCountPerHost.put(minLocation.server, assignedRowCountPerHost.get(minLocation.server)
+ scanRangeLocations.getScan_range().getInternal_scan_range().getRow_count());
} else {
assignedRowCountPerHost.put(minLocation.server, assignedRowCountPerHost.get(minLocation.server) + 1);
}
Reference<Long> backendIdRef = new Reference<>();
TNetworkAddress execHostPort = SimpleScheduler.getHost(minLocation.backend_id,
scanRangeLocations.getLocations(),
idToBackend, backendIdRef);
if (execHostPort == null) {
throw new UserException(FeConstants.BACKEND_NODE_NOT_FOUND_ERROR
+ backendInfosString(false));
}
recordUsedBackend(execHostPort, backendIdRef.getRef());
Map<Integer, List<TScanRangeParams>> scanRanges = BackendSelector.findOrInsert(
assignment, execHostPort, new HashMap<>());
List<TScanRangeParams> scanRangeParamsList = BackendSelector.findOrInsert(
scanRanges, scanNode.getId().asInt(), new ArrayList<>());
TScanRangeParams scanRangeParams = new TScanRangeParams();
scanRangeParams.scan_range = scanRangeLocations.scan_range;
scanRangeParamsList.add(scanRangeParams);
LOG.info("scan range {} is assigned to backend {}",
scanRangeLocations.scan_range, execHostPort);
}
if (LOG.isDebugEnabled()) {
LOG.debug("assignedRowCountPerHost: {}", assignedRowCountPerHost);
}
}

Line under review: && scanRangeLocations.getScan_range().getInternal_scan_range().getRow_count() > 0) {

Code after addressing the review:
public void computeScanRangeAssignment() throws Exception {
HashMap<TNetworkAddress, Long> assignedRowCountPerHost = Maps.newHashMap();
if (locations.size() < 10240 && locations.size() > 0 && isEnableScheduleByRowCnt(locations.get(0))) {
locations.sort(new Comparator<TScanRangeLocations>() {
@Override
public int compare(TScanRangeLocations l, TScanRangeLocations r) {
return Long.compare(r.getScan_range().getInternal_scan_range().getRow_count(),
l.getScan_range().getInternal_scan_range().getRow_count());
}
});
}
for (TScanRangeLocations scanRangeLocations : locations) {
Long minAssignedBytes = Long.MAX_VALUE;
TScanRangeLocation minLocation = null;
for (final TScanRangeLocation location : scanRangeLocations.getLocations()) {
Long assignedBytes = BackendSelector.findOrInsert(assignedRowCountPerHost, location.server, 0L);
if (assignedBytes < minAssignedBytes) {
minAssignedBytes = assignedBytes;
minLocation = location;
}
}
if (minLocation == null) {
throw new UserException("Scan range not found" + backendInfosString(false));
}
if (isEnableScheduleByRowCnt(scanRangeLocations)) {
assignedRowCountPerHost.put(minLocation.server, assignedRowCountPerHost.get(minLocation.server)
+ scanRangeLocations.getScan_range().getInternal_scan_range().getRow_count());
} else {
assignedRowCountPerHost.put(minLocation.server, assignedRowCountPerHost.get(minLocation.server) + 1);
}
Reference<Long> backendIdRef = new Reference<>();
TNetworkAddress execHostPort = SimpleScheduler.getHost(minLocation.backend_id,
scanRangeLocations.getLocations(),
idToBackend, idToComputeNode, backendIdRef);
if (execHostPort == null) {
throw new UserException(FeConstants.BACKEND_NODE_NOT_FOUND_ERROR
+ backendInfosString(false));
}
recordUsedBackend(execHostPort, backendIdRef.getRef());
Map<Integer, List<TScanRangeParams>> scanRanges = BackendSelector.findOrInsert(
assignment, execHostPort, new HashMap<>());
List<TScanRangeParams> scanRangeParamsList = BackendSelector.findOrInsert(
scanRanges, scanNode.getId().asInt(), new ArrayList<>());
TScanRangeParams scanRangeParams = new TScanRangeParams();
scanRangeParams.scan_range = scanRangeLocations.scan_range;
scanRangeParamsList.add(scanRangeParams);
}
if (LOG.isDebugEnabled()) {
LOG.debug("assignedRowCountPerHost: {}", assignedRowCountPerHost);
}
}