use of javax.annotation.Nullable in project pinot by linkedin.
the class TableViews method getIdealState.
@Nullable
public Map<String, Map<String, String>> getIdealState(@Nonnull String tableNameOptType, @Parameter(name = "tableType", in = "query", description = "Table type", required = false) @Nullable TableType tableType) {
String tableName = getTableName(tableNameOptType, tableType);
IdealState resourceIdealState = _pinotHelixResourceManager.getHelixAdmin().getResourceIdealState(_pinotHelixResourceManager.getHelixClusterName(), tableName);
return resourceIdealState == null ? null : resourceIdealState.getRecord().getMapFields();
}
use of javax.annotation.Nullable in project pinot by linkedin.
the class SegmentDirectoryPaths method findFormatFile.
@Nullable
private static File findFormatFile(@Nonnull File indexDir, String fileName) {
Preconditions.checkNotNull(indexDir);
Preconditions.checkArgument(indexDir.exists(), "Path %s does not exist", indexDir);
if (!indexDir.isDirectory()) {
return indexDir;
}
File v1File = new File(indexDir, fileName);
if (v1File.exists()) {
return v1File;
}
File v3Dir = segmentDirectoryFor(indexDir, SegmentVersion.v3);
File v3File = new File(v3Dir, fileName);
if (v3File.exists()) {
return v3File;
}
return null;
}
use of javax.annotation.Nullable in project killbill by killbill.
the class PhasePriceOverrideJson method toPlanPhasePriceOverrides.
public static List<PlanPhasePriceOverride> toPlanPhasePriceOverrides(final List<PhasePriceOverrideJson> priceOverrides, final PlanSpecifier spec, final Currency currency) {
if (priceOverrides == null || priceOverrides.isEmpty()) {
return ImmutableList.<PlanPhasePriceOverride>of();
}
return ImmutableList.copyOf(Iterables.transform(priceOverrides, new Function<PhasePriceOverrideJson, PlanPhasePriceOverride>() {
@Nullable
@Override
public PlanPhasePriceOverride apply(@Nullable final PhasePriceOverrideJson input) {
if (input.getPhaseName() != null) {
return new DefaultPlanPhasePriceOverride(input.getPhaseName(), currency, input.getFixedPrice(), input.getRecurringPrice());
} else {
final PhaseType phaseType = input.getPhaseType() != null ? PhaseType.valueOf(input.getPhaseType()) : null;
final PlanPhaseSpecifier planPhaseSpecifier = spec.getPlanName() != null ? new PlanPhaseSpecifier(spec.getPlanName(), phaseType) : new PlanPhaseSpecifier(spec.getProductName(), spec.getBillingPeriod(), spec.getPriceListName(), phaseType);
final Currency resolvedCurrency = input.getFixedPrice() != null || input.getRecurringPrice() != null ? currency : null;
return new DefaultPlanPhasePriceOverride(planPhaseSpecifier, resolvedCurrency, input.getFixedPrice(), input.getRecurringPrice());
}
}
}));
}
use of javax.annotation.Nullable in project storm by apache.
the class TestExprSemantic method testArithmeticFunctions.
@Test
public void testArithmeticFunctions() throws Exception {
Values v = testExpr(Lists.newArrayList("POWER(3, 2)", "ABS(-10)", "MOD(10, 3)", "MOD(-10, 3)", "CEIL(123.45)", "FLOOR(123.45)"));
assertEquals(new Values(9.0d, 10, 1, -1, new BigDecimal(124), new BigDecimal(123)), v);
// Belows are floating numbers so comparing this with literal is tend to be failing...
// Picking int value and compare
Values v2 = testExpr(Lists.newArrayList("SQRT(255)", "LN(16)", "LOG10(10000)", "EXP(10)"));
List<Object> v2m = Lists.transform(v2, new Function<Object, Object>() {
@Nullable
@Override
public Object apply(@Nullable Object o) {
// only takes int value
return ((Number) o).intValue();
}
});
// 15.9687, 2.7725, 4.0, 22026.465794
assertEquals(new Values(15, 2, 4, 22026), v2m);
}
use of javax.annotation.Nullable in project storm by apache.
the class TestExprSemantic method testCaseStatement.
@Test
public void testCaseStatement() throws Exception {
Values v = testExpr(Lists.newArrayList("CASE WHEN 'abcd' IN ('a', 'abc', 'abcde') THEN UPPER('a') " + "WHEN UPPER('abcd') = 'AB' THEN 'b' ELSE {fn CONCAT('abcd', '#')} END", "CASE WHEN 'ab' IN ('a', 'abc', 'abcde') THEN UPPER('a') " + "WHEN UPPER('ab') = 'AB' THEN 'b' ELSE {fn CONCAT('ab', '#')} END", "CASE WHEN 'abc' IN ('a', 'abc', 'abcde') THEN UPPER('a') " + "WHEN UPPER('abc') = 'AB' THEN 'b' ELSE {fn CONCAT('abc', '#')} END"));
// TODO: The data type of literal Calcite assigns seems to be out of expectation. Please see below logical plan.
// LogicalProject(EXPR$0=[CASE(OR(=('abcd', 'a'), =('abcd', 'abc'), =('abcd', 'abcde')), CAST(UPPER('a')):VARCHAR(5) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL, =(UPPER('abcd'), CAST('AB'):CHAR(4) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL), 'b', CAST(||('abcd', '#')):VARCHAR(5) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL)], EXPR$1=[CASE(OR(=('ab', 'a'), =('ab', 'abc'), =('ab', 'abcde')), CAST(UPPER('a')):CHAR(3) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL, =(UPPER('ab'), 'AB'), CAST('b'):CHAR(3) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL, ||('ab', '#'))], EXPR$2=[CASE(OR(=('abc', 'a'), =('abc', 'abc'), =('abc', 'abcde')), CAST(UPPER('a')):CHAR(4) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL, =(UPPER('abc'), CAST('AB'):CHAR(3) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL), CAST('b'):CHAR(4) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL, ||('abc', '#'))]): rowcount = 1.0, cumulative cost = {2.0 rows, 5.0 cpu, 0.0 io}, id = 5
// LogicalFilter(condition=[AND(>($0, 0), <($0, 2))]): rowcount = 1.0, cumulative cost = {1.0 rows, 2.0 cpu, 0.0 io}, id = 4
// EnumerableTableScan(table=[[FOO]]): rowcount = 1.0, cumulative cost = {0.0 rows, 1.0 cpu, 0.0 io}, id = 3
// in result, both 'b' and UPPER('a') hence 'A' are having some spaces which is not expected.
// When we use CASE with actual column (Java String type hence VARCHAR), it seems to work as expected.
// Please refer trident/TestPlanCompiler#testCaseStatement(), and see below logical plan.
// LogicalProject(EXPR$0=[CASE(OR(=($1, 'a'), =($1, 'abc'), =($1, 'abcde')), CAST(UPPER('a')):VARCHAR(1) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary", =(CAST(UPPER($1)):VARCHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary", 'AB'), 'b', CAST(||($1, '#')):VARCHAR(1) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary")]): rowcount = 1.0, cumulative cost = {1.0 rows, 2.0 cpu, 0.0 io}, id = 3
List<Object> v2 = Lists.transform(v, new Function<Object, Object>() {
@Nullable
@Override
public String apply(@Nullable Object o) {
return ((String) o).trim();
}
});
assertArrayEquals(new Values("abcd#", "b", "A").toArray(), v2.toArray());
}
Aggregations