8000 Validator merge by ghislainfourny · Pull Request #1101 · RumbleDB/rumble · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Validator merge #1101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for Git 8000 Hub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 241 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
241 commits
Select commit Hold shift + click to select a range
b1f9a3d
test with error
pierremotard Jun 7, 2021
e6942f2
AtMostOneItem LowerCaseFunction
pierremotard Jun 7, 2021
a17a207
pierremotard Jun 7, 2021
95e89d3
pierremotard Jun 7, 2021
d03b29b
AtMostOne: Trigo (acos, asin, atan) and sumFunction
pierremotard Jun 8, 2021
3ea5cff
Trigo Arc (cos, sin, tan)
pierremotard Jun 8, 2021
be89ba4
Merge remote-tracking branch 'origin/atMostOne-pierre-motard' into at…
pierremotard Jun 8, 2021
7b8f54e
back to localCall SumFunction
pierremotard Jun 9, 2021
2764b69
spotless
pierremotard Jun 9, 2021
1cd496e
AtMost MinFunction
pierremotard Jun 9, 2021
e3df903
AtMostOne FloorFunction
pierremotard Jun 9, 2021
36f6fe1
AtMostOne Ceiling
pierremotard Jun 9, 2021
5beb18d
Ceiling, Floor, Pow, Number, RoundHalf, Max, fix Min
pierremotard Jun 9, 2021
0b4f4fa
fix Pow nullException
pierremotard Jun 9, 2021
c1dbace
Exp10, Log10, Pi, Tan, YFromDateTime
pierremotard Jun 9, 2021
7b53eb6
Spotless
pierremotard Jun 9, 2021
8ccfc95
Spotless
pierremotard Jun 9, 2021
edc7533
Merge remote-tracking branch 'origin/atMostOne-pierre-motard' into at…
pierremotard Jun 10, 2021
fc5665e
AtMostOne - Avg, Count, Sum
pierremotard Jun 11, 2021
7b9ff71
AtMostOne: ZeroOrOne (Cardinality) and Replace
pierremotard Jun 11, 2021
7614f86
AtMostOne String functions
pierremotard Jun 11, 2021
4024df3
Normalize Space and Unicode, Codepoints2String.
pierremotard Jun 11, 2021
254b637
AtMostOne - Time functions
pierremotard Jun 13, 2021
8a37b40
Spotless. AtMostOne. Time Functions, Parse, Null, Codepoint, Length
pierremotard Jun 14, 2021
af25858
AtMostOne. Boolean, Concat
pierremotard Jun 14, 2021
242cbc5
AtMostOne. Extra functions not in excel
pierremotard Jun 15, 2021
01005f1
Intersection from Hybrid to AtMostOne
pierremotard Jun 18, 2021
0001498
Revert "Intersection from Hybrid to AtMostOne"
pierremotard Jun 18, 2021
af86868
Auto stash before revert of "Intersection from Hybrid to AtMostOne"
pierremotard Jun 18, 2021
ec5f04b
spotless
pierremotard Jun 18, 2021
c2321df
intersect catalogue back to initial
pierremotard Jun 18, 2021
94065ca
Merge branch 'atMostOne-pierre-motard' into 'master-pierre-motard'
Jun 19, 2021
a87f780
deepEqual. add if collation
pierremotard Jun 19, 2021
8a6399b
RoundHalfToEven to numeric?
pierremotard Jun 20, 2021
1b47cbe
RoundHalfToEven to numeric?
pierremotard Jun 20, 2021
8a984a8
Merge remote-tracking branch 'origin/correct-types-pierre-motard' int…
pierremotard Jun 20, 2021
fe51050
spotless.
pierremotard Jun 20, 2021
fbf8e11
roundHalfToEven. support Int & Integer
pierremotard Jun 20, 2021
8cf9dee
roundHalfToEven. support Int & Integer
pierremotard Jun 20, 2021
0fc91ab
Merge remote-tracking branch 'origin/correct-types-pierre-motard' int…
pierremotard Jun 20, 2021
97267db
comment collation part
pierremotard Jun 21, 2021
3f0ecc8
SupportCollation. DeepEqual, Contains, StartsWith
pierremotard Jun 21, 2021
a1595b7
Merge remote-tracking branch 'origin/correct-types-pierre-motard' int…
pierremotard Jun 21, 2021
a3afd87
Revert "Merge remote-tracking branch 'origin/correct-types-pierre-mot…
pierremotard Jun 21, 2021
3f381b4
Collation support. EndsWith, Substring before/after
pierremotard Jun 21, 2021
1cea585
Support collation. Distinct values, index of
pierremotard Jun 21, 2021
67c94ba
AtMostOne from Hybrid. ObjectIntersect
pierremotard Jun 21, 2021
1689eb3
Collation min#2 max#2
pierremotard Jun 22, 2021
902a904
fix intersect
pierremotard Jun 22, 2021
2e63c10
fix intersect
pierremotard Jun 22, 2021
5e2579a
Merge remote-tracking branch 'origin/atMostOne-pierre-motard' into at…
pierremotard Jun 22, 2021
79242c3
Merge branch 'atMostOne-pierre-motard' into 'master-pierre-motard'
Jun 22, 2021
2c9a2b6
Merge branch 'support-collation-pierre-motard' into 'master-pierre-mo…
Jun 22, 2021
33dd844
Revert "Remove DurationFunction"
Jun 23, 2021
0babd75
Merge branch 'remove-type-constructors-pierre-motard' into 'master-pi…
Jun 23, 2021
265918c
Ceiling supports numeric
Jun 23, 2021
1b78472
Merge branch 'correct-types-pierre-motard' into 'master-pierre-motard'
Jun 23, 2021
94063db
Add support for 0 parameter, in context
Jun 24, 2021
dbf536b
Merge branch 'zero-param-pierre-motard' into 'master-pierre-motard'
Jun 24, 2021
2e24d6c
Correct prefix from math: to fn:
Jun 25, 2021
79f633f
Merge branch 'correct-prefix-pierre-motard' into 'master-pierre-motard'
Jun 25, 2021
a7c1b34
Master into master pierre motard
Jun 28, 2021
1615450
Merge branch 'master' into 'master-pierre-motard'
Jun 28, 2021
9e6a856
merge annotatedItem branch
Jun 30, 2021
9c8eae6
Merge branch 'annotatedItem-pierre-motard' into 'master-pierre-motard'
Jun 30, 2021
c9b81ed
mantissa for large floats, satisfy spec
pierremotard Jul 2, 2021
5683e8e
fix test suite for DateTimeStamp type.
pierremotard Jul 2, 2021
36d0516
fn:resolve-uri, adapt multiplicative tests float
pierremotard Jul 3, 2021
ce74204
fn:resolve-uri, adapt multiplicative tests float
pierremotard Jul 3, 2021
674f48b
Merge remote-tracking branch 'origin/master-pierre-motard' into maste…
pierremotard Jul 3, 2021
d9a864b
fn:unorder (unordered -> parser failed)
pierremotard Jul 4, 2021
a299a70
Fix cast string to boolean
pierremotard Jul 4, 2021
217f490
small fix serialize.
pierremotard Jul 4, 2021
9adf7db
fn:default-collation
pierremotard Jul 4, 2021
0dd1715
spotless. ArrayMembers RDD with closure
pierremotard Jul 4, 2021
8fa3bbb
add test members RDD.
pierremotard Jul 4, 2021
6698d3a
spotless. fix cast string to boolean.
pierremotard Jul 4, 2021
2278252
Merge branch 'master-pierre-motard' into 'members-pierre-motard'
Jul 4, 2021
10bac12
Accumulate AtMostOne with RDD. RDD tests.
pierremotard Jul 5, 2021
85e2b8c
Members pierre into master-pierre
Jul 6, 2021
6707632
Merge branch 'members-pierre-motard' into 'master-pierre-motard'
Jul 6, 2021
7c8489a
Accumulate pierre motard into master pierre
Jul 6, 2021
983ea8f
Merge branch 'accumulate-pierre-motard' into 'master-pierre-motard'
Jul 6, 2021
fd716d5
Fix conflicts.
ghislainfourny Jul 6, 2021
103db13
fix resolve-uri#0 and add static-base-uri.
pierremotard Jul 6, 2021
519a998
Merge branch 'master' into MergePM
ghislainfourny Jul 7, 2021
653176f
Override.
ghislainfourny Jul 7, 2021
0390e4b
Merge branch 'MergePM' of github.com:RumbleDB/rumble into MergePM
ghislainfourny Jul 7, 2021
105db82
Override.
ghislainfourny Jul 7, 2021
d63c339
Merge.
ghislainfourny Jul 7, 2021
bbb369a
Fix compilation.
ghislainfourny Jul 7, 2021
557fbfe
Fix compilation.
ghislainfourny Jul 7, 2021
3526e9f
Remove remark.
ghislainfourny Jul 7, 2021
78543c1
annotatedTypes finished. facets solved.
Jul 7, 2021
e70db77
Merge branch 'facets-pierre-motard' into 'master-pierre-motard'
Jul 7, 2021
484495a
Merge branch 'master' into MergePM
ghislainfourny Jul 8, 2021
6d43f72
Merge back.
ghislainfourny Jul 9, 2021
6050c7b
Merge branch 'accumulate-pierre-motard' into 'master-pierre-motard'
Jul 9, 2021
9d7a3b9
Gregorian dateTypes
Jul 9, 2021
cbf2ab1
Merge branch 'gDateTypes-pierre-motard' into 'master-pierre-motard'
Jul 9, 2021
1d61f18
fix to accept xs:int.
pierremotard Jul 10, 2021
6e519f5
Min, Max, OneOrMore, ZeroOrOne consume DF.
pierremotard Jul 10, 2021
ba7884b
Add tests for min, max, one-or-more, zero-or-one DF.
pierremotard Jul 10, 2021
0625de0
string-join AtMostOne and consumes RDD.
pierremotard Jul 10, 2021
6bb6528
Init fn:collection.
pierremotard Jul 10, 2021
ac03d6c
merge master in master-pierre-motard, solve conflicts.
pierremotard Jul 10, 2021
776bdee
fix duplicate method.
pierremotard Jul 10, 2021
61c693d
Merge branch 'master' into MergePM
ghislainfourny Jul 12, 2021
ce322ff
Merge branch 'master' into MergePM
ghislainfourny Jul 12, 2021
36a04e2
Merge branch 'master' into MergePM
ghislainfourny Jul 13, 2021
bbdbd7e
Take over.
ghislainfourny Jul 13, 2021
c180f76
Remove import.
ghislainfourny Jul 13, 2021
4212aee
Remove diff.
ghislainfourny Jul 13, 2021
5956bc4
Fix diff.
ghislainfourny Jul 13, 2021
2bd714e
Update ObjectItemType.java
ghislainfourny Jul 13, 2021
f4d9239
Fix tests.
ghislainfourny Jul 13, 2021
b301cd0
Merge branch 'master' into MergePM
ghislainfourny Jul 13, 2021
418b75e
Remove test.
ghislainfourny Jul 13, 2021
a275f7b
Merge branch 'MergePM' of github.com:RumbleDB/rumble into MergePM
ghislainfourny Jul 13, 2021
367a155
Remove unused file.
ghislainfourny Jul 13, 2021
6fe790e
Merge branch 'master-pierre-motard' into 'MergePM'
Jul 13, 2021
39ec830
unordered keyw
pierremotard Jul 13, 2021
df3efba
fn:unordered allowed + clean grammar file.
pierremotard Jul 13, 2021
dc6ebb2
Revert "fn:unordered allowed + clean grammar file."
pierremotard Jul 13, 2021
f6dca01
allow unordered keyword.
pierremotard Jul 13, 2021
ed17929
fix imports.
pierremotard Jul 13, 2021
58ad896
fix RuntimeTests.
pierremotard Jul 13, 2021
1eabf7b
Merge branch 'support-df-pierre-motard' into 'master-pierre-motard'
Jul 13, 2021
811faf9
dateTimeStamp Facet + adapt two tests.
pierremotard Jul 13, 2021
9344f33
Merge branch 'master-pierre-motard' into 'MergePM'
Jul 13, 2021
79a5c88
Update ZeroOrOneIterator.java
Jul 13, 2021
25890d0
fix tests.
pierremotard Jul 13, 2021
be27fbc
Merge branch 'MergePM' into 'master-pierre-motard'
Jul 13, 2021
b147581
string-join rdd not better than local.
pierremotard Jul 14, 2021
00ff45c
serialize -0 and fix rounding issues.
pierremotard Jul 16, 2021
30ad1e2
Fix comparison with NaN
pierremotard Jul 18, 2021
33ee01c
spotless.
pierremotard Jul 18, 2021
e3ae8e4
fix cast decimal to int.
pierremotard Jul 18, 2021
eaaaf6c
fix wrong expected output round.
pierremotard Jul 18, 2021
f30467f
spotless.
pierremotard Jul 18, 2021
074adf6
fix float precision MLPipeline tests.
pierremotard Jul 18, 2021
d9377ff
Revert "fix float precision MLPipeline tests."
pierremotard Jul 18, 2021
aa7cb81
revert MLPipeline changes. Improve float mantissa handling.
pierremotard Jul 18, 2021
757b81f
Annotated support in DFs. Type test.
pierremotard Jul 19, 2021
42a778a
Throw error if compare invalid types, even if contain NaN.
pierremotard Jul 19, 2021
b001506
fix deep-equal annotated items. spotless.
pierremotard Jul 19, 2021
0cd6662
True False functions.
pierremotard Jul 19, 2021
6cd0b64
Forbid 0000 gyear.
pierremotard Jul 19, 2021
563b91b
NaN deep-equal.
pierremotard Jul 19, 2021
9b05580
Deep-equal Annotated
pierremotard Jul 20, 2021
7e58da1
DeepEq NaN, compare with NaN or INF.
pierremotard Jul 20, 2021
7d36b60
deactivate MLPipeline tests
pierremotard Jul 20, 2021
2c0c89e
modify check facets int to fix annotate.
pierremotard Jul 22, 2021
34a59ce
spotless.
pierremotard Jul 22, 2021
abdd02e
spotless.
pierremotard Jul 22, 2021
d1c95de
DeepEq NaN, compare with NaN or INF.
pierremotard Jul 20, 2021
d132edd
Merge branch 'negativeZeros-pm' into 'merge-zeros-pm'
Jul 23, 2021
5cd8b94
update compare float.
pierremotard Jul 23, 2021
dae4a5b
min to volcano style.
pierremotard Jul 23, 2021
394743d
fix types hierarchy. min still has issues if called in context.
pierremotard Jul 24, 2021
b640048
update min, works for numeric types.
pierremotard Jul 26, 2021
7691e67
pass test suite min function, except 2.
pierremotard Jul 26, 2021
3a1a8ce
Merge branch 'merge-zeros-pm' into 'fix-master-pm'
Jul 27, 2021
f501179
Update max similarly. spotless.
pierremotard Jul 27, 2021
1b863c4
null handling.
pierremotard Jul 27, 2021
d4766d2
handle null for min.
pierremotard Jul 27, 2021
c69d04e
handle null for min.
pierremotard Jul 27, 2021
a0a5fa1
Merge remote-tracking branch 'origin/type-promotion-pm' into type-pro…
pierremotard Jul 27, 2021
f5a1bfc
Merge branch 'type-promotion-pm' into 'fix-master-pm'
Jul 27, 2021
6a2a9bd
Merge branch 'master-pierre-motard' into 'fix-master-pm'
Jul 27, 2021
8e1842b
Merge branch 'fix-master-pm' into 'master-pierre-motard'
Jul 27, 2021
73cec55
meeting update min
pierremotard Jul 28, 2021
17d14c7
add all comparable types min.
pierremotard Jul 28, 2021
26b79af
Cleaner min and max.
pierremotard Jul 29, 2021
4fb38fe
fix max with null. < 10000 /div> pierremotard Jul 30, 2021
6b597cd
add fn:dateTime.
pierremotard Jul 30, 2021
cc48f1d
fix fn:dateTime, add inconsistent timezone exception.
pierremotard Jul 30, 2021
2023c79
added error code FODT0002
pierremotard Aug 1, 2021
f180a58
add xs:untypedAtomic and adapt min/max.
pierremotard Aug 1, 2021
4682fc5
Merge branch 'untypedAtomic-pm' into 'format-date-pm'
Aug 3, 2021
92df602
Revert "Merge branch 'untypedAtomic-pm' into 'format-date-pm'"
Aug 3, 2021
cadb31b
update Name of concat function to add fn prefix.
pierremotard Aug 4, 2021
81fce96
Handle duration op exceptions, add exception.
pierremotard Aug 5, 2021
3a6b6b6
getString for some duration/time items.
pierremotard Aug 5, 2021
06d399c
add current DateTime to dynamic context fields.
pierremotard Aug 6, 2021
2a12013
spotless.
pierremotard Aug 6, 2021
b32e909
Merge back.
ghislainfourny Aug 25, 2021
fcaede1
Fix.
ghislainfourny Aug 25, 2021
71f0f39
Merge.
ghislainfourny Aug 25, 2021
d58a1e6
Merge branch 'master' into MergePM
ghislainfourny Aug 26, 2021
1b2977e
Merge.
ghislainfourny Aug 31, 2021
f559f47
Remove import.
ghislainfourny Aug 31, 2021
50d60ca
Merge branch 'master' into MergePM
ghislainfourny Sep 8, 2021
49fd536
Remove change.
ghislainfourny Sep 8, 2021
e6dd4bc
Merge branch 'MergePM' of github.com:RumbleDB/rumble into MergePM
ghislainfourny Sep 8, 2021
d290d10
Remove changes.
ghislainfourny Sep 8, 2021
698fd70
Revert tests.
ghislainfourny Sep 8, 2021
1958bf6
Add back.
ghislainfourny Sep 8, 2021
5824d74
Merge branch 'master' into MergePM
ghislainfourny Sep 9, 2021
be18e34
Merge branch 'master' into MergePM
ghislainfourny Sep 9, 2021
cb9bdf3
Update ComparisonIterator.java
ghislainfourny Sep 9, 2021
efdccc8
Fix test.
ghislainfourny Sep 9, 2021
3613e63
Merge branch 'master' into MergePM
ghislainfourny Sep 9, 2021
48c5fd6
Merge branch 'merge-sept-7' into 'master-pierre-motard'
Sep 10, 2021
e83ba85
Merge branch 'current-time-pm' into 'merge-11sept'
Sep 11, 2021
89a03d5
remove unescapeJson stringRuntime
pierremotard Sep 11, 2021
9c860ba
Exception UnidentifiedErr+UnsupportedCollation
pierremotard Sep 11, 2021
8fe948f
put back unescapeJson StringRuntime
pierremotard Sep 11, 2021
73b114d
spotless.
pierremotard Sep 11, 2021
ef78275
test without unescapeJson
pierremotard Sep 12, 2021
3484e9d
spotless.
pierremotard Sep 12, 2021
d4bc05f
Revert "test without unescapeJson"
pierremotard Sep 12, 2021
32b4c76
update import.
pierremotard Sep 12, 2021
bb89e4e
start case atomic
pierremotard Sep 12, 2021
e170dcc
facets for remaining atomicTypes.
pierremotard Sep 13, 2021
9c6d5a2
comment out code causing errors.
pierremotard Sep 13, 2021
fb14ee6
change facet
pierremotard Sep 14, 2021
6ac5ea7
facets to <0 and >0
pierremotard Sep 23, 2021
b171eca
start atomic processing
pierremotard Sep 23, 2021
b4cab26
fix maxExclusive facet
pierremotard Sep 23, 2021
4d9bcf3
add dateTimeStamp facet castIterator
pierremotard Sep 23, 2021
4186536
add facets duration
pierremotard Sep 23, 2021
01534fa
atomic case for userdefined type
pierremotard Sep 23, 2021
a67517e
fix comment description
pierremotard Sep 23, 2021
e7d5293
fix process type derivedAtomic
pierremotard Sep 23, 2021
95c3c64
maxExclusive fix
pierremotard Sep 23, 2021
ae671bb
Merge branch 'facets-pm' into 'derivedAtomic-pm'
Sep 23, 2021
0dbc9da
Merge branch 'derivedAtomic-pm' into 'facets-pm'
Sep 23, 2021
8643eae
Update rumble server for jsound validator
pierremotard Oct 13, 2021
3433f90
improve design jsound validator
pierremotard Oct 13, 2021
30a28da
Merge branch 'master' of github.com:RumbleDB/rumble into facets-pm
Oct 14, 2021
b07b57b
test Jsound user defined
pierremotard Oct 19, 2021
c135606
Merge remote-tracking branch 'origin/facets-pm' into facets-pm
pierremotard Oct 19, 2021
da939d9
Check user defined type facets, add first tests
pierremotard Oct 19, 2021
3b9ec28
codemirror library, still update issue
pierremotard Oct 19, 2021
99792ff
Tests Jsound user defined types with facets
pierremotard Oct 19, 2021
79e25c8
fix type17.jq
pierremotard Oct 19, 2021
45ca181
simple working jsound validator, no highlight
pierremotard Oct 27, 2021
6fd5172
move highlighting files to another branch
pierremotard Oct 27, 2021
0845c3c
Merge branch 'facets-pm' into 'validator-jsound-pm'
Oct 27, 2021
f8c43f9
Merge.
Oct 28, 2021
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 @@ -1322,7 +1322,7 @@ private static BuiltinFunction createBuiltinFunction(
*/
static final BuiltinFunction concat =
new BuiltinFunction(
new FunctionIdentifier(Name.createVariableInDefaultFunctionNamespace("concat"), 100),
new FunctionIdentifier(new Name(Name.FN_NS, "fn", "concat"), 100),
new FunctionSignature(
Collections.nCopies(
100,
Expand Down Expand Up @@ -2641,7 +2641,7 @@ private static BuiltinFunction createBuiltinFunction(
builtinFunctions.put(substring_after2.getIdentifier(), substring_after2);
for (int i = 0; i < 100; i++) {
builtinFunctions.put(
new FunctionIdentifier(Name.createVariableInDefaultFunctionNamespace("concat"), i),
new FunctionIdentifier(concat.getIdentifier().getName(), i),
concat
);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/rumbledb/items/DayTimeDurationItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public Period getDurationValue() {
return this.value;
}

@Override
public String getStringValue() {
return this.value.toString();
}

@Override
public boolean isAtomic() {
return true;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/rumbledb/items/DoubleItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
public class DoubleItem implements Item {

private static final long serialVersionUID = 1L;
private double value;
private Double value;

public DoubleItem() {
super();
Expand Down Expand Up @@ -79,12 +79,12 @@ public String getStringValue() {
if (Double.isInfinite(this.value) && this.value < 0) {
return "-INF";
}
if (Double.compare(this.value, 0d) == 0) {
return "0";
}
if (Double.compare(this.value, -0d) == 0) {
return "-0";
}
if (Double.compare(this.value, 0d) == 0) {
return "0";
}
double abs = Math.abs(this.value);
if (abs >= 0.000001 && abs <= 1000000) {
return this.castToDecimalValue().stripTrailingZeros().toPlainString();
Expand All @@ -104,7 +104,7 @@ public double castToDoubleValue() {

@Override
public float castToFloatValue() {
return (float) this.value;
return this.value.floatValue();
}

public BigDecimal castToDecimalValue() {
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/org/rumbledb/items/FloatItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.rumbledb.types.ItemType;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;

public class FloatItem implements Item {

Expand Down Expand Up @@ -83,25 +82,24 @@ public String getStringValue() {
if (Float.isInfinite(this.value) && this.value < 0) {
return "-INF";
}
if (Float.compare(this.value, 0f) == 0) {
return "0";
}
if (Float.compare(this.value, -0f) == 0) {
return "-0";
}
if (Float.compare(this.value, 0f) == 0) {
return "0";
}
double abs = Math.abs(this.value);
// Mantissa from less or equal than 1.0E-7
// Convert to decimal between 10E-7 to 10E6
if (abs >= 0.000001 && abs < 1000000) {
return new BigDecimal(this.value).toString();
}
// Mantissa already from 1.0E6, then let Float.toString take care of mantissa from 1.0E7
if (abs >= 1000000 && abs < 10000000) {
return new DecimalFormat("0.0#######E0").format(this.value);
// return String.format("%.4E", this.castToDecimalValue().stripTrailingZeros().toPlainString());
// Force mantissa between 10E6 and 10E7
if (abs < 100000000) {
String str = Float.toString(this.value * 10);
char reducedChar = (char) ((int) str.charAt(str.length() - 1) - 1);
StringBuilder sb = new StringBuilder(str.substring(0, str.length() - 1)).append(reducedChar);
return sb.toString();
}
// If less than 0.000001 must use mantissa, so from 0.0000001 = 1.0E-7
// If more or = than 1.0E6
// When use float.toString or not
return Float.toString(this.value);
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/rumbledb/items/YearMonthDurationItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public Period getDurationValue() {
return this.value;
}

@Override
public String getStringValue() {
return this.value.toString();
}

@Override
public boolean isYearMonthDuration() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@
import org.joda.time.PeriodType;
import org.rumbledb.api.Item;
import org.rumbledb.context.DynamicContext;
import org.rumbledb.exceptions.DivisionByZeroException;
import org.rumbledb.exceptions.ExceptionMetadata;
import org.rumbledb.exceptions.MoreThanOneItemException;
import org.rumbledb.exceptions.NonAtomicKeyException;
import org.rumbledb.exceptions.OurBadException;
import org.rumbledb.exceptions.UnexpectedTypeException;
import org.rumbledb.exceptions.*;
import org.rumbledb.expressions.ExecutionMode;
import org.rumbledb.expressions.arithmetic.MultiplicativeExpression;
import org.rumbledb.expressions.arithmetic.MultiplicativeExpression.MultiplicativeOperator;
Expand Down Expand Up @@ -452,6 +447,9 @@ private static Item processYearMonthDurationDouble(
MultiplicativeExpression.MultiplicativeOperator multiplicativeOperator,
ExceptionMetadata metadata
) {
if (Double.isNaN(r)) {
throw new InvalidNaNOperationException("Invalid operation with NaN value.", metadata);
}
switch (multiplicativeOperator) {
case MUL: {
int months = l.getYears() * 12 + l.getMonths();
Expand All @@ -463,6 +461,9 @@ private static Item processYearMonthDurationDouble(
}
case DIV: {
int months = l.getYears() * 12 + l.getMonths();
if (r == 0 || r == -0) {
throw new ArithmeticOverflowOrUnderflow("Division of a duration by 0.", metadata);
}
int totalMonths = (int) Math.round(months / r);
return ItemFactory.getInstance()
.createYearMonthDurationItem(
Expand Down Expand Up @@ -512,6 +513,9 @@ private static Item processDayTimeDurationDouble(
MultiplicativeExpression.MultiplicativeOperator multiplicativeOperator,
ExceptionMetadata metadata
) {
if (Double.isNaN(r)) {
throw new InvalidNaNOperationException("Invalid operation with NaN value.", metadata);
}
switch (multiplicativeOperator) {
case MUL: {
long durationInMillis = l.toStandardDuration().getMillis();
Expand All @@ -521,6 +525,10 @@ private static Item processDayTimeDurationDouble(
}
case DIV: {
long durationInMillis = l.toStandardDuration().getMillis();
// Check r is 0 and throw exception
if (r == 0 || r == -0) {
throw new ArithmeticOverflowOrUnderflow("Division of a duration by 0.", metadata);
}
long durationResult = Math.round(durationInMillis / r);
return ItemFactory.getInstance()
.createDayTimeDurationItem(new Period(durationResult, PeriodType.dayTime()));
Expand Down
Loading
0