-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resource Management of Dataset Cache Layer (#417)
* Add task status QUEUED & add cache task and query task to pool * Add max cache table size ratio to limit cache task * Add query task timeout * Add query memory limit * Fix style check * Add test * Modify duckdb.max-query-timeout to duckdb.max-cache-query-timeout * Implement cache retry in case the cache task surpasses the memory limit * Remove query memory limit * Modify Cache Query Task exception * Remove unused import * Add more information in error message
- Loading branch information
Showing
12 changed files
with
540 additions
and
50 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
51 changes: 51 additions & 0 deletions
51
accio-base/src/main/java/io/accio/base/client/duckdb/DuckdbUtil.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,51 @@ | ||
package io.accio.base.client.duckdb; | ||
|
||
import io.accio.base.AccioException; | ||
import io.airlift.units.DataSize; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static io.accio.base.metadata.StandardErrorCode.GENERIC_INTERNAL_ERROR; | ||
import static java.util.Locale.ENGLISH; | ||
|
||
public final class DuckdbUtil | ||
{ | ||
private static final Map<String, DataSize.Unit> UNIT_MAP = new HashMap<>(); | ||
|
||
// https://github.com/duckdb/duckdb/blob/4c7cb20474baa3a8ca1d5d8ceb22beae0e4c0e4c/src/common/string_util.cpp#L178 | ||
static { | ||
UNIT_MAP.put("BYTE", DataSize.Unit.BYTE); | ||
UNIT_MAP.put("BYTES", DataSize.Unit.BYTE); | ||
UNIT_MAP.put("KB", DataSize.Unit.KILOBYTE); | ||
UNIT_MAP.put("KIB", DataSize.Unit.KILOBYTE); | ||
UNIT_MAP.put("MB", DataSize.Unit.MEGABYTE); | ||
UNIT_MAP.put("MIB", DataSize.Unit.MEGABYTE); | ||
UNIT_MAP.put("GB", DataSize.Unit.GIGABYTE); | ||
UNIT_MAP.put("GIB", DataSize.Unit.GIGABYTE); | ||
UNIT_MAP.put("TB", DataSize.Unit.TERABYTE); | ||
UNIT_MAP.put("TIB", DataSize.Unit.TERABYTE); | ||
UNIT_MAP.put("PB", DataSize.Unit.PETABYTE); | ||
UNIT_MAP.put("PIB", DataSize.Unit.PETABYTE); | ||
} | ||
|
||
private DuckdbUtil() {} | ||
|
||
public static DataSize convertDuckDBUnits(String valueWithUnit) | ||
{ | ||
try { | ||
String valueWithUnitUpperCase = valueWithUnit.toUpperCase(ENGLISH); | ||
for (Map.Entry<String, DataSize.Unit> entry : UNIT_MAP.entrySet()) { | ||
String unit = entry.getKey(); | ||
if (valueWithUnitUpperCase.endsWith(unit)) { | ||
double value = Double.parseDouble(valueWithUnitUpperCase.substring(0, valueWithUnitUpperCase.length() - unit.length()).trim()); | ||
return DataSize.of((long) value, entry.getValue()); | ||
} | ||
} | ||
} | ||
catch (Exception e) { | ||
throw new AccioException(GENERIC_INTERNAL_ERROR, String.format("Failed to parse duckdb value %s", valueWithUnit), e); | ||
} | ||
throw new AccioException(GENERIC_INTERNAL_ERROR, String.format("Failed to parse duckdb value %s", valueWithUnit)); | ||
} | ||
} |
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
Oops, something went wrong.