Repository: phoenix Updated Branches: refs/heads/master 288eda9ab -> d8333e838
PHOENIX-2311 Fix performance.py java.io.FileNotFoundException (Gabor Liptak) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d8333e83 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d8333e83 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d8333e83 Branch: refs/heads/master Commit: d8333e838c6f6ec9c24798b4694be83f0286747f Parents: 288eda9 Author: Mujtaba <[email protected]> Authored: Tue Oct 13 10:35:03 2015 -0700 Committer: Mujtaba <[email protected]> Committed: Tue Oct 13 10:35:03 2015 -0700 ---------------------------------------------------------------------- bin/performance.py | 10 ++++++---- .../phoenix/util/GeneratePerformanceData.java | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/d8333e83/bin/performance.py ---------------------------------------------------------------------- diff --git a/bin/performance.py b/bin/performance.py index b9df433..2f7fad1 100755 --- a/bin/performance.py +++ b/bin/performance.py @@ -22,6 +22,7 @@ import os import subprocess import sys +import tempfile import phoenix_utils def queryex(description, statement): @@ -54,9 +55,9 @@ rowcount = sys.argv[2] table = "PERFORMANCE_" + sys.argv[2] # helper variable and functions -ddl = "ddl.sql" -data = "data.csv" -qry = "query.sql" +ddl = tempfile.mkstemp(prefix='ddl_', suffix='.sql')[1] +data = tempfile.mkstemp(prefix='data_', suffix='.csv')[1] +qry = tempfile.mkstemp(prefix='query_', suffix='.sql')[1] statements = "" phoenix_utils.setPath() @@ -97,7 +98,8 @@ queryex("4 - Truncate + Group By", "SELECT TRUNC(DATE,'DAY') DAY FROM %s GROUP B queryex("5 - Filter + Count", "SELECT COUNT(1) FROM %s WHERE CORE<10;" % (table)) print "\nGenerating and upserting data..." -exitcode = subprocess.call('java -jar %s %s' % (phoenix_utils.testjar, rowcount), shell=True) +exitcode = subprocess.call('java -jar %s %s %s' % (phoenix_utils.testjar, data, rowcount), + shell=True) if exitcode != 0: sys.exit(exitcode) http://git-wip-us.apache.org/repos/asf/phoenix/blob/d8333e83/phoenix-core/src/test/java/org/apache/phoenix/util/GeneratePerformanceData.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/GeneratePerformanceData.java b/phoenix-core/src/test/java/org/apache/phoenix/util/GeneratePerformanceData.java index 8f5c93f..53a1d01 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/util/GeneratePerformanceData.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/util/GeneratePerformanceData.java @@ -26,22 +26,22 @@ import java.util.GregorianCalendar; import java.util.Random; public class GeneratePerformanceData { - private static final String FILENAME = "data.csv"; - public static void main(String[] args) throws FileNotFoundException, IOException { String[] host = {"NA","CS","EU"}; String[] domain = {"Salesforce.com","Apple.com","Google.com"}; String[] feature = {"Login","Report","Dashboard"}; Calendar now = GregorianCalendar.getInstance(); - FileOutputStream fostream = new FileOutputStream(FILENAME); + Random random = new Random(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (args.length != 2) { + System.out.println("Data file name and row count must be specified as arguments"); + return; + } + String dataFile = args[0]; + int rowCount = Integer.parseInt(args[1]); + FileOutputStream fostream = null; try { - Random random = new Random(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - if (args.length < 1) { - System.out.println("Row count must be specified as argument"); - return; - } - int rowCount = Integer.parseInt(args[0]); + fostream = new FileOutputStream(dataFile); for (int i=0; i<rowCount; i++) { now.add(Calendar.SECOND, 1); fostream.write((host[random.nextInt(host.length)] + "," +
