Skip to content

Commit

Permalink
fix: Warmups Code Revamp (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanbrub authored Nov 26, 2024
1 parent f8be437 commit 9a7136e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,30 +206,32 @@ long getMaxExpectedRowCount(long expectedRowCount, long scaleFactor) {
}

String getReadOperation(int scaleFactor, long rowCount, String... loadColumns) {
var headRows = (rowCount >= getGeneratedRowCount())?"":".head(${rows})";
if (scaleFactor > 1 && mainTable.equals("timed") && Arrays.asList(loadColumns).contains("timestamp")) {
var read = """
merge([
read('/data/timed.parquet').view(formulas=[${loadColumns}])
read('/data/timed.parquet').view(formulas=[${loadColumns}])${headRows}
] * ${scaleFactor}).update_view([
'timestamp=timestamp.plusMillis((long)(ii / ${rows}) * ${rows})'
]).head(${rows}).select()
]).select()
""";
read = read.replace("${headRows}",headRows);
return read.replace("${scaleFactor}", "" + scaleFactor).replace("${rows}", "" + rowCount);
}

var read = "read('/data/${mainTable}.parquet').head(${rows}).select(formulas=[${loadColumns}])";
var read = "read('/data/${mainTable}.parquet')${headRows}.select(formulas=[${loadColumns}])";
read = (loadColumns.length == 0) ? ("empty_table(${rows})") : read;

if (scaleFactor > 1) {
read = "merge([${readTable}] * ${scaleFactor})".replace("${readTable}", read);
read = read.replace("${scaleFactor}", "" + scaleFactor);
}
return read.replace("${rows}", "" + rowCount);
return read.replace("${headRows}",headRows).replace("${rows}", "" + rowCount);
}

String getStaticQuery(String name, String operation, long warmupRows, String... loadColumns) {
String getStaticQuery(String name, String operation, long rowCount, String... loadColumns) {
var staticQuery = """
source = right = timed = result = None
source = right = timed = result = stats = None
bench_api_metrics_init()
${loadSupportTables}
${mainTable} = ${readTable}
Expand All @@ -253,13 +255,13 @@ String getStaticQuery(String name, String operation, long warmupRows, String...
long_col("result_row_count", [result.size]),
])
""";
var read = getReadOperation(staticFactor, warmupRows, loadColumns);
var read = getReadOperation(staticFactor, rowCount, loadColumns);
return populateQuery(name, staticQuery, operation, read, loadColumns);
}

String getIncQuery(String name, String operation, long warmupRows, String... loadColumns) {
String getIncQuery(String name, String operation, long rowCount, String... loadColumns) {
var incQuery = """
source = right = timed = result = source_filter = right_filter = autotune = None
source = right = timed = result = source_filter = right_filter = autotune = stats = None
bench_api_metrics_init()
${loadSupportTables}
${mainTable} = ${readTable}
Expand Down Expand Up @@ -299,7 +301,7 @@ String getIncQuery(String name, String operation, long warmupRows, String... loa
long_col("result_row_count", [result.size])
])
""";
var read = getReadOperation(staticFactor, warmupRows, loadColumns);
var read = getReadOperation(incFactor, rowCount, loadColumns);
return populateQuery(name, incQuery, operation, read, loadColumns);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

start_time = 1676557157537
timed = empty_table(row_count).update([
'timestamp=start_time+ii','num1=(double)randomInt(0,5)','num2=(double)randomInt(1,11)',
'timestamp=epochMillisToInstant(start_time+ii)','num1=(double)randomInt(0,5)','num2=(double)randomInt(1,11)',
'key1=``+randomInt(1,101)','key2=``+randomInt(1,102)','key3=randomInt(0,9)','key4=randomInt(0,99)'
])

Expand Down

0 comments on commit 9a7136e

Please sign in to comment.