This repository was archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
TAJO-987: Hash shuffle should be balanced according to intermediate data volumes #101
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -18,15 +18,21 @@ | |
|
|
||
| package org.apache.tajo.master; | ||
|
|
||
| import com.google.common.collect.Maps; | ||
| import org.apache.tajo.ExecutionBlockId; | ||
| import org.apache.tajo.QueryId; | ||
| import org.apache.tajo.TestTajoIds; | ||
| import org.apache.tajo.ipc.TajoWorkerProtocol; | ||
| import org.apache.tajo.master.querymaster.QueryMaster; | ||
| import org.apache.tajo.master.querymaster.QueryUnit; | ||
| import org.apache.tajo.master.querymaster.Repartitioner; | ||
| import org.apache.tajo.master.querymaster.SubQuery; | ||
| import org.apache.tajo.util.Pair; | ||
| import org.apache.tajo.util.TUtil; | ||
| import org.apache.tajo.worker.FetchImpl; | ||
| import org.jboss.netty.handler.codec.http.QueryStringDecoder; | ||
| import org.junit.Test; | ||
| import org.mockito.Mockito; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are some unused imports. |
||
|
|
||
| import java.net.URI; | ||
| import java.util.ArrayList; | ||
|
|
@@ -35,6 +41,8 @@ | |
| import java.util.Map; | ||
|
|
||
| import static junit.framework.Assert.assertEquals; | ||
| import static org.apache.tajo.master.querymaster.Repartitioner.FetchGroupMeta; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| public class TestRepartitioner { | ||
| @Test | ||
|
|
@@ -83,4 +91,52 @@ private List<String> splitMaps(List<String> mapq) { | |
| } | ||
| return ret; | ||
| } | ||
|
|
||
| @Test | ||
| public void testScheduleFetchesByEvenDistributedVolumes() { | ||
| Map<Integer, FetchGroupMeta> fetchGroups = Maps.newHashMap(); | ||
| String tableName = "test1"; | ||
|
|
||
|
|
||
| fetchGroups.put(0, new FetchGroupMeta(100, new FetchImpl())); | ||
| fetchGroups.put(1, new FetchGroupMeta(80, new FetchImpl())); | ||
| fetchGroups.put(2, new FetchGroupMeta(70, new FetchImpl())); | ||
| fetchGroups.put(3, new FetchGroupMeta(30, new FetchImpl())); | ||
| fetchGroups.put(4, new FetchGroupMeta(10, new FetchImpl())); | ||
| fetchGroups.put(5, new FetchGroupMeta(5, new FetchImpl())); | ||
|
|
||
| Pair<Long [], Map<String, List<FetchImpl>>[]> results; | ||
|
|
||
| results = Repartitioner.makeEvenDistributedFetchImpl(fetchGroups, tableName, 1); | ||
| long expected [] = {100 + 80 + 70 + 30 + 10 + 5}; | ||
| assertFetchVolumes(expected, results.getFirst()); | ||
|
|
||
| results = Repartitioner.makeEvenDistributedFetchImpl(fetchGroups, tableName, 2); | ||
| long expected0 [] = {130, 165}; | ||
| assertFetchVolumes(expected0, results.getFirst()); | ||
|
|
||
| results = Repartitioner.makeEvenDistributedFetchImpl(fetchGroups, tableName, 3); | ||
| long expected1 [] = {100, 95, 100}; | ||
| assertFetchVolumes(expected1, results.getFirst()); | ||
|
|
||
| results = Repartitioner.makeEvenDistributedFetchImpl(fetchGroups, tableName, 4); | ||
| long expected2 [] = {100, 80, 70, 45}; | ||
| assertFetchVolumes(expected2, results.getFirst()); | ||
|
|
||
| results = Repartitioner.makeEvenDistributedFetchImpl(fetchGroups, tableName, 5); | ||
| long expected3 [] = {100, 80, 70, 30, 15}; | ||
| assertFetchVolumes(expected3, results.getFirst()); | ||
|
|
||
| results = Repartitioner.makeEvenDistributedFetchImpl(fetchGroups, tableName, 6); | ||
| long expected4 [] = {100, 80, 70, 30, 10, 5}; | ||
| assertFetchVolumes(expected4, results.getFirst()); | ||
| } | ||
|
|
||
| private static void assertFetchVolumes(long [] expected, Long [] results) { | ||
| assertEquals("the lengths of volumes are mismatch", expected.length, results.length); | ||
|
|
||
| for (int i = 0; i < expected.length; i++) { | ||
| assertTrue(expected[i] + " is expected, but " + results[i], expected[i] == results[i]); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unused imports.
Please remove it.