forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
287 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
fe/fe-core/src/main/java/org/apache/doris/nereids/worker/WorkerScanRanges.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// 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.doris.nereids.worker; | ||
|
||
import org.apache.doris.nereids.worker.job.ScanRanges; | ||
|
||
import java.util.Objects; | ||
|
||
/** WorkerScanRange */ | ||
public class WorkerScanRanges { | ||
public final Worker worker; | ||
public final ScanRanges scanRanges; | ||
|
||
public WorkerScanRanges(Worker worker, ScanRanges scanRanges) { | ||
this.worker = Objects.requireNonNull(worker, "scanRangeParams can not be null"); | ||
this.scanRanges = Objects.requireNonNull(scanRanges, "scanRanges can not be null"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
fe/fe-core/src/main/java/org/apache/doris/nereids/worker/job/Splittable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// 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.doris.nereids.worker.job; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** Splittable */ | ||
public interface Splittable<S extends Splittable<S>> { | ||
|
||
int itemSize(); | ||
|
||
void addItem(S other, int index); | ||
|
||
default List<S> split(int splitSize) { | ||
return Splittable.split(this, splitSize); | ||
} | ||
|
||
S newSplittable(); | ||
|
||
/** | ||
* split a list to multi expected number sublist | ||
* for example: | ||
* | ||
* list is : [1, 2, 3, 4, 5, 6, 7] | ||
* expectedSize is : 3 | ||
* | ||
* return : | ||
* [1, 4, 7] | ||
* [2, 5] | ||
* [3, 6] | ||
*/ | ||
static <S extends Splittable<S>> List<S> split(Splittable<S> splittable, int splitSize) { | ||
Preconditions.checkNotNull(splittable, "splittable must not be null"); | ||
Preconditions.checkArgument(splitSize > 0, "splitSize must larger than 0"); | ||
|
||
int itemSize = splittable.itemSize(); | ||
splitSize = Math.min(splitSize, itemSize); | ||
|
||
List<S> result = new ArrayList<>(splitSize); | ||
for (int i = 0; i < splitSize; i++) { | ||
result.add(splittable.newSplittable()); | ||
} | ||
|
||
int index = 0; | ||
for (int i = 0; i < itemSize; i++) { | ||
result.get(index).addItem((S) splittable, i); | ||
index = (index + 1) % splitSize; | ||
} | ||
return result; | ||
} | ||
} |
Oops, something went wrong.