forked from apache/hive
-
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.
HIVE-23323: Add qsplits profile (Zoltan Haindrich reviewed by Miklos …
…Gergely) Signed-off-by: Zoltan Haindrich <zhaindrich@cloudera.com>
- Loading branch information
Showing
14 changed files
with
281 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
usage() { | ||
echo "$0 <from> <to>" | ||
exit 1 | ||
} | ||
|
||
[ "$1" == "" ] && usage | ||
[ "$2" == "" ] && usage | ||
|
||
|
||
inDir="$1" | ||
outDir="$2" | ||
|
||
git grep SplitSupport.process | grep "$1" | cut -d ':' -f1 | while read f;do | ||
|
||
echo "processing: $f" | ||
n="`grep N_SPLITS "$f" | cut -d= -f2 | tr -c -d '0-9'`" | ||
echo " * nSplits: $n" | ||
|
||
for((i=0;i<n;i++)) { | ||
oDir="`dirname $f | sed "s|$inDir|$outDir|"`/split$i" | ||
mkdir -p $oDir | ||
cat $f | sed -r "s|^(package.*);$|\1.split$i;|g" > $oDir/`basename $f` | ||
} | ||
done |
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
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
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
itests/util/src/main/java/org/apache/hadoop/hive/cli/control/SplitSupport.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 @@ | ||
package org.apache.hadoop.hive.cli.control; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
|
||
public class SplitSupport { | ||
|
||
public static List<Object[]> process(List<Object[]> parameters, Class<?> currentClass, int nSplits) { | ||
if (!isSplitExecution(currentClass)) { | ||
return parameters; | ||
} | ||
// auto-disable primary test in case splits are present | ||
if (isSplit0ClassExistsFor(currentClass)) { | ||
return new ArrayList<>(); | ||
} | ||
int i = getSplitIndex(currentClass); | ||
return getSplitParams(parameters, i, nSplits); | ||
} | ||
|
||
private static boolean isSplitExecution(Class<?> currentClass) { | ||
return isSplitClass(currentClass) || isSplit0ClassExistsFor(currentClass); | ||
} | ||
|
||
@VisibleForTesting | ||
static List<Object[]> getSplitParams(List<Object[]> parameters, int i, int nSplits) { | ||
if(i<0 || i>=nSplits) { | ||
throw new IllegalArgumentException("unexpected"); | ||
} | ||
int n = parameters.size(); | ||
int st = i * n / nSplits; | ||
int ed = (i + 1) * n / nSplits; | ||
|
||
return parameters.subList(st, ed); | ||
} | ||
|
||
@VisibleForTesting | ||
static boolean isSplitClass(Class<?> currentClass) { | ||
Package p = currentClass.getPackage(); | ||
return p.getName().matches(".*split[0-9]+$"); | ||
} | ||
|
||
@VisibleForTesting | ||
static int getSplitIndex(Class<?> currentClass) { | ||
Package p = currentClass.getPackage(); | ||
Pattern pat = Pattern.compile("(.*split)([0-9]+)$"); | ||
Matcher matcher = pat.matcher(p.getName()); | ||
if (matcher.find()) { | ||
return Integer.parseInt(matcher.group(2)); | ||
} | ||
throw new IllegalArgumentException("cant get splitindex for: " + p); | ||
} | ||
|
||
@VisibleForTesting | ||
static boolean isSplit0ClassExistsFor(Class<?> clazz) { | ||
Package p = clazz.getPackage(); | ||
String split1 = p.getName() + ".split0." + clazz.getSimpleName(); | ||
try { | ||
Class<?> c = Class.forName(split1); | ||
return c != null; | ||
} catch (ClassNotFoundException e) { | ||
return false; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.