Skip to content
Merged
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 @@ -42,7 +42,7 @@ protected JExpr readIsNullImpl(boolean eq) {
else if (javaBaseType == double.class)
checkNull = CTXT.staticCall (Double.class, "isNaN", value);
else if (javaBaseType == long.class)
checkNull = CTXT.staticCall (Decimal64Utils.class, "isNaN", value);
checkNull = CTXT.staticCall (Decimal64Utils.class, "isNull", value);
else if (javaBaseType == Decimal64.class)
//checkNull = CTXT.binExpr(CTXT.binExpr(value, " == ", getNullLiteral()), " || ", value.call("isNaN"));
checkNull = CTXT.binExpr(value, " == ", getNullLiteral());
Expand Down Expand Up @@ -74,12 +74,11 @@ public JExpr getNullLiteral () {
else if (javaBaseType == double.class)
return (CTXT.staticVarRef (Double.class, "NaN"));
else if (javaBaseType == long.class)
return (CTXT.staticVarRef (Decimal64Utils.class, "NaN"));
return (CTXT.staticVarRef (Decimal64Utils.class, "NULL"));
else if (javaBaseType == Decimal64.class)
return CTXT.nullLiteral();

throw new RuntimeException ("unknown bound type = " + javaBaseType);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ final protected void copy (DecodingContext ctxt, Object obj)
@Override
protected void setNull(Object obj) throws IllegalAccessException, InvocationTargetException {
if (fieldType == long.class) { // special case for decimals
setter.setLong(obj, IntegerDataType.INT64_NULL);
setter.setLong(obj, Decimal64Utils.NULL);
} else if (fieldType == Decimal64.class) { // special case for decimals
setter.set(obj, Decimal64.NULL);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.epam.deltix.util.memory.MemoryDataOutput;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

Expand Down Expand Up @@ -107,11 +106,16 @@ public void setSize(long value) {
public boolean equals(Object obj) {
boolean superEquals = super.equals(obj);

if (!superEquals) return false;
if (!(obj instanceof LongPriceTestMessage)) return false;
LongPriceTestMessage other =(LongPriceTestMessage)obj;
if (getPrice() != other.getPrice()) return false;
if (getSize() != other.getSize()) return false;
if (!superEquals)
return false;
if (!(obj instanceof LongPriceTestMessage))
return false;

LongPriceTestMessage other = (LongPriceTestMessage)obj;
if (getPrice() != other.getPrice())
return false;
if (getSize() != other.getSize())
return false;

return true;
}
Expand Down Expand Up @@ -214,7 +218,6 @@ public String toString() {
public static class DoublePriceTestMessage extends InstrumentMessage {

protected double price = TypeConstants.IEEE64_NULL;

protected double size = TypeConstants.IEEE64_NULL;

@SchemaElement(title = "Price")
Expand Down Expand Up @@ -242,7 +245,6 @@ public double getSize() {
public void setSize(double value) {
this.size = value;
}

public boolean hasSize() {
return size != TypeConstants.IEEE64_NULL;
}
Expand All @@ -257,9 +259,18 @@ public boolean equals(Object obj) {
if (!superEquals) return false;
if (!(obj instanceof DoublePriceTestMessage)) return false;

DoublePriceTestMessage other =(DoublePriceTestMessage)obj;
if (getPrice() != other.getPrice()) return false;
if (getSize() != other.getSize()) return false;
DoublePriceTestMessage other = (DoublePriceTestMessage)obj;
if (hasPrice() && other.hasPrice()) {
if (getPrice() != other.getPrice()) return false;
} else {
if (hasPrice() || other.hasPrice()) return false;
}

if (hasSize() && other.hasSize()) {
if (getSize() != other.getSize()) return false;
} else {
if (hasSize() || other.hasSize()) return false;
}

return true;
}
Expand Down Expand Up @@ -438,12 +449,12 @@ public void test1Int() throws Exception {
void testCodecs1() throws Exception {
double price = 0.12345;
double size = 123.456789;

test2(new LongFlatPriceTestMessage(Decimal64Utils.fromDouble(price), Decimal64Utils.fromDouble(size)), price, size);

test2(new LongFlatPriceTestMessage(Decimal64Utils.NaN, Decimal64Utils.NaN), Double.NaN, Double.NaN);
}

@Ignore("Fails because of incorrect processing Decimal64Utils.NULL") //TODO:
@Test
public void testCodecsNulls() throws Exception {

Expand Down Expand Up @@ -520,8 +531,15 @@ private void test2(LongFlatPriceTestMessage msg, double price, double size) thro
DoublePriceTestMessage d = (DoublePriceTestMessage) factory.createFixedBoundDecoder(
cd -> DoublePriceTestMessage.class, LONG_RCD).decode(in);

Assert.assertEquals(price, d.getPrice(), 1E-16);
Assert.assertEquals(size, d.getSize(), 1E-16);
if (Double.isNaN(price))
Assert.assertTrue(Double.isNaN(d.getPrice()));
else
Assert.assertEquals(price, d.getPrice(), 1E-16);

if (Double.isNaN(size))
Assert.assertTrue(Double.isNaN(d.getSize()));
else
Assert.assertEquals(size, d.getSize(), 1E-16);
}

private void test2(double price, double size) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ private static void loadAllData() throws Exception {
importStream(db, "KRAKEN", "KRAKEN.30s.qsmsg.gz");
}

private static void importStream(DXTickDB db, String streamKey, String file) throws IOException {
public static void importStream(DXTickDB db, String streamKey, String file) throws IOException {
DXTickStream stream = db.getStream(streamKey);
if (stream != null) {
stream.delete();
Expand Down