Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void setDataSizeMax(Long dataSizeMax) {
*/
@Schema(hidden = true)
public Double getSizeUtilization() {
return size != null && sizeMax != null && sizeMax > 0 ? (double) size / (double) sizeMax : null;
return size != null && sizeMax != null && sizeMax > 0 ? (double) size / sizeMax : null;
}

/**
Expand All @@ -86,6 +86,6 @@ public Double getSizeUtilization() {
*/
@Schema(hidden = true)
public Double getDataSizeUtilization() {
return dataSize != null && dataSizeMax != null && dataSizeMax > 0 ? (double) dataSize / (double) dataSizeMax : null;
return dataSize != null && dataSizeMax != null && dataSizeMax > 0 ? (double) dataSize / dataSizeMax : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void setDataSizeMax(Long dataSizeMax) {
*/
@Schema(hidden = true)
public Double getSizeUtilization() {
return size != null && sizeMax != null && sizeMax > 0 ? (double) size / (double) sizeMax : null;
return size != null && sizeMax != null && sizeMax > 0 ? (double) size / sizeMax : null;
}

/**
Expand All @@ -86,6 +86,6 @@ public Double getSizeUtilization() {
*/
@Schema(hidden = true)
public Double getDataSizeUtilization() {
return dataSize != null && dataSizeMax != null && dataSizeMax > 0 ? (double) dataSize / (double) dataSizeMax : null;
return dataSize != null && dataSizeMax != null && dataSizeMax > 0 ? (double) dataSize / dataSizeMax : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public RelOptCost computeSelfCost(final RelOptPlanner planner, final RelMetadata
// For example, if table has 3 fields, project has 1 field,
// then factor = (1 + 2) / (3 + 2) = 0.6
return super.computeSelfCost(planner, mq)
.multiplyBy(((double) fields.length + 2D)
/ ((double) table.getRowType().getFieldCount() + 2D));
.multiplyBy((fields.length + 2D)
/ (table.getRowType().getFieldCount() + 2D));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public String getError() {
public int getPercentComplete() {
readLock.lock();
try {
return (numSteps < 1) ? 100 : (int) (((float) numCompletedSteps / (float) numSteps) * 100.0F);
return (numSteps < 1) ? 100 : (int) (((float) numCompletedSteps / numSteps) * 100.0F);
} finally {
readLock.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public String getError() {
public int getPercentComplete() {
readLock.lock();
try {
return (numSteps < 1) ? 100 : (int) (((float) numCompletedSteps / (float) numSteps) * 100.0F);
return (numSteps < 1) ? 100 : (int) (((float) numCompletedSteps / numSteps) * 100.0F);
} finally {
readLock.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ protected AbstractDateArithmeticEvaluator(final Evaluator<Date> subject,

if (amountEvaluator instanceof StringLiteralEvaluator) {
DateAmountParser.validate(
((StringLiteralEvaluator) amountEvaluator).evaluate(null).getValue());
amountEvaluator.evaluate(null).getValue());
}

if (timeZoneEvaluator instanceof StringLiteralEvaluator) {
final String tz = ((StringLiteralEvaluator) timeZoneEvaluator).evaluate(null).getValue();
final String tz = timeZoneEvaluator.evaluate(null).getValue();
try {
ZoneId.of(tz);
} catch (final DateTimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ protected AbstractInstantArithmeticEvaluator(final Evaluator<Instant> subject,
this.subject = subject;
this.amountEvaluator = amountEvaluator;
if (amountEvaluator instanceof StringLiteralEvaluator) {
DateAmountParser.validate(
((StringLiteralEvaluator) amountEvaluator).evaluate(null).getValue());
DateAmountParser.validate(amountEvaluator.evaluate(null).getValue());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public QueryResult<Long> evaluate(final EvaluationContext evaluationContext) {
return new WholeNumberQueryResult(count);
}

if (result.getResultType() == ResultType.BOOLEAN && ((Boolean) result.getValue()).equals(Boolean.FALSE)) {
if (result.getResultType() == ResultType.BOOLEAN && result.getValue().equals(Boolean.FALSE)) {
return new WholeNumberQueryResult(count);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ protected long copy(final InputStream in, final OutputStream out, final long num
return totalBytesRead;
}

@SuppressWarnings("PMD.UnnecessaryCast")
protected long readLong(final InputStream in) throws IOException {
fillBuffer(in, readBuffer, 8);
return (((long) readBuffer[0] << 56)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ protected long copy(final InputStream in, final OutputStream out, final long num
return totalBytesRead;
}

@SuppressWarnings("PMD.UnnecessaryCast")
protected long readLong(final InputStream in) throws IOException {
fillBuffer(in, readBuffer, 8);
return (((long) readBuffer[0] << 56)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public ContainsRegex(RecordPathSegment recordPath, final RecordPathSegment regex
this.regexPath = regexPath;

if (regexPath instanceof LiteralValuePath) {
final FieldValue fieldValue = ((LiteralValuePath) regexPath).evaluate((RecordPathEvaluationContext) null).findFirst().get();
final FieldValue fieldValue = regexPath.evaluate((RecordPathEvaluationContext) null).findFirst().get();
final Object value = fieldValue.getValue();
final String regex = DataTypeUtils.toString(value, (String) null);
final String regex = DataTypeUtils.toString(value, null);
compiledPattern = Pattern.compile(regex);
} else {
compiledPattern = null;
Expand All @@ -60,13 +60,13 @@ protected boolean test(final FieldValue fieldValue, final RecordPathEvaluationCo
return false;
}

final String regex = DataTypeUtils.toString(value, (String) null);
final String regex = DataTypeUtils.toString(value, null);
pattern = Pattern.compile(regex);
} else {
pattern = compiledPattern;
}

final String searchString = DataTypeUtils.toString(fieldValue.getValue(), (String) null);
final String searchString = DataTypeUtils.toString(fieldValue.getValue(), null);
if (searchString == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public IsBlank(RecordPathSegment recordPath) {

@Override
protected boolean test(final FieldValue fieldValue, final RecordPathEvaluationContext context) {
final String fieldVal = DataTypeUtils.toString(fieldValue.getValue(), (String) null);
final String fieldVal = DataTypeUtils.toString(fieldValue.getValue(), null);
if (fieldVal == null) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public IsEmpty(RecordPathSegment recordPath) {

@Override
protected boolean test(final FieldValue fieldValue, final RecordPathEvaluationContext context) {
final String fieldVal = DataTypeUtils.toString(fieldValue.getValue(), (String) null);
final String fieldVal = DataTypeUtils.toString(fieldValue.getValue(), null);
if (fieldVal == null) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public MatchesRegex(RecordPathSegment recordPath, final RecordPathSegment regexP
this.regexPath = regexPath;

if (regexPath instanceof LiteralValuePath) {
final FieldValue fieldValue = ((LiteralValuePath) regexPath).evaluate((RecordPathEvaluationContext) null).findFirst().get();
final FieldValue fieldValue = regexPath.evaluate((RecordPathEvaluationContext) null).findFirst().get();
final Object value = fieldValue.getValue();
final String regex = DataTypeUtils.toString(value, (String) null);
final String regex = DataTypeUtils.toString(value, null);
compiledPattern = Pattern.compile(regex);
} else {
compiledPattern = null;
Expand All @@ -60,13 +60,13 @@ protected boolean test(final FieldValue fieldValue, final RecordPathEvaluationCo
return false;
}

final String regex = DataTypeUtils.toString(value, (String) null);
final String regex = DataTypeUtils.toString(value, null);
pattern = Pattern.compile(regex);
} else {
pattern = compiledPattern;
}

final String searchString = DataTypeUtils.toString(fieldValue.getValue(), (String) null);
final String searchString = DataTypeUtils.toString(fieldValue.getValue(), null);
if (searchString == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public StringComparisonFilter(RecordPathSegment recordPath, final RecordPathSegm

@Override
protected boolean test(final FieldValue fieldValue, final RecordPathEvaluationContext context) {
final String fieldVal = DataTypeUtils.toString(fieldValue.getValue(), (String) null);
final String fieldVal = DataTypeUtils.toString(fieldValue.getValue(), null);
if (fieldVal == null) {
return false;
}
Expand All @@ -45,7 +45,7 @@ protected boolean test(final FieldValue fieldValue, final RecordPathEvaluationCo
return false;
}

final String searchValue = DataTypeUtils.toString(firstValue.get().getValue(), (String) null);
final String searchValue = DataTypeUtils.toString(firstValue.get().getValue(), null);
if (searchValue == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) {
}

final StringBuilder sb = new StringBuilder();
concatenated.forEach(fv -> sb.append(DataTypeUtils.toString(fv.getValue(), (String) null)));
concatenated.forEach(fv -> sb.append(DataTypeUtils.toString(fv.getValue(), null)));

final RecordField field = new RecordField("concat", RecordFieldType.STRING.getDataType());
final FieldValue responseValue = new StandardFieldValue(sb.toString(), field, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) {
}

final MessageDigest digest = getDigest(algorithmValue);
final String value = DataTypeUtils.toString(fv.getValue(), (String) null);
final String value = DataTypeUtils.toString(fv.getValue(), null);
String encoded = new DigestUtils(digest).digestAsHex(value);
return new StandardFieldValue(encoded, fv.getField(), fv.getParent().orElse(null));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public NoArgStringFunction(final String path, final RecordPathSegment valuePath,
@Override
public Stream<FieldValue> evaluate(RecordPathEvaluationContext context) {
return valuePath.evaluate(context).map(fv -> {
final String original = fv.getValue() == null ? "" : DataTypeUtils.toString(fv.getValue(), (String) null);
final String original = fv.getValue() == null ? "" : DataTypeUtils.toString(fv.getValue(), null);
final String processed = apply(original);
return new StandardFieldValue(processed, fv.getField(), fv.getParent().orElse(null));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Stream<FieldValue> evaluate(RecordPathEvaluationContext context) {
}

int desiredLength = desiredLengthOpt.getAsInt();
final String value = DataTypeUtils.toString(fv.getValue(), (String) null);
final String value = DataTypeUtils.toString(fv.getValue(), null);
return new StandardFieldValue(doPad(value, desiredLength, pad), fv.getField(), fv.getParent().orElse(null));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) {
return fv;
}

final String value = DataTypeUtils.toString(fv.getValue(), (String) null);
final String value = DataTypeUtils.toString(fv.getValue(), null);
final String replaced = value.replace(searchValue, replacementValue);
return new StandardFieldValue(replaced, fv.getField(), fv.getParent().orElse(null));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public ReplaceRegex(final RecordPathSegment recordPath, final RecordPathSegment
this.recordPath = recordPath;
this.searchValuePath = searchValue;
if (searchValue instanceof LiteralValuePath) {
final FieldValue fieldValue = ((LiteralValuePath) searchValue).evaluate((RecordPathEvaluationContext) null).findFirst().get();
final FieldValue fieldValue = searchValue.evaluate((RecordPathEvaluationContext) null).findFirst().get();
final Object value = fieldValue.getValue();
final String regex = DataTypeUtils.toString(value, (String) null);
final String regex = DataTypeUtils.toString(value, null);
compiledPattern = Pattern.compile(regex);
} else {
compiledPattern = null;
Expand All @@ -59,7 +59,7 @@ public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) {
final Stream<FieldValue> fieldValues = recordPath.evaluate(context);
return fieldValues.filter(fv -> fv.getValue() != null)
.map(fv -> {
final String value = DataTypeUtils.toString(fv.getValue(), (String) null);
final String value = DataTypeUtils.toString(fv.getValue(), null);

// Determine the Replacement Value
final String replacementValue = RecordPathUtils.getFirstStringValue(replacementValuePath, context);
Expand All @@ -79,7 +79,7 @@ public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) {
return fv;
}

final String regex = DataTypeUtils.toString(fieldValue, (String) null);
final String regex = DataTypeUtils.toString(fieldValue, null);
pattern = Pattern.compile(regex);
} else {
pattern = compiledPattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) {
final int start = startIndex.getAsInt();
final int end = endIndex.getAsInt();

final String value = DataTypeUtils.toString(fv.getValue(), (String) null);
final String value = DataTypeUtils.toString(fv.getValue(), null);

// Allow for negative indices to be used to reference offset from string length. We add 1 here because we want -1 to refer
// to the actual length of the string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) {
return fv;
}

final String value = DataTypeUtils.toString(fv.getValue(), (String) null);
final String value = DataTypeUtils.toString(fv.getValue(), null);
final int index = value.indexOf(searchValue);
if (index < 0) {
return fv;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) {
return fv;
}

final String value = DataTypeUtils.toString(fv.getValue(), (String) null);
final String value = DataTypeUtils.toString(fv.getValue(), null);
final int index = value.lastIndexOf(searchValue);
if (index < 0) {
return fv;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) {
return fv;
}

final String value = DataTypeUtils.toString(fv.getValue(), (String) null);
final String value = DataTypeUtils.toString(fv.getValue(), null);
final int index = value.indexOf(searchValue);
if (index < 0) {
return fv;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) {
return fv;
}

final String value = DataTypeUtils.toString(fv.getValue(), (String) null);
final String value = DataTypeUtils.toString(fv.getValue(), null);
final int index = value.lastIndexOf(searchValue);
if (index < 0) {
return fv;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Stream<FieldValue> evaluate(RecordPathEvaluationContext context) {
} else if (!(fv.getValue() instanceof byte[])) {
stringValue = fv.getValue().toString();
} else {
stringValue = DataTypeUtils.toString(fv.getValue(), (String) null, charset);
stringValue = DataTypeUtils.toString(fv.getValue(), null, charset);
}
final RecordField originalField = fv.getField();
final RecordField stringField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static String getFirstStringValue(final RecordPathSegment segment, final
return null;
}

final String stringValue = DataTypeUtils.toString(stringFieldValue.get().getValue(), (String) null);
final String stringValue = DataTypeUtils.toString(stringFieldValue.get().getValue(), null);
if (stringValue == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ public void supportsReferenceToFieldOfTypeLong() {
List.of(
1234567890L,
0L,
((long) Integer.MAX_VALUE) + 1L,
((long) Integer.MIN_VALUE) - 1L,
Integer.MAX_VALUE + 1L,
Integer.MIN_VALUE - 1L,
Long.MIN_VALUE,
Long.MAX_VALUE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,11 @@ public void testStringToBytes() {
assertInstanceOf(Byte[].class, bytes);
assertNotNull(bytes);
Byte[] b = (Byte[]) bytes;
assertEquals((long) 72, (long) b[0], "Conversion from String to byte[] failed"); // H
assertEquals((long) 101, (long) b[1], "Conversion from String to byte[] failed"); // e
assertEquals((long) 108, (long) b[2], "Conversion from String to byte[] failed"); // l
assertEquals((long) 108, (long) b[3], "Conversion from String to byte[] failed"); // l
assertEquals((long) 111, (long) b[4], "Conversion from String to byte[] failed"); // o
assertEquals(72, (long) b[0], "Conversion from String to byte[] failed"); // H
assertEquals(101, (long) b[1], "Conversion from String to byte[] failed"); // e
assertEquals(108, (long) b[2], "Conversion from String to byte[] failed"); // l
assertEquals(108, (long) b[3], "Conversion from String to byte[] failed"); // l
assertEquals(111, (long) b[4], "Conversion from String to byte[] failed"); // o
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class TestObjectLocalDateTimeFieldConverter {
private static final long MILLIS_TIMESTAMP_LONG = 1707238288351L;
private static final long MICROS_TIMESTAMP_LONG = 1707238288351567L;
private static final String MICROS_TIMESTAMP_STRING = Long.toString(MICROS_TIMESTAMP_LONG);
private static final double MICROS_TIMESTAMP_DOUBLE = ((double) MICROS_TIMESTAMP_LONG) / 1000000D;
private static final double MICROS_TIMESTAMP_DOUBLE = MICROS_TIMESTAMP_LONG / 1000000D;
private static final long NANOS_AFTER_SECOND = 351567000L;
private static final Instant INSTANT_MILLIS_PRECISION = Instant.ofEpochMilli(MILLIS_TIMESTAMP_LONG);
// Create an instant to represent the same time as the microsecond precision timestamp. We add nanoseconds after second but then have to subtract the milliseconds after the second that are already
Expand Down
Loading
Loading