diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index d2dc8a5..e74eac7 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.00.0.0")] -[assembly: AssemblyFileVersion("3.00.0.0")] +[assembly: AssemblyVersion("3.00.1.0")] +[assembly: AssemblyFileVersion("3.00.1.0")] diff --git a/src/data/AbstractMatrix.cs b/src/data/AbstractMatrix.cs index 0cbdc0c..e58aa2b 100644 --- a/src/data/AbstractMatrix.cs +++ b/src/data/AbstractMatrix.cs @@ -150,7 +150,7 @@ public virtual void setColumnLabels(IVector vector) public virtual string getString() { int rows = Math.Min(Utils.DISPLAY_ROWS, this.rows()); - int limitColMaxWidth = 25; + int limitColMaxWidth = Utils.DISPLAY_WIDTH; int length = 0; int curCol = 0; int maxColWidth; diff --git a/src/data/BasicDecimal128.cs b/src/data/BasicDecimal128.cs index b042a10..294aa1b 100644 --- a/src/data/BasicDecimal128.cs +++ b/src/data/BasicDecimal128.cs @@ -37,9 +37,9 @@ public BasicDecimal128(decimal data, int scale){ this.scale_ = scale; } - public BasicDecimal128(ExtendedDataInput @input) + internal BasicDecimal128(ExtendedDataInput @input, int scale = -1) { - scale_ = @input.readInt(); + scale_ = scale == -1 ? @input.readInt() : scale; byte[] data = new byte[16]; @input.readFully(data); reserveBytes(data, !@input.isLittleEndian()); diff --git a/src/data/BasicDecimal128Matrix.cs b/src/data/BasicDecimal128Matrix.cs new file mode 100644 index 0000000..803047d --- /dev/null +++ b/src/data/BasicDecimal128Matrix.cs @@ -0,0 +1,117 @@ +using dolphindb.io; +using System; +using System.Collections.Generic; + +namespace dolphindb.data +{ + + public class BasicDecimal128Matrix : AbstractMatrix + { + private BasicDecimal128Vector value; + + public BasicDecimal128Matrix(int rows, int columns, int scale) : base(rows, columns) + { + this.value = new BasicDecimal128Vector(rows * columns, scale); + } + + public BasicDecimal128Matrix(int rows, int columns, IList list, int scale) : base(rows, columns) + { + List tmp = new List(); + foreach (decimal[] data in list) + { + tmp.AddRange(data); + } + if (tmp.Count != rows * columns) + { + throw new Exception("the total size of list must be equal to rows * columns"); + } + value = new BasicDecimal128Vector(tmp, scale); + } + + public BasicDecimal128Matrix(int rows, int columns, IList list, int scale) : base(rows, columns) + { + List tmp = new List(); + foreach (string[] data in list) + { + tmp.AddRange(data); + } + if (tmp.Count != rows * columns) + { + throw new Exception("the total size of list must be equal to rows * columns"); + } + value = new BasicDecimal128Vector(tmp, scale); + } + + public BasicDecimal128Matrix(ExtendedDataInput @in) : base(@in) + { + } + + public virtual void setDecimal(int row, int column, decimal value) + { + this.value.setDecimal(getIndex(row, column), value); + } + + public virtual decimal getDecimal(int row, int column) + { + return value.getDecimal(getIndex(row, column)); + } + + public void setString(int row, int column, string value) + { + this.value.set(getIndex(row, column), value); + } + + public override bool isNull(int row, int column) + { + return value.isNull(getIndex(row, column)); + } + + public override void setNull(int row, int column) + { + value.setNull(getIndex(row, column)); + } + + public override IScalar get(int row, int column) + { + return this.value.get(getIndex(row, column)); + } + + public void set(int row, int column, IScalar value) + { + this.value.set(getIndex(row, column), value); + } + + public override DATA_CATEGORY getDataCategory() + { + return DATA_CATEGORY.DENARY; + } + + public override DATA_TYPE getDataType() + { + return DATA_TYPE.DT_DECIMAL128; + } + + public override Type getElementClass() + { + return typeof(BasicDecimal128); + } + + protected internal override void readMatrixFromInputStream(int rows, int columns, ExtendedDataInput @in) + { + int scale = @in.readInt(); + this.value = new BasicDecimal128Vector(rows * columns, scale); + value.deserialize(0, rows * columns, @in); + } + + protected internal override void writeVectorToOutputStream(ExtendedDataOutput @out) + { + this.value.writeVectorToOutputStream(@out); + } + + public int getScale() + { + return value.getScale(); + } + } + +} \ No newline at end of file diff --git a/src/data/BasicDecimal128Vector.cs b/src/data/BasicDecimal128Vector.cs index 0380e3a..efb0825 100644 --- a/src/data/BasicDecimal128Vector.cs +++ b/src/data/BasicDecimal128Vector.cs @@ -279,9 +279,13 @@ public override void set(int index, IScalar value) { int originScale = value.getScale(); BigInteger convertData; - if (originScale > scale_) + if (originScale == scale_) { - convertData = ((BasicDecimal128)value).getRawData() / BasicDecimal128.pow10(originScale - scale_); + convertData = ((BasicDecimal128)value).getRawData(); + } + else if (originScale > scale_) + { + convertData = new BasicDecimal128(value.getString(), scale_).getRawData(); } else { @@ -336,5 +340,10 @@ public decimal getDecimal(int index) { return ((BasicDecimal128)get(index)).getDecimalValue(); } + + public void setDecimal(int index, decimal value) + { + set(index, new BasicDecimal128(value, scale_)); + } } } diff --git a/src/data/BasicDecimal32.cs b/src/data/BasicDecimal32.cs index faa9ccd..71ea046 100644 --- a/src/data/BasicDecimal32.cs +++ b/src/data/BasicDecimal32.cs @@ -41,9 +41,9 @@ public BasicDecimal32(decimal data, int scale) } } - public BasicDecimal32(ExtendedDataInput @input) + internal BasicDecimal32(ExtendedDataInput @input, int scale = -1) { - scale_ = @input.readInt(); + scale_ = scale == -1 ? @input.readInt() : scale; value_ = @input.readInt(); } diff --git a/src/data/BasicDecimal32Matrix.cs b/src/data/BasicDecimal32Matrix.cs new file mode 100644 index 0000000..9680ee5 --- /dev/null +++ b/src/data/BasicDecimal32Matrix.cs @@ -0,0 +1,118 @@ +using dolphindb.io; +using System; +using System.Collections.Generic; + +namespace dolphindb.data +{ + + + public class BasicDecimal32Matrix : AbstractMatrix + { + private BasicDecimal32Vector value; + + public BasicDecimal32Matrix(int rows, int columns, int scale) : base(rows, columns) + { + this.value = new BasicDecimal32Vector(rows * columns, scale); + } + + public BasicDecimal32Matrix(int rows, int columns, IList list, int scale) : base(rows, columns) + { + List tmp = new List(); + foreach (decimal[] data in list) + { + tmp.AddRange(data); + } + if (tmp.Count != rows * columns) + { + throw new Exception("the total size of list must be equal to rows * columns"); + } + value = new BasicDecimal32Vector(tmp, scale); + } + + public BasicDecimal32Matrix(int rows, int columns, IList list, int scale) : base(rows, columns) + { + List tmp = new List(); + foreach (string[] data in list) + { + tmp.AddRange(data); + } + if(tmp.Count != rows * columns) + { + throw new Exception("the total size of list must be equal to rows * columns"); + } + value = new BasicDecimal32Vector(tmp, scale); + } + + public BasicDecimal32Matrix(ExtendedDataInput @in) : base(@in) + { + } + + public virtual void setDecimal(int row, int column, decimal value) + { + this.value.setDecimal(getIndex(row, column), value); + } + + public virtual decimal getDecimal(int row, int column) + { + return value.getDecimal(getIndex(row, column)); + } + + public void setString(int row, int column, string value) + { + this.value.set(getIndex(row, column), value); + } + + public override bool isNull(int row, int column) + { + return value.isNull(getIndex(row, column)); + } + + public override void setNull(int row, int column) + { + value.setNull(getIndex(row, column)); + } + + public override IScalar get(int row, int column) + { + return this.value.get(getIndex(row, column)); + } + + public void set(int row, int column, IScalar value) + { + this.value.set(getIndex(row, column), value); + } + + public override DATA_CATEGORY getDataCategory() + { + return DATA_CATEGORY.DENARY; + } + + public override DATA_TYPE getDataType() + { + return DATA_TYPE.DT_DECIMAL32; + } + + public override Type getElementClass() + { + return typeof(BasicDecimal32); + } + + protected internal override void readMatrixFromInputStream(int rows, int columns, ExtendedDataInput @in) + { + int scale = @in.readInt(); + this.value = new BasicDecimal32Vector(rows * columns, scale); + value.deserialize(0, rows * columns, @in); + } + + protected internal override void writeVectorToOutputStream(ExtendedDataOutput @out) + { + this.value.writeVectorToOutputStream(@out); + } + + public int getScale() + { + return value.getScale(); + } + } + +} \ No newline at end of file diff --git a/src/data/BasicDecimal32Vector.cs b/src/data/BasicDecimal32Vector.cs index 82000f9..d75f3f4 100644 --- a/src/data/BasicDecimal32Vector.cs +++ b/src/data/BasicDecimal32Vector.cs @@ -256,9 +256,13 @@ public override void set(int index, IScalar value) else { int originScale = value.getScale(); - if (originScale > scale_) + if(originScale == scale_) { - values_[index] = ((BasicDecimal32)value).getRawData() / BasicDecimal32.pow10(originScale - scale_); + values_[index] = ((BasicDecimal32)value).getRawData(); + } + else if (originScale > scale_) + { + values_[index] = new BasicDecimal32(value.getString(), scale_).getRawData(); } else { @@ -309,5 +313,10 @@ public decimal getDecimal(int index) { return Utils.createBasicDecimal32(values_[index], scale_).getDecimalValue(); } + + public void setDecimal(int index, decimal value) + { + set(index, new BasicDecimal32(value, scale_)); + } } } diff --git a/src/data/BasicDecimal64.cs b/src/data/BasicDecimal64.cs index ae30583..aac1ba9 100644 --- a/src/data/BasicDecimal64.cs +++ b/src/data/BasicDecimal64.cs @@ -13,9 +13,9 @@ public class BasicDecimal64 : AbstractScalar private int scale_ = 0;//Decimal precision private long value_; //covert decimal to int for saving - public BasicDecimal64(ExtendedDataInput @input) + internal BasicDecimal64(ExtendedDataInput @input, int scale = -1) { - scale_ = @input.readInt(); + scale_ = scale == -1 ? @input.readInt() : scale; value_ = @input.readLong(); } diff --git a/src/data/BasicDecimal64Matrix.cs b/src/data/BasicDecimal64Matrix.cs new file mode 100644 index 0000000..ffaff7f --- /dev/null +++ b/src/data/BasicDecimal64Matrix.cs @@ -0,0 +1,118 @@ +using dolphindb.io; +using System; +using System.Collections.Generic; + +namespace dolphindb.data +{ + + + public class BasicDecimal64Matrix : AbstractMatrix + { + private BasicDecimal64Vector value; + + public BasicDecimal64Matrix(int rows, int columns, int scale) : base(rows, columns) + { + this.value = new BasicDecimal64Vector(rows * columns, scale); + } + + public BasicDecimal64Matrix(int rows, int columns, IList list, int scale) : base(rows, columns) + { + List tmp = new List(); + foreach (decimal[] data in list) + { + tmp.AddRange(data); + } + if (tmp.Count != rows * columns) + { + throw new Exception("the total size of list must be equal to rows * columns"); + } + value = new BasicDecimal64Vector(tmp, scale); + } + + public BasicDecimal64Matrix(int rows, int columns, IList list, int scale) : base(rows, columns) + { + List tmp = new List(); + foreach (string[] data in list) + { + tmp.AddRange(data); + } + if (tmp.Count != rows * columns) + { + throw new Exception("the total size of list must be equal to rows * columns"); + } + value = new BasicDecimal64Vector(tmp, scale); + } + + public BasicDecimal64Matrix(ExtendedDataInput @in) : base(@in) + { + } + + public virtual void setDecimal(int row, int column, decimal value) + { + this.value.setDecimal(getIndex(row, column), value); + } + + public virtual decimal getDecimal(int row, int column) + { + return value.getDecimal(getIndex(row, column)); + } + + public void setString(int row, int column, string value) + { + this.value.set(getIndex(row, column), value); + } + + public override bool isNull(int row, int column) + { + return value.isNull(getIndex(row, column)); + } + + public override void setNull(int row, int column) + { + value.setNull(getIndex(row, column)); + } + + public override IScalar get(int row, int column) + { + return this.value.get(getIndex(row, column)); + } + + public void set(int row, int column, IScalar value) + { + this.value.set(getIndex(row, column), value); + } + + public override DATA_CATEGORY getDataCategory() + { + return DATA_CATEGORY.DENARY; + } + + public override DATA_TYPE getDataType() + { + return DATA_TYPE.DT_DECIMAL64; + } + + public override Type getElementClass() + { + return typeof(BasicDecimal64); + } + + protected internal override void readMatrixFromInputStream(int rows, int columns, ExtendedDataInput @in) + { + int scale = @in.readInt(); + this.value = new BasicDecimal64Vector(rows * columns, scale); + value.deserialize(0, rows * columns, @in); + } + + protected internal override void writeVectorToOutputStream(ExtendedDataOutput @out) + { + this.value.writeVectorToOutputStream(@out); + } + + public int getScale() + { + return value.getScale(); + } + } + +} \ No newline at end of file diff --git a/src/data/BasicDecimal64Vector.cs b/src/data/BasicDecimal64Vector.cs index d449d60..a67ce7e 100644 --- a/src/data/BasicDecimal64Vector.cs +++ b/src/data/BasicDecimal64Vector.cs @@ -252,9 +252,13 @@ public override void set(int index, IScalar value) else { int originScale = value.getScale(); - if (originScale > scale_) + if (originScale == scale_) { - values_[index] = ((BasicDecimal64)value).getRawData() / BasicDecimal64.pow10(originScale - scale_); + values_[index] = ((BasicDecimal64)value).getRawData(); + } + else if (originScale > scale_) + { + values_[index] = new BasicDecimal64(value.getString(), scale_).getRawData(); } else { @@ -304,5 +308,10 @@ public decimal getDecimal(int index) { return Utils.createBasicDecimal64(values_[index], scale_).getDecimalValue(); } + + public void setDecimal(int index, decimal value) + { + set(index, new BasicDecimal64(value, scale_)); + } } } diff --git a/src/data/BasicEntityFactory.cs b/src/data/BasicEntityFactory.cs index 7a3d0fc..21305d9 100644 --- a/src/data/BasicEntityFactory.cs +++ b/src/data/BasicEntityFactory.cs @@ -128,13 +128,13 @@ public IEntity createEntity(DATA_FORM form, DATA_TYPE type, ExtendedDataInput @i } } - public IMatrix createMatrixWithDefaultValue(DATA_TYPE type, int rows, int columns) + public IMatrix createMatrixWithDefaultValue(DATA_TYPE type, int rows, int columns, int extra = -1) { int index = (int)type; if (factories[index] == null) return null; else - return factories[index].createMatrixWithDefaultValue(rows, columns); + return factories[index].createMatrixWithDefaultValue(rows, columns, extra); } @@ -280,7 +280,7 @@ private class BooleanFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicBoolean(false); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicBooleanVector(size); } public IVector createPairWithDefaultValue() { return new BasicBooleanVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicBooleanMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicBooleanMatrix(rows, columns); } } private class ByteFactory : TypeFactory @@ -292,7 +292,7 @@ private class ByteFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicByte((byte)0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicByteVector(size); } public IVector createPairWithDefaultValue() { return new BasicByteVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicByteMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicByteMatrix(rows, columns); } } private class ShortFactory : TypeFactory @@ -305,7 +305,7 @@ private class ShortFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicShort((short)0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicShortVector(size); } public IVector createPairWithDefaultValue() { return new BasicShortVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicShortMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicShortMatrix(rows, columns); } } private class IntFactory : TypeFactory @@ -317,7 +317,7 @@ private class IntFactory : TypeFactory public IVector createPairWithDefaultValue() { return new BasicIntVector(DATA_FORM.DF_PAIR, 2); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicIntVector(size); } public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicIntMatrix(@in); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicIntMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicIntMatrix(rows, columns); } } private class LongFactory : TypeFactory @@ -330,7 +330,7 @@ private class LongFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicLong(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicLongVector(size); } public IVector createPairWithDefaultValue() { return new BasicLongVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicLongMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicLongMatrix(rows, columns); } } private class FloatFactory : TypeFactory @@ -342,7 +342,7 @@ private class FloatFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicFloat(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicFloatVector(size); } public IVector createPairWithDefaultValue() { return new BasicFloatVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicFloatMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicFloatMatrix(rows, columns); } } private class DoubleFactory : TypeFactory @@ -355,7 +355,7 @@ private class DoubleFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicDouble(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicDoubleVector(size); } public IVector createPairWithDefaultValue() { return new BasicDoubleVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicDoubleMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicDoubleMatrix(rows, columns); } } private class UuidFactory : TypeFactory @@ -368,7 +368,7 @@ private class UuidFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicUuid(0, 0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicUuidVector(size); } public IVector createPairWithDefaultValue() { return new BasicUuidVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new Exception("Matrix for UUID not supported yet."); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { throw new Exception("Matrix for UUID not supported yet."); } } private class IPAddrFactory : TypeFactory @@ -381,7 +381,7 @@ private class IPAddrFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicIPAddr(0, 0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicIPAddrVector(size); } public IVector createPairWithDefaultValue() { return new BasicIPAddrVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new Exception("Matrix for IPADDR not supported yet."); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { throw new Exception("Matrix for IPADDR not supported yet."); } } private class Int128Factory : TypeFactory @@ -394,7 +394,7 @@ private class Int128Factory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicInt128(0, 0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicInt128Vector(size); } public IVector createPairWithDefaultValue() { return new BasicInt128Vector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new Exception("Matrix for INT128 not supported yet."); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { throw new Exception("Matrix for INT128 not supported yet."); } } private class StringFactory : TypeFactory @@ -403,11 +403,11 @@ private class StringFactory : TypeFactory public IScalar createScalar(ExtendedDataInput @in) { return new BasicString(@in); } public IVector createVector(ExtendedDataInput @in) { return new BasicStringVector(DATA_FORM.DF_VECTOR, @in); } public IVector createPair(ExtendedDataInput @in) { return new BasicStringVector(DATA_FORM.DF_PAIR, @in); } - public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicStringMatrix(@in); } + public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicStringMatrix(@in, false); } public IScalar createScalarWithDefaultValue() { return new BasicString(""); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicStringVector(size); } public IVector createPairWithDefaultValue() { return new BasicStringVector(DATA_FORM.DF_PAIR, 2, false); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicStringMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicStringMatrix(rows, columns); } } //2021.01.19 cwj @@ -417,11 +417,11 @@ private class BlobFactory : TypeFactory public IScalar createScalar(ExtendedDataInput @in) { return new BasicString(@in,true); } public IVector createVector(ExtendedDataInput @in) { return new BasicStringVector(DATA_FORM.DF_VECTOR, @in,false,true ); } public IVector createPair(ExtendedDataInput @in) { return new BasicStringVector(DATA_FORM.DF_PAIR, @in,false, true); } - public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicStringMatrix(@in); } + public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicStringMatrix(@in, false); } public IScalar createScalarWithDefaultValue() { return new BasicString("", true); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicStringVector(DATA_FORM.DF_VECTOR, size, false, true); } public IVector createPairWithDefaultValue() { return new BasicStringVector(DATA_FORM.DF_PAIR, 2, false,true); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicStringMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicStringMatrix(rows, columns); } } // private class SymbolFactory : TypeFactory @@ -430,11 +430,11 @@ private class SymbolFactory : TypeFactory public IScalar createScalar(ExtendedDataInput @in) { return new BasicString(@in); } public IVector createVector(ExtendedDataInput @in) { return new BasicStringVector(DATA_FORM.DF_VECTOR, @in); } public IVector createPair(ExtendedDataInput @in) { return new BasicStringVector(DATA_FORM.DF_PAIR, @in); } - public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicStringMatrix(@in); } + public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicStringMatrix(@in, true); } public IScalar createScalarWithDefaultValue() { return new BasicString(""); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicStringVector(DATA_FORM.DF_VECTOR, size, true); } public IVector createPairWithDefaultValue() { return new BasicStringVector(DATA_FORM.DF_PAIR, 2, true); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicStringMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicStringMatrix(rows, columns); } } private class ExtendedSymbolFactory : TypeFactory @@ -443,11 +443,11 @@ private class ExtendedSymbolFactory : TypeFactory public IScalar createScalar(ExtendedDataInput @in) { return new BasicString(@in); } public IVector createVector(ExtendedDataInput @in) { return new BasicSymbolVector(DATA_FORM.DF_VECTOR, @in); } public IVector createPair(ExtendedDataInput @in) { return new BasicSymbolVector(DATA_FORM.DF_PAIR, @in); } - public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicStringMatrix(@in); } + public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicStringMatrix(@in, true); } public IScalar createScalarWithDefaultValue() { return new BasicString(""); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicSymbolVector(size); } public IVector createPairWithDefaultValue() { return new BasicStringVector(DATA_FORM.DF_PAIR, 2, true); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicStringMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicStringMatrix(rows, columns); } } private class DateFactory : TypeFactory @@ -459,7 +459,7 @@ private class DateFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicDate(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicDateVector(size); } public IVector createPairWithDefaultValue() { return new BasicDateVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicDateMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicDateMatrix(rows, columns); } } private class DateTimeFactory : TypeFactory @@ -471,7 +471,7 @@ private class DateTimeFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicDateTime(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicDateTimeVector(size); } public IVector createPairWithDefaultValue() { return new BasicDateTimeVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicDateTimeMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicDateTimeMatrix(rows, columns); } } private class DateHourFactory : TypeFactory @@ -483,7 +483,7 @@ private class DateHourFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicDateHour(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicDateHourVector(size); } public IVector createPairWithDefaultValue() { return new BasicDateHourVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicDateHourMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicDateHourMatrix(rows, columns); } } private class TimestampFactory : TypeFactory @@ -495,7 +495,7 @@ private class TimestampFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicTimestamp(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicTimestampVector(size); } public IVector createPairWithDefaultValue() { return new BasicTimestampVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicTimestampMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicTimestampMatrix(rows, columns); } } private class MonthFactory : TypeFactory @@ -507,7 +507,7 @@ private class MonthFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicMonth(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicMonthVector(size); } public IVector createPairWithDefaultValue() { return new BasicMonthVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicMonthMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicMonthMatrix(rows, columns); } } private class NanoTimestampFactory : TypeFactory { @@ -518,7 +518,7 @@ private class NanoTimestampFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicNanoTimestamp(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicNanoTimestampVector(size); } public IVector createPairWithDefaultValue() { return new BasicNanoTimestampVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicNanoTimestampMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicNanoTimestampMatrix(rows, columns); } } private class MinuteFactory : TypeFactory { @@ -529,7 +529,7 @@ private class MinuteFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicMinute(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicMinuteVector(size); } public IVector createPairWithDefaultValue() { return new BasicMinuteVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicMinuteMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicMinuteMatrix(rows, columns); } } private class SecondFactory : TypeFactory @@ -541,7 +541,7 @@ private class SecondFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicSecond(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicSecondVector(size); } public IVector createPairWithDefaultValue() { return new BasicSecondVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicSecondMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicSecondMatrix(rows, columns); } } private class TimeFactory : TypeFactory @@ -554,7 +554,7 @@ private class TimeFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicTime(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicTimeVector(size); } public IVector createPairWithDefaultValue() { return new BasicTimeVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicTimeMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicTimeMatrix(rows, columns); } } private class NanoTimeFactory : TypeFactory { @@ -565,7 +565,7 @@ private class NanoTimeFactory : TypeFactory public IScalar createScalarWithDefaultValue() { return new BasicNanoTime(0); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicNanoTimeVector(size); } public IVector createPairWithDefaultValue() { return new BasicNanoTimeVector(DATA_FORM.DF_PAIR, 2); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { return new BasicNanoTimeMatrix(rows, columns); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicNanoTimeMatrix(rows, columns); } } private class Decimal32Factory : TypeFactory @@ -573,11 +573,11 @@ private class Decimal32Factory : TypeFactory public IScalar createScalar(ExtendedDataInput @in) { return new BasicDecimal32(@in); } public IVector createVector(ExtendedDataInput @in) { return new BasicDecimal32Vector(DATA_FORM.DF_VECTOR, @in, -1); } public IVector createPair(ExtendedDataInput @in) { return new BasicDecimal32Vector(DATA_FORM.DF_PAIR, @in, -1); } - public IMatrix createMatrix(ExtendedDataInput @in) { throw new NotImplementedException("Matrix for BasicDecimal32 not supported yet."); } + public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicDecimal32Matrix(@in); } public IScalar createScalarWithDefaultValue() { return new BasicDecimal32("0"); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicDecimal32Vector(size, extra); } public IVector createPairWithDefaultValue() { throw new NotImplementedException(); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new NotImplementedException("Matrix for BasicDecimal32 not supported yet."); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicDecimal32Matrix(rows, columns, extra); } } private class Decimal64Factory : TypeFactory @@ -585,11 +585,11 @@ private class Decimal64Factory : TypeFactory public IScalar createScalar(ExtendedDataInput @in) { return new BasicDecimal64(@in); } public IVector createVector(ExtendedDataInput @in) { return new BasicDecimal64Vector(DATA_FORM.DF_VECTOR, @in, -1); } public IVector createPair(ExtendedDataInput @in) { return new BasicDecimal64Vector(DATA_FORM.DF_PAIR, @in, -1); } - public IMatrix createMatrix(ExtendedDataInput @in) { throw new NotImplementedException("Matrix for BasicDecimal64 not supported yet."); } + public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicDecimal64Matrix(@in); } public IScalar createScalarWithDefaultValue() { return new BasicDecimal64("0"); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicDecimal64Vector(size, extra); } public IVector createPairWithDefaultValue() { throw new NotImplementedException(); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new NotImplementedException("Matrix for BasicDecimal32 not supported yet."); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicDecimal64Matrix(rows, columns, extra); } } private class Decimal128Factory : TypeFactory @@ -597,11 +597,11 @@ private class Decimal128Factory : TypeFactory public IScalar createScalar(ExtendedDataInput @in) { return new BasicDecimal128(@in); } public IVector createVector(ExtendedDataInput @in) { return new BasicDecimal128Vector(DATA_FORM.DF_VECTOR, @in, -1); } public IVector createPair(ExtendedDataInput @in) { return new BasicDecimal128Vector(DATA_FORM.DF_PAIR, @in, -1); } - public IMatrix createMatrix(ExtendedDataInput @in) { throw new NotImplementedException("Matrix for BasicDecimal128 not supported yet."); } + public IMatrix createMatrix(ExtendedDataInput @in) { return new BasicDecimal128Matrix(@in); } public IScalar createScalarWithDefaultValue() { return new BasicDecimal128("0"); } public IVector createVectorWithDefaultValue(int size, int extra = -1) { return new BasicDecimal128Vector(size, extra); } public IVector createPairWithDefaultValue() { throw new NotImplementedException(); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new NotImplementedException("Matrix for BasicDecimal128 not supported yet."); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { return new BasicDecimal128Matrix(rows, columns, extra); } } private class FunctionDefFactory : TypeFactory @@ -613,7 +613,7 @@ private class FunctionDefFactory : TypeFactory public IMatrix createMatrix(ExtendedDataInput @in) { throw new NotImplementedException(); } public IVector createVectorWithDefaultValue(int size, int extra) { throw new NotImplementedException(); } public IVector createPairWithDefaultValue() { throw new NotImplementedException(); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new NotImplementedException(); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { throw new NotImplementedException(); } } private class MetaCodeFactory : TypeFactory @@ -625,7 +625,7 @@ private class MetaCodeFactory : TypeFactory public IMatrix createMatrix(ExtendedDataInput @in) { throw new NotImplementedException(); } public IVector createVectorWithDefaultValue(int size, int extra) { throw new NotImplementedException(); } public IVector createPairWithDefaultValue() { throw new NotImplementedException(); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new NotImplementedException(); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { throw new NotImplementedException(); } } private class DataSourceFactory : TypeFactory @@ -637,7 +637,7 @@ private class DataSourceFactory : TypeFactory public IMatrix createMatrix(ExtendedDataInput @in) { throw new NotImplementedException(); } public IVector createVectorWithDefaultValue(int size, int extra) { throw new NotImplementedException(); } public IVector createPairWithDefaultValue() { throw new NotImplementedException(); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new NotImplementedException(); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { throw new NotImplementedException(); } } private class SystemHandleFactory : TypeFactory @@ -650,7 +650,7 @@ private class SystemHandleFactory : TypeFactory public IMatrix createMatrix(ExtendedDataInput @in) { throw new NotImplementedException(); } public IVector createVectorWithDefaultValue(int size, int extra) { throw new NotImplementedException(); } public IVector createPairWithDefaultValue() { throw new NotImplementedException(); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new NotImplementedException(); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { throw new NotImplementedException(); } } private class ResourceFactory : TypeFactory @@ -663,7 +663,7 @@ private class ResourceFactory : TypeFactory public IMatrix createMatrix(ExtendedDataInput @in) { throw new NotImplementedException(); } public IVector createVectorWithDefaultValue(int size, int extra) { throw new NotImplementedException(); } public IVector createPairWithDefaultValue() { throw new NotImplementedException(); } - public IMatrix createMatrixWithDefaultValue(int rows, int columns) { throw new NotImplementedException(); } + public IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra) { throw new NotImplementedException(); } } } @@ -676,6 +676,6 @@ public interface TypeFactory IMatrix createMatrix(ExtendedDataInput @in); IVector createVectorWithDefaultValue(int size, int extra); IVector createPairWithDefaultValue(); - IMatrix createMatrixWithDefaultValue(int rows, int columns); + IMatrix createMatrixWithDefaultValue(int rows, int columns, int extra); } } \ No newline at end of file diff --git a/src/data/BasicStringMatrix.cs b/src/data/BasicStringMatrix.cs index 1c16bb7..33ee283 100644 --- a/src/data/BasicStringMatrix.cs +++ b/src/data/BasicStringMatrix.cs @@ -9,12 +9,11 @@ namespace dolphindb.data public class BasicStringMatrix : AbstractMatrix { private string[] values; - private bool isSymbol; + private bool isSymbol = false; public BasicStringMatrix(int rows, int columns) : base(rows, columns) { values = new string[rows * columns]; - isSymbol = true; } public BasicStringMatrix(int rows, int columns, IList list) : base(rows, columns) @@ -33,12 +32,11 @@ public BasicStringMatrix(int rows, int columns, IList list) : base(row } Array.Copy(array, 0, values, i * rows, rows); } - isSymbol = true; } - public BasicStringMatrix(ExtendedDataInput @in) : base(@in) + public BasicStringMatrix(ExtendedDataInput @in, bool isSymbol) : base(@in) { - isSymbol = true; + this.isSymbol = isSymbol; } public virtual void setString(int row, int column, string value) diff --git a/src/data/BasicStringVector.cs b/src/data/BasicStringVector.cs index 5c3344c..5026748 100644 --- a/src/data/BasicStringVector.cs +++ b/src/data/BasicStringVector.cs @@ -10,7 +10,7 @@ public class BasicStringVector : AbstractVector { private List values; private List blobValues; - private bool isSymbol; + private bool isSymbol = false; //2021.01.19 cwj private bool isBlob = false; // diff --git a/src/data/IEntityFactory.cs b/src/data/IEntityFactory.cs index 4d1d921..4f28985 100644 --- a/src/data/IEntityFactory.cs +++ b/src/data/IEntityFactory.cs @@ -5,7 +5,7 @@ namespace dolphindb.data public interface IEntityFactory { IEntity createEntity(DATA_FORM form, DATA_TYPE type, ExtendedDataInput @in, bool extended); - IMatrix createMatrixWithDefaultValue(DATA_TYPE type, int rows, int columns); + IMatrix createMatrixWithDefaultValue(DATA_TYPE type, int rows, int columns, int extra = -1); IVector createVectorWithDefaultValue(DATA_TYPE type, int size, int extra = -1); IVector createPairWithDefaultValue(DATA_TYPE type); IScalar createScalarWithDefaultValue(DATA_TYPE type); diff --git a/src/data/Utils.cs b/src/data/Utils.cs index 40fe6f0..8b98b2b 100644 --- a/src/data/Utils.cs +++ b/src/data/Utils.cs @@ -30,7 +30,7 @@ public class Utils private static readonly int[] cumLeapMonthDays = new int[] { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }; private static readonly int[] monthDays = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; private static readonly int[] leapMonthDays = new int[] { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - private static string API_VERSION = "3.00.0.0"; + private static string API_VERSION = "3.00.1.0"; public static string getAPIVersion() { @@ -950,6 +950,8 @@ public static string getDataTypeString(DATA_TYPE dt) { switch (dt) { + case DATA_TYPE.DT_VOID: + return "VOID"; case DATA_TYPE.DT_BOOL: return "BOOL"; case DATA_TYPE.DT_BYTE: @@ -1412,6 +1414,23 @@ public static BasicDecimal128 createBasicDecimal128(BigInteger rawData, int scal { return new BasicDecimal128(rawData, scale); } + + internal static void checkParamIsNull(object param, string paramName) + { + if(param == null) + { + throw new Exception(paramName + " must be non-null."); + } + } + + internal static void checkStringNotNullAndEmpty (string param, string paramName) + { + checkParamIsNull(param, paramName); + if (param == "") + { + throw new Exception(paramName + " must be non-empty."); + } + } } } \ No newline at end of file diff --git a/src/dolphindb_csharpapi.csproj b/src/dolphindb_csharpapi.csproj index 5196e52..cb53c8e 100644 --- a/src/dolphindb_csharpapi.csproj +++ b/src/dolphindb_csharpapi.csproj @@ -52,10 +52,13 @@ + + + @@ -193,6 +196,10 @@ + + + + diff --git a/src/route/autoFitTableAppender.cs b/src/route/autoFitTableAppender.cs index 1ce5e4a..7aa7647 100644 --- a/src/route/autoFitTableAppender.cs +++ b/src/route/autoFitTableAppender.cs @@ -18,6 +18,7 @@ public class autoFitTableAppender private string tableStr; Dictionary dataTypeMap; Dictionary extrasMap; + bool supportDecimal; @@ -34,7 +35,8 @@ public autoFitTableAppender(string dbUrl, string tableName, bool asynTask,DBConn colDefs = ((BasicTable)tableInfo.get(new BasicString("colDefs"))); BasicStringVector names = (BasicStringVector)colDefs.getColumn("name"); BasicIntVector types = (BasicIntVector)colDefs.getColumn("typeInt"); - BasicIntVector extras = (BasicIntVector)colDefs.getColumn("extra"); + supportDecimal = colDefs.getColumnNames().Contains("extra"); + BasicIntVector extras = supportDecimal ? (BasicIntVector)colDefs.getColumn("extra") : null; int rows = names.rows(); this.dataTypeMap = new Dictionary(); @@ -42,7 +44,7 @@ public autoFitTableAppender(string dbUrl, string tableName, bool asynTask,DBConn for (int i = 0; i < rows; ++i) { dataTypeMap.Add(names.getString(i), (DATA_TYPE)types.getInt(i)); - extrasMap.Add(names.getString(i), extras.getInt(i)); + if(supportDecimal) extrasMap.Add(names.getString(i), extras.getInt(i)); } conn.setasynTask(asynTask); diff --git a/src/streaming/MessageParser.cs b/src/streaming/MessageParser.cs index 2f5dad0..2d7572a 100644 --- a/src/streaming/MessageParser.cs +++ b/src/streaming/MessageParser.cs @@ -199,7 +199,7 @@ public void run() IEntity entity = vector.getEntity(i); row.setEntity(j, entity); } - BasicMessage rec = new BasicMessage(msgId, topic, row); + BasicMessage rec = new BasicMessage(msgId - rowSize + i + 1, topic, row); if (subscribeInfo.getDeseriaLizer() != null) rec = subscribeInfo.getDeseriaLizer().parse(rec); messages.Add(rec); diff --git a/src/streaming/cep/EventClient.cs b/src/streaming/cep/EventClient.cs new file mode 100644 index 0000000..af390fe --- /dev/null +++ b/src/streaming/cep/EventClient.cs @@ -0,0 +1,212 @@ +using System; +using System.Collections.Generic; +using System.Collections.Concurrent; +using System.Threading; +using dolphindb.data; +using dolphindb.streaming.cep; + +namespace dolphindb.streaming.cep +{ + public class EventClient : AbstractClient + { + private Dictionary handlerLoopers = new Dictionary(); + public EventClient(List eventSchema, List eventTimeFields = null, List commonFields = null) : base("", -1) + { + if(eventTimeFields == null) eventTimeFields = new List(); + if(commonFields == null) commonFields = new List(); + eventHandler_ = new EventHandler(eventSchema, eventTimeFields, commonFields); + } + + EventHandler eventHandler_; + + class HandlerLooper + { + public Thread thread_; + BlockingCollection> queue_; + EventMessageHandler handler_; + int batchSize_; + float throttle_; + MessageDispatcher dispatcher_; + EventHandler eventHandler_; + internal HandlerLooper(BlockingCollection> queue, EventMessageHandler handler, int batchSize, float throttle, MessageDispatcher dispatcher, EventHandler eventHandler) + { + this.queue_ = queue; + this.handler_ = handler; + this.batchSize_ = batchSize; + this.throttle_ = throttle; + this.dispatcher_ = dispatcher; + this.eventHandler_ = eventHandler; + } + + public void run() + { + try + { + while (!dispatcher_.isClose()) + { + List messages = null; + if (!this.queue_.TryTake(out messages, 1000)) + continue; + List eventTypes; + List> attributes; + try + { + eventTypes = new List(); + attributes = new List>(); + eventHandler_.deserializeEvent(messages, eventTypes, attributes); + for (int i = 0; i < eventTypes.Count; ++i) + { + handler_.doEvent(eventTypes[i], attributes[i]); + } + } + catch (Exception e) + { + Console.WriteLine("failed to doEvent: " + e.Message); + Console.Write(e.StackTrace); + } + } + + } + catch (ThreadInterruptedException) + { + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + Console.WriteLine(ex.StackTrace); + } + Console.WriteLine("Handler thread stopped."); + } + } + + protected override bool doReconnect(SubscribeInfo subscribeInfo, Site site) + { + try + { + subscribe(site.host, site.port, subscribeInfo.getTableName(), subscribeInfo.getActionName(), null, + subscribeInfo.getMsgId() + 1, true, subscribeInfo.getFilter(), -1, 0, subscribeInfo.getDeseriaLizer(), subscribeInfo.getUser(), subscribeInfo.getPassword(), false); + Console.WriteLine("Successfully reconnected and subscribed " + site.host + ":" + site.port + ":" + subscribeInfo.getTableName()); + return true; + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + Console.WriteLine(ex.StackTrace); + } + return false; + } + + public void subscribe(string host, int port, string tableName, string actionName, EventMessageHandler handler, long offset = -1, bool reconnect = true, string user = "", string password = "") + { + Utils.checkStringNotNullAndEmpty(host, "host"); + Utils.checkStringNotNullAndEmpty(tableName, "tableName"); + Utils.checkStringNotNullAndEmpty(actionName, "actionName"); + Utils.checkParamIsNull(handler, "handler"); + Utils.checkParamIsNull(user, "user"); + Utils.checkParamIsNull(password, "password"); + subscribe(host, port, tableName, actionName, handler, offset, reconnect, null, -1, 1, null, user, password, true); + } + + + private void subscribe(string host, int port, string tableName, string actionName, EventMessageHandler handler, long offset, bool reconnect, IVector filter, int batchSize, float throttle, StreamDeserializer deserializer, string user, string password, bool createSubInfo) + { + if (!(batchSize == -1 || batchSize > 0)) + throw new Exception("Invalid batchSize value, should be -1 or positive integer."); + if (throttle < 0) + throw new Exception("Throttle can't be less than 0."); + lock (this) + { + DBConnection dbConn = new DBConnection(); + try + { + dbConn.connect(host, port); + string sql = "select top 0 * from " + tableName; + BasicTable table = (BasicTable)dbConn.run(sql); + eventHandler_.checkOutputTable(table, tableName); + List @params = new List + { + new BasicString(tableName), + new BasicString(actionName) + }; + IEntity re = dbConn.run("getSubscriptionTopic", @params); + string topic = ((BasicAnyVector)re).getEntity(0).getString(); + BlockingCollection> queue = subscribeInternal(host, port, tableName, actionName, null, offset, reconnect, filter, deserializer, user, password, createSubInfo); + if (createSubInfo) + { + lock (handlerLoopers) + { + HandlerLooper handlerLooper = new HandlerLooper(queue, handler, batchSize, throttle, this, eventHandler_); + handlerLooper.thread_ = new Thread(new ThreadStart(handlerLooper.run)); + handlerLooper.thread_.Start(); + handlerLoopers.Add(topic, handlerLooper); + } + } + } + catch (Exception ex) + { + throw ex; + } + finally + { + dbConn.close(); + } + } + } + + public void unsubscribe(string host, int port, string tableName, string actionName) + { + unsubscribeInternal(host, port, tableName, actionName); + } + + public override void close() + { + base.close(); + } + + protected override void unsubscribeInternal(string host, int port, string tableName, string actionName) + { + DBConnection dbConn = new DBConnection(); + dbConn.connect(host, port); + try + { + lock (this) + { + string localIP = listeningHost_; + if (localIP == null || localIP.Equals(String.Empty)) + localIP = dbConn.LocalAddress; + List @params = new List + { + new BasicString(tableName), + new BasicString(actionName) + }; + IEntity re = dbConn.run("getSubscriptionTopic", @params); + string topic = ((BasicAnyVector)re).getEntity(0).getString(); + SubscribeInfo subscribeInfo = null; + if (!subscribeInfos_.TryRemove(topic, out subscribeInfo)) + { + throw new Exception("The subscription " + topic + " doesn't exist. "); + } + lock (handlerLoopers) + { + handlerLoopers.Remove(topic); + } + @params = new List + { + new BasicString(localIP), + new BasicInt(listeningPort_), + new BasicString(tableName), + new BasicString(actionName) + }; + subscribeInfo.close(); + dbConn.run("stopPublishTable", @params); + Console.WriteLine("Successfully unsubscribed table " + topic); + } + } + finally + { + dbConn.close(); + } + return; + } + } +} diff --git a/src/streaming/cep/EventHandler.cs b/src/streaming/cep/EventHandler.cs new file mode 100644 index 0000000..d9af36d --- /dev/null +++ b/src/streaming/cep/EventHandler.cs @@ -0,0 +1,562 @@ +using dolphindb.data; +using dolphindb.io; +using dolphindb.route; +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using System.Text; + +namespace dolphindb.streaming.cep +{ + public class EventSchema + { + public EventSchema(string eventType, List fieldNames, List fieldTypes, List fieldForms, List fieldExtraParams = null) + { + Utils.checkStringNotNullAndEmpty(eventType, "eventType"); + Utils.checkParamIsNull(fieldNames, "fieldNames"); + Utils.checkParamIsNull(fieldTypes, "fieldTypes"); + Utils.checkParamIsNull(fieldForms, "fieldForms"); + eventType_ = eventType; + fieldNames_ = fieldNames; + fieldTypes_ = fieldTypes; + fieldForms_ = fieldForms; + for(int i = 0; i < fieldNames_.Count; ++i) + { + Utils.checkStringNotNullAndEmpty(fieldNames_[i], "the element of fieldNames"); + } + for(int i = 0; i < fieldForms.Count; ++i) + { + if (fieldForms[i] != DATA_FORM.DF_VECTOR && fieldForms[i] != DATA_FORM.DF_SCALAR) + { + throw new Exception("FieldForm only can be DF_SCALAR or DF_VECTOR."); + } + } + + for (int i = 0; i < fieldTypes_.Count; ++i) + { + DATA_CATEGORY category = Utils.getCategory(fieldTypes_[i]); + if(category == DATA_CATEGORY.NOTHING || category == DATA_CATEGORY.SYSTEM || category == DATA_CATEGORY.MIXED) + { + throw new Exception("not support " + Utils.getDataTypeString(fieldTypes_[i]) + " type. "); + } + } + if (fieldExtraParams == null) + { + fieldExtraParams_ = new List { }; + for(int i = 0; i < fieldNames_.Count; ++i) + { + fieldExtraParams_.Add(0); + } + } + else + { + fieldExtraParams_ = new List { }; + fieldExtraParams_.AddRange(fieldExtraParams); + } + } + + public string geteEventType() + { + return eventType_; + } + + public List getFieldNames() + { + return fieldNames_; + } + + public List getFieldTypes() + { + return fieldTypes_; + } + + public List getFieldForms() + { + return fieldForms_; + } + + public List getFieldExtraParams() + { + return fieldExtraParams_; + } + + private string eventType_; + private List fieldNames_; + private List fieldTypes_; + private List fieldForms_; + private List fieldExtraParams_; + }; + + + + class EventSchemaEx + { + public EventSchema schema_; + public int timeIndex_; + public List commonKeyIndex_ = new List(); + }; + + class AttributeSerializer + { + public AttributeSerializer() + { + } + public virtual void serialize(IEntity attribute, AbstractExtendedDataOutputStream outStream, int scale) + { + if (attribute.isScalar()) + { + if(((AbstractScalar)attribute).getDataCategory() == DATA_CATEGORY.DENARY && ((AbstractScalar)attribute).getScale() != scale) + { + attribute = Utils.createObject(attribute.getDataType(), attribute.getString(), scale); + } + ((AbstractScalar)attribute).writeScalarToOutputStream(outStream); + } + else if (attribute.isVector()) + { + int type = (int)attribute.getDataType(); + if(attribute is BasicSymbolVector) + { + type += 128; + } + int flag = ((int)DATA_FORM.DF_VECTOR << 8) + type; + outStream.writeShort(flag); + outStream.writeInt(attribute.rows()); + outStream.writeInt(attribute.columns()); + ((AbstractVector)attribute).writeVectorToOutputStream(outStream); + }else + { + throw new Exception("the " + Utils.getDataFormString(attribute.getDataForm()) + " is not supported. "); + } + } + }; + + struct EventInfo + { + public List attributeSerializers_; + public EventSchemaEx eventSchema_; + }; + + + class FastArrayAttributeSerializer : AttributeSerializer + { + public FastArrayAttributeSerializer() : base() { } + public override void serialize(IEntity attribute, AbstractExtendedDataOutputStream outStream, int scale) + { + { + if (attribute.getDataCategory() == DATA_CATEGORY.DENARY) + { + if(((AbstractVector)attribute).getScale() != scale) + { + int rows = attribute.rows(); + AbstractVector tmp = (AbstractVector)BasicEntityFactory.instance().createVectorWithDefaultValue(attribute.getDataType(), rows, scale); + for(int i = 0; i < rows; i++) + { + tmp.set(i, ((AbstractVector)attribute).get(i)); + } + attribute = tmp; + } + } + } + int curCount = attribute.rows(); + if (curCount == 0) + { + short tCnt = (short)curCount; + outStream.writeShort(tCnt); + return; + } + + ushort arrayRows = 1; + byte curCountBytes = 1; + byte reserved = 0; + int maxCount = 255; + while (curCount > maxCount) + { + curCountBytes *= 2; + maxCount = (int)((1L << (8 * curCountBytes)) - 1); + } + outStream.writeShort(arrayRows); + outStream.writeByte(curCountBytes); + outStream.writeByte(reserved); + switch (curCountBytes) + { + case 1: + { + byte tCnt = (byte)curCount; + outStream.writeByte(tCnt); + break; + } + case 2: + { + ushort tCnt = (ushort)curCount; + outStream.writeShort((short)tCnt); + break; + } + default: + { + uint tCnt = (uint)curCount; + outStream.writeInt((int)tCnt); + } + break; + } + ((AbstractVector)attribute).serialize(0, curCount, outStream); + } + }; + + + + class EventHandler + { + public EventHandler(List eventSchemas, List eventTimeKeys, List commonKeys) + { + Utils.checkParamIsNull(eventSchemas, "eventSchemas"); + Utils.checkParamIsNull(eventTimeKeys, "eventTimeKeys"); + Utils.checkParamIsNull(commonKeys, "commonKeys"); + isNeedEventTime_ = false; + outputColNums_ = 0; + //check eventSchemas + if (eventSchemas.Count == 0) + { + throw new Exception("eventSchemas must not be empty."); + } + List expandEventSchemas = eventSchemas; + foreach (EventSchema item in expandEventSchemas) + { + if (item.geteEventType().Length == 0) + { + throw new Exception("eventType must not be empty."); + } + int length = item.getFieldNames().Count; + if (length == 0) + { + throw new Exception("the eventKey in eventSchema must not be empty."); + } + if (length != item.getFieldExtraParams().Count() || length != item.getFieldForms().Count() || length != item.getFieldTypes().Count()) + { + throw new Exception("The number of eventKey, eventTypes, eventForms and eventExtraParams must have the same length."); + } + } + int eventNum = eventSchemas.Count(); + //check eventTimeKeys + List expandTimeKeys = new List(); + if (eventTimeKeys.Count != 0) + { + //if eventTimeKeys only contain one element, it means every event has this key + if (eventTimeKeys.Count == 1) + { + for (int i = 0; expandTimeKeys.Count < eventNum; ++i) + { + expandTimeKeys.Add(eventTimeKeys[0]); + } + } + else + { + if (eventTimeKeys.Count != eventNum) + { + throw new Exception("The number of eventTimeKey is inconsistent with the number of events in eventSchemas."); + } + expandTimeKeys = eventTimeKeys; + } + isNeedEventTime_ = true; + } + checkSchema(expandEventSchemas, expandTimeKeys, commonKeys); + commonKeySize_ = commonKeys.Count(); + } + public void checkOutputTable(BasicTable outputTable, string tableName) + { + outputColNums_ = isNeedEventTime_ ? (3 + commonKeySize_) : (2 + commonKeySize_); + if (outputColNums_ != outputTable.columns()) + { + throw new Exception("Incompatible table columnns for table " + tableName + ", expected: " + outputColNums_.ToString() + ", got: " + outputTable.columns().ToString() + "."); + } + int colIdx = 0; + if (isNeedEventTime_) + { + if (Utils.getCategory(outputTable.getColumn(0).getDataType()) != DATA_CATEGORY.TEMPORAL) + { + throw new Exception("The first column of the output table must be temporal if eventTimeKey is specified."); + } + colIdx++; + } + int typeIdx_ = colIdx++; + int blobIdx_ = colIdx++; + + if (outputTable.getColumn(typeIdx_).getDataType() != DATA_TYPE.DT_STRING && outputTable.getColumn(typeIdx_).getDataType() != DATA_TYPE.DT_SYMBOL) + { + throw new Exception("The eventType column of the output table must be STRING or SYMBOL type."); + } + if (outputTable.getColumn(blobIdx_).getDataType() != DATA_TYPE.DT_BLOB) + { + throw new Exception("The event column of the output table must be BLOB type."); + } + } + public void serializeEvent(string eventType, List attributes, List serializedEvent) + { + if (!eventInfos_.ContainsKey(eventType)) + { + throw new Exception("unknown eventType " + eventType + "."); + } + + EventInfo info = eventInfos_[eventType]; + if (attributes.Count() != info.attributeSerializers_.Count()) + { + throw new Exception("the number of event values does not match."); + } + + + List fieldTypes = info.eventSchema_.schema_.getFieldTypes(); + List fieldNames = info.eventSchema_.schema_.getFieldNames(); + List fieldForms = info.eventSchema_.schema_.getFieldForms(); + for (int i = 0; i < attributes.Count(); ++i) + { + if (fieldTypes[i] != attributes[i].getDataType()) + { + //An exception: when the type in schema is symbol, you can pass a string attribute + if (fieldTypes[i] == DATA_TYPE.DT_SYMBOL && attributes[i].getDataType() == DATA_TYPE.DT_STRING) + { + continue; + } + throw new Exception("Expected type for the field " + fieldNames[i] + " of " + eventType + " : " + Utils.getDataTypeString(fieldTypes[i]) + + ", but now it is " + Utils.getDataTypeString(attributes[i].getDataType()) + "."); + } + if (fieldForms[i] != attributes[i].getDataForm()) + { + throw new Exception("Expected form for the field " + fieldNames[i] + " of " + eventType + " : " + Utils.getDataFormString(fieldForms[i]) + + ", but now it is " + Utils.getDataFormString(attributes[i].getDataForm()) + "."); + } + } + + //std::vector oneLineContent; + BasicAnyVector oneLineContent = new BasicAnyVector(0); + if (isNeedEventTime_) + { + if (attributes[info.eventSchema_.timeIndex_].isScalar()) + { + oneLineContent.append(attributes[info.eventSchema_.timeIndex_]); + } + } + oneLineContent.append(new BasicString(eventType)); + //serialize all attribute to a blob + MemoryStream myStream = new MemoryStream(); + LittleEndianDataOutputStream outStream = new LittleEndianDataOutputStream(myStream); + List extraParams = info.eventSchema_.schema_.getFieldExtraParams(); + for (int i = 0; i < attributes.Count(); ++i) + { + info.attributeSerializers_[i].serialize(attributes[i], outStream, extraParams[i]); + } + oneLineContent.append(new BasicString(myStream.ToArray(), true)); + + foreach (int commonIndex in info.eventSchema_.commonKeyIndex_) + { + if (fieldForms[commonIndex] == DATA_FORM.DF_VECTOR) + { + BasicAnyVector any = new BasicAnyVector(0); + any.append(attributes[commonIndex]); + oneLineContent.append(any); + } + else + { + oneLineContent.append(attributes[commonIndex]); + } + } + serializedEvent.Add(oneLineContent); + } + public void deserializeEvent(List obj, List eventTypes, List> attributes) + { + int eventTypeIndex = isNeedEventTime_ ? 1 : 0; + int blobIndex = isNeedEventTime_ ? 2 : 1; + int rowSize = obj.Count; + for (int rowIndex = 0; rowIndex < rowSize; ++rowIndex) + { + string eventType = obj[rowIndex].getEntity(eventTypeIndex).getString(); + if (!eventInfos_.ContainsKey(eventType)) + { + throw new Exception("UnKnown eventType " + eventType + "."); + } + byte[] blob = ((BasicString)obj[rowIndex].getEntity(blobIndex)).getBytes(); + + + MemoryStream memoryStream = new MemoryStream(); + ExtendedDataOutput writeStream = new BigEndianDataOutputStream(memoryStream); + writeStream.write(blob); + LittleEndianDataInputStream input = new LittleEndianDataInputStream(new MemoryStream(memoryStream.GetBuffer(), 0, (int)memoryStream.Position)); + + EventSchema schema = eventInfos_[eventType].eventSchema_.schema_; + List fieldTypes = schema.getFieldTypes(); + List fieldNames = schema.getFieldNames(); + List fieldForms = schema.getFieldForms(); + List fieldExtraParams = schema.getFieldExtraParams(); + int attrCount = fieldTypes.Count(); + List datas = new List(); + for (int i = 0; i < attrCount; ++i) + { + DATA_FORM form = fieldForms[i]; + DATA_TYPE type = fieldTypes[i]; + int extraParam = fieldExtraParams[i]; + if (form == DATA_FORM.DF_SCALAR) + { + if (type == DATA_TYPE.DT_ANY) + { + datas.Add(deserializeAny(input)); + } + else + { + datas.Add(deserializeScalar(type, extraParam, input)); + } + } + else if (form == DATA_FORM.DF_VECTOR) + { + if (((int)type) < 64 && Utils.getCategory(type) != DATA_CATEGORY.LITERAL) + { + datas.Add(deserializeFastArray(type, extraParam, input)); + } + else + { + datas.Add(deserializeAny(input)); + } + } + else + { + datas.Add(deserializeAny(input)); + } + if (datas[i] == null) + { + throw new Exception("Deserialize blob error."); + } + } + eventTypes.Add(eventType); + attributes.Add(datas); + } + } + private void checkSchema(List eventSchemas, List expandTimeKeys, List commonKeys) + { + int index = 0; + foreach (EventSchema schema in eventSchemas) + { + if (eventInfos_.ContainsKey(schema.geteEventType())) + { + throw new Exception("EventType must be unique."); + } + + EventSchemaEx schemaEx = new EventSchemaEx(); + schemaEx.schema_ = schema; + List fieldNames = schema.getFieldNames(); + if (isNeedEventTime_) + { + if (!fieldNames.Contains(expandTimeKeys[index])) + { + throw new Exception("Event " + schema.geteEventType() + " doesn't contain eventTimeKey " + expandTimeKeys[index] + "."); + } + schemaEx.timeIndex_ = fieldNames.FindIndex(0, x => x == expandTimeKeys[index]); + } + + foreach (string commonKey in commonKeys) + { + if (!fieldNames.Contains(commonKey)) + { + throw new Exception("Event " + schema.geteEventType() + " doesn't contain commonField " + commonKey + "."); + } + schemaEx.commonKeyIndex_.Add(fieldNames.FindIndex(0, x => x == commonKey)); + } + + List serls = new List(); + if(fieldNames.Distinct().Count() != fieldNames.Count()) + throw new Exception("fieldNames must be unique."); + int length = fieldNames.Count; + List fieldTypes = schema.getFieldTypes(); + List fieldForms = schema.getFieldForms(); + for (int j = 0; j < length; ++j) + { + DATA_TYPE type = fieldTypes[j]; + DATA_FORM form = fieldForms[j]; + if(form == DATA_FORM.DF_VECTOR && ((int)type) < AbstractVector.ARRAY_VECTOR_BASE && type != DATA_TYPE.DT_ANY) + { + int unitLen = AbstractVector.getUnitLength(type); + if(type == DATA_TYPE.DT_SYMBOL) + { + unitLen = -1; + } + if(unitLen > 0) + { + serls.Add(new FastArrayAttributeSerializer()); + continue; + } + } + serls.Add(new AttributeSerializer()); + } + + EventInfo info; + info.attributeSerializers_ = serls; + info.eventSchema_ = schemaEx; + eventInfos_[schema.geteEventType()] = info; + index++; + } + } + IEntity deserializeScalar(DATA_TYPE type, int extraParam, AbstractExtendedDataInputStream input) + { + if(Utils.getCategory(type) == DATA_CATEGORY.DENARY) + { + if(type == DATA_TYPE.DT_DECIMAL128) + { + return new BasicDecimal128(input, extraParam); + }else if(type == DATA_TYPE.DT_DECIMAL64) + { + return new BasicDecimal64(input, extraParam); + } + else + { + return new BasicDecimal32(input, extraParam); + } + } + else + { + return (IScalar)BasicEntityFactory.instance().createEntity(DATA_FORM.DF_SCALAR, type, input, false); + } + } + IVector deserializeFastArray(DATA_TYPE type, int extraParam, AbstractExtendedDataInputStream input) + { + int totalCount = input.ReadInt16(); + if(totalCount == 0) + { + return BasicEntityFactory.instance().createVectorWithDefaultValue(type, 0, extraParam); + } + byte countByte = input.ReadByte(); + input.ReadByte(); + int count; + if (countByte == 1) + { + count = input.ReadByte(); + }else if(countByte == 2) + { + count = input.ReadUInt16(); + } + else + { + count = input.readInt(); + } + AbstractVector vector = (AbstractVector)BasicEntityFactory.instance().createVectorWithDefaultValue(type, count, extraParam); + vector.deserialize(0, count, input); + return vector; + } + IEntity deserializeAny(AbstractExtendedDataInputStream input) + { + short flag = input.ReadInt16(); + int form = flag >> 8; + int type = flag & 0xff; + bool extended = type >= 128; + if (type >= 128) + type -= 128; + IEntity ret = BasicEntityFactory.instance().createEntity((DATA_FORM)form, (DATA_TYPE)type, input, extended); + return ret; + } + + Dictionary eventInfos_ = new Dictionary(); + bool isNeedEventTime_; + + int outputColNums_; //the number of columns of the output table + int commonKeySize_; + }; +} diff --git a/src/streaming/cep/EventMessageHandler.cs b/src/streaming/cep/EventMessageHandler.cs new file mode 100644 index 0000000..082a68d --- /dev/null +++ b/src/streaming/cep/EventMessageHandler.cs @@ -0,0 +1,13 @@ +using dolphindb.data; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace dolphindb.streaming.cep +{ + public interface EventMessageHandler { + + void doEvent(string eventType, List attribute); + } +} diff --git a/src/streaming/cep/EventSender.cs b/src/streaming/cep/EventSender.cs new file mode 100644 index 0000000..74b7a19 --- /dev/null +++ b/src/streaming/cep/EventSender.cs @@ -0,0 +1,45 @@ +using dolphindb.data; +using System; +using System.Collections.Generic; +using System.Data.Common; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dolphindb.streaming.cep +{ + public class EventSender + { + public EventSender(DBConnection conn, string tableName, List eventSchema, List eventTimeFields = null, List commonFields = null) + { + Utils.checkParamIsNull(conn, "conn"); + Utils.checkParamIsNull(tableName, "tableName"); + Utils.checkParamIsNull(eventSchema, "eventSchema"); + conn_ = conn; + if (eventTimeFields == null) eventTimeFields = new List(); + if (commonFields == null) commonFields = new List(); + eventHandler_ = new EventHandler(eventSchema, eventTimeFields, commonFields); + if (tableName == "") + { + throw new Exception("tableName must not be empty."); + } + string sql = "select top 0 * from " + tableName; + BasicTable outputTable = (BasicTable)conn_.run(sql); + eventHandler_.checkOutputTable(outputTable, tableName); + insertScript_ = "tableInsert{" + tableName + "}"; + } + public void sendEvent(string eventType, List attributes) + { + Utils.checkParamIsNull(eventType, "eventType"); + Utils.checkParamIsNull(attributes, "attributes"); + List args = new List(); + eventHandler_.serializeEvent(eventType, attributes, args); + conn_.run(insertScript_, args); + } + + private string insertScript_; + private EventHandler eventHandler_; + private DBConnection conn_; + }; + +} diff --git a/test/DBConnection_test.cs b/test/DBConnection_test.cs index 024b484..3755042 100644 --- a/test/DBConnection_test.cs +++ b/test/DBConnection_test.cs @@ -1464,7 +1464,7 @@ public void Test_run_return_matrix_second() db.close(); } - [TestMethod]//APICS-338 + [TestMethod] public void Test_run_return_matrix_string() { DBConnection db = new DBConnection(); @@ -1482,9 +1482,224 @@ public void Test_run_return_matrix_string() Console.WriteLine(datatype.toString()); BasicStringMatrix matrixString1Res = (BasicStringMatrix)db.run("matrixString"); Assert.AreEqual(matrixString.getString(), matrixString1Res.getString()); + + IEntity matrixString1 = db.run("string(1..36)$6:6"); + Dictionary obj1 = new Dictionary(); + obj1.Add("matrixString", (IEntity)matrixString); + obj1.Add("matrixString1", (IEntity)matrixString1); + db.upload(obj1); + BasicStringMatrix matrixString1Res1 = (BasicStringMatrix)db.run("matrixString1"); + Assert.AreEqual(6, matrixString1.rows()); + Assert.AreEqual(6, matrixString1.columns()); + Assert.AreEqual(matrixString1.getString(), matrixString1Res1.getString()); + db.close(); + } + + [TestMethod] + public void Test_upload_matrix_string_1() + { + DBConnection db = new DBConnection(); + db.connect(SERVER, PORT); + IEntity matrixString = db.run("matrix(`STRING,1000,1000, ,\"NULL中国测试!@#$%^&*()_+{}:COUNT<>,.//;'|[]=-`~\\\\\");"); + Assert.IsTrue(matrixString.isMatrix()); + Assert.AreEqual(1000, matrixString.rows()); + Assert.AreEqual(1000, matrixString.columns()); + Dictionary obj = new Dictionary(); + obj.Add("matrixString", matrixString); + db.upload(obj); + BasicString datatype = (BasicString)db.run("typestr(matrixString)"); + Console.WriteLine(datatype.toString()); + BasicStringMatrix matrixString1Res = (BasicStringMatrix)db.run("matrixString"); + Assert.AreEqual(matrixString.getString(), matrixString1Res.getString()); db.close(); } + [TestMethod] + public void Test_run_return_matrix_decimal32() + { + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT); + BasicDecimal32Matrix matrix = (BasicDecimal32Matrix)conn.run("matrix(DECIMAL32(1),1,1, ,);"); + Assert.AreEqual(1, matrix.rows()); + Assert.AreEqual(1, matrix.columns()); + Assert.AreEqual("", matrix.get(0, 0).getString()); + + BasicDecimal32Matrix matrix1 = (BasicDecimal32Matrix)conn.run("decimal32(1..10$2:5,2)"); + Assert.AreEqual("#0 #1 #2 #3 #4 \n" + + "1.00 3.00 5.00 7.00 9.00 \n" + + "2.00 4.00 6.00 8.00 10.00\n", matrix1.getString()); + + BasicDecimal32Matrix matrix2 = (BasicDecimal32Matrix)conn.run("decimal32(-1.999999999 -1.0000001 0 1.999999999 1.01 0.1$3:2,9)"); + Assert.AreEqual(3, matrix2.rows()); + Assert.AreEqual(2, matrix2.columns()); + Assert.AreEqual("#0 #1 \n" + + "-1.999999999 1.999999999\n" + + "-1.000000100 1.010000000\n" + + "0.000000000 0.100000000\n", matrix2.getString()); + BasicDecimal32Matrix matrix3 = (BasicDecimal32Matrix)conn.run("decimal32(cross(add,1 2,3 4),2)"); + Assert.AreEqual(2, matrix3.rows()); + Assert.AreEqual(2, matrix3.columns()); + Assert.AreEqual("1", matrix3.getRowLabel(0).getString()); + Assert.AreEqual("4.00", matrix3.get(0, 0).getString()); + } + + [TestMethod] + public void Test_run_return_matrix_decimal64() + { + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT); + BasicDecimal64Matrix matrix = (BasicDecimal64Matrix)conn.run("matrix(DECIMAL64(1),1,1, ,);"); + Assert.AreEqual(1, matrix.rows()); + Assert.AreEqual(1, matrix.columns()); + Assert.AreEqual("", matrix.get(0, 0).getString()); + + BasicDecimal64Matrix matrix1 = (BasicDecimal64Matrix)conn.run("decimal64(1..10$2:5,2)"); + Assert.AreEqual("#0 #1 #2 #3 #4 \n" + + "1.00 3.00 5.00 7.00 9.00 \n" + + "2.00 4.00 6.00 8.00 10.00\n", matrix1.getString()); + + BasicDecimal64Matrix matrix2 = (BasicDecimal64Matrix)conn.run("decimal64(-1.99999999999999999 -1.00000001 0 1.99999999999999999 1.01 0.1$3:2,18)"); + Assert.AreEqual(3, matrix2.rows()); + Assert.AreEqual(2, matrix2.columns()); + Console.WriteLine(matrix2.getString()); + Assert.AreEqual("#0 #1 \n" + + "-2.000000000000000000 2.000000000000000000\n" + + "-1.000000010000000000 1.010000000000000000\n" + + "0.000000000000000000 0.100000000000000000\n", matrix2.getString()); + BasicDecimal64Matrix matrix3 = (BasicDecimal64Matrix)conn.run("decimal64(cross(add,1 2,3 4),2)"); + Assert.AreEqual(2, matrix3.rows()); + Assert.AreEqual(2, matrix3.columns()); + Assert.AreEqual("1", matrix3.getRowLabel(0).getString()); + Assert.AreEqual("4.00", matrix3.get(0, 0).getString()); + } + + [TestMethod] + public void Test_run_return_matrix_decimal128() + { + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT); + BasicDecimal128Matrix matrix = (BasicDecimal128Matrix)conn.run("matrix(DECIMAL128(1),1,1, ,);"); + Assert.AreEqual(1, matrix.rows()); + Assert.AreEqual(1, matrix.columns()); + Assert.AreEqual("", matrix.get(0, 0).getString()); + + BasicDecimal128Matrix matrix1 = (BasicDecimal128Matrix)conn.run("decimal128(1..10$2:5,2)"); + Assert.AreEqual("#0 #1 #2 #3 #4 \n" + + "1.00 3.00 5.00 7.00 9.00 \n" + + "2.00 4.00 6.00 8.00 10.00\n", matrix1.getString()); + + BasicDecimal128Matrix matrix2 = (BasicDecimal128Matrix)conn.run("decimal128(-1.99999999999999999 -1.00000001 0 1.99999999999999999 1.01 0.1$3:2,37)"); + Assert.AreEqual(3, matrix2.rows()); + Assert.AreEqual(2, matrix2.columns()); + Console.WriteLine(matrix2.getString()); + Assert.AreEqual("#0 #1 \n" + + "-2.0000000000000000000000000000000000000 2.0000000000000000000000000000000000000\n" + + "-1.0000000099999998682326038754967420928 1.0099999999999999498732536162620014592\n" + + "0.0000000000000000000000000000000000000 0.1000000000000000042420637374017961984\n", matrix2.getString()); + BasicDecimal128Matrix matrix3 = (BasicDecimal128Matrix)conn.run("decimal128(cross(add,1 2,3 4),2)"); + Assert.AreEqual(2, matrix3.rows()); + Assert.AreEqual(2, matrix3.columns()); + Assert.AreEqual("1", matrix3.getRowLabel(0).getString()); + Assert.AreEqual("4.00", matrix3.get(0, 0).getString()); + } + + [TestMethod] + public void Test_upload_matrix_decimal32() + { + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT); + Dictionary map = new Dictionary(); + IEntity decimal32matrix = conn.run("decimal32(-1.999999999 -1.0000001 0 1.999999999 1.01 0.1$3:2,9)"); + map.Add("decimal32matrix", decimal32matrix); + conn.upload(map); + IEntity decimal32matrixRes = conn.run("decimal32matrix"); + Assert.AreEqual(3, decimal32matrixRes.rows()); + Assert.AreEqual(2, decimal32matrixRes.columns()); + Assert.AreEqual(decimal32matrix.getString(), decimal32matrixRes.getString()); + + List list = new List(); + list.Add(new String[] { "999999999", "0", "-999999999" }); + list.Add(new String[] { "999999999", "999999999", "999999999" }); + list.Add(new String[] { "-999999999", "-999999999", "-999999999" }); + BasicDecimal32Matrix decimal32matrix1 = new BasicDecimal32Matrix(3, 3, list, 0); + map.Add("decimal32matrix1", decimal32matrix1); + conn.upload(map); + IEntity decimal32matrix1Res = conn.run("decimal32matrix1"); + Assert.AreEqual(decimal32matrix1.getString(), decimal32matrix1Res.getString()); + + BasicDecimal32Matrix decimal32matrix2 = new BasicDecimal32Matrix(0, 0, 0); + map.Add("decimal32matrix2", decimal32matrix2); + conn.upload(map); + IEntity decimal32matrix2Res = conn.run("decimal32matrix2"); + Assert.AreEqual(decimal32matrix2.getString(), decimal32matrix2Res.getString()); + Assert.AreEqual("\n", decimal32matrix2Res.getString()); + } + + [TestMethod] + public void Test_upload_matrix_decimal64() + { + + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT); + Dictionary map = new Dictionary(); + IEntity decimal64matrix = conn.run("decimal64(-1.99999999999999999 -1.00000001 0 1.99999999999999999 1.01 0.1$3:2,18)"); + map.Add("decimal64matrix", decimal64matrix); + conn.upload(map); + IEntity decimal64matrixRes = conn.run("decimal64matrix"); + Assert.AreEqual(3, decimal64matrixRes.rows()); + Assert.AreEqual(2, decimal64matrixRes.columns()); + Assert.AreEqual(decimal64matrix.getString(), decimal64matrixRes.getString()); + + List list = new List(); + list.Add(new String[] { "999999999999999999", "0", "-999999999999999999" }); + list.Add(new String[] { "999999999999999999", "9.99999999999999999", "9999.99999999999999" }); + list.Add(new String[] { "-9.999999999999999999", "-9.99999999999999999", "-9999.99999999999999" }); + BasicDecimal64Matrix decimal64matrix1 = new BasicDecimal64Matrix(3, 3, list, 0); + map.Add("decimal64matrix1", decimal64matrix1); + conn.upload(map); + IEntity decimal64matrix1Res = conn.run("decimal64matrix1"); + Assert.AreEqual(decimal64matrix1.getString(), decimal64matrix1Res.getString()); + + BasicDecimal64Matrix decimal64matrix2 = new BasicDecimal64Matrix(0, 0, 0); + map.Add("decimal64matrix2", decimal64matrix2); + conn.upload(map); + IEntity decimal64matrix2Res = conn.run("decimal64matrix2"); + Assert.AreEqual(decimal64matrix2.getString(), decimal64matrix2Res.getString()); + Assert.AreEqual("\n", decimal64matrix2Res.getString()); + } + + [TestMethod] + public void Test_upload_matrix_decimal128() + { + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT); + Dictionary map = new Dictionary(); + IEntity decimal128matrix = conn.run("decimal128(-1.99999999999999999 -1.00000001 0 1.99999999999999999 1.01 0.1$3:2,37)"); + map.Add("decimal128matrix", decimal128matrix); + conn.upload(map); + IEntity decimal128matrixRes = conn.run("decimal128matrix"); + Assert.AreEqual(3, decimal128matrixRes.rows()); + Assert.AreEqual(2, decimal128matrixRes.columns()); + Assert.AreEqual(decimal128matrix.getString(), decimal128matrixRes.getString()); + + List list = new List(); + list.Add(new String[] { "9999999999999999999.9999999999999999999", "0", "-9999999999999999999" }); + list.Add(new String[] { "9999999999999999999.0000000000000000009", "9999999999999999999", "9999999999999999999" }); + list.Add(new String[] { "-9999999999999999999.0000000000000000009", "-9999999999999999999", "-9999999999999999999" }); + BasicDecimal128Matrix decimal128matrix1 = new BasicDecimal128Matrix(3, 3, list, 0); + map.Add("decimal128matrix1", decimal128matrix1); + conn.upload(map); + IEntity decimal128matrix1Res = conn.run("decimal128matrix1"); + Assert.AreEqual(decimal128matrix1.getString(), decimal128matrix1Res.getString()); + + BasicDecimal128Matrix decimal128matrix2 = new BasicDecimal128Matrix(0, 0, 0); + map.Add("decimal128matrix2", decimal128matrix2); + conn.upload(map); + IEntity decimal128matrix2Res = conn.run("decimal128matrix2"); + Assert.AreEqual(decimal128matrix2.getString(), decimal128matrix2Res.getString()); + Assert.AreEqual("\n", decimal128matrix2Res.getString()); + } + [TestMethod] public void Test_run_return_table_int() { @@ -3544,18 +3759,19 @@ public void Test_sqlList_parallelism() connection1.run(scripts,false); List sqlList1 = new List() { "select sum(impl_fwd), * from loadTable(\"dfs://test1\", \"pt\") where instr='OPT_XSHG_510050' and snapshot_config = 'snap_sz1_0930_1457_5s' and impl_fwd_disc_config = 'fwd_synth_order_match' and impl_vol_model_config = 'spline_gd_dof10.0' and snapshot_ts = timestamp('2022.08.03T09:30:05.000000'); " }; - List sqlList2 = new List() { "t = select * from loadTable(\"dfs://test\",\"pt\")", "loop(max, t.values()); " }; + // List sqlList2 = new List() { "t = select * from loadTable(\"dfs://test1\",\"pt\")", "loop(max, t.values()); " }; + List sqlList2 = new List() { "t = select * from loadTable(\"dfs://test11\",\"t1\")", "loop(max, t.values()); " }; + List sqlList3 = new List() { "t = select id, max(v) from loadTable(\"dfs://test11\", \"t1\") group by id;" }; - List entities1 = connection1.run(sqlList1, 4, 64); + List entities1 = connection1.run(sqlList3, 4, 1); foreach (IEntity entity in entities1) { Console.Out.WriteLine(entity.getString()); entity.getString(); } connection1.close(); - - } + [TestMethod] public void Test_sqlList_parallelism_65() { diff --git a/test/ExclusiveDBConnectionPool_test.cs b/test/ExclusiveDBConnectionPool_test.cs index c53be76..639182b 100644 --- a/test/ExclusiveDBConnectionPool_test.cs +++ b/test/ExclusiveDBConnectionPool_test.cs @@ -491,7 +491,7 @@ public void Test_ExclusiveDBConnectionPool_usePython_false() pool.run(script1); pool.shutdown(); } - catch (IOException ex) + catch (Exception ex) { string s = ex.Message; Assert.AreEqual(s, "Syntax Error: [line #1] Cannot recognize the token import"); diff --git a/test/Utils_test.cs b/test/Utils_test.cs index b03f352..7c19fb2 100644 --- a/test/Utils_test.cs +++ b/test/Utils_test.cs @@ -82,39 +82,6 @@ public void Test_RSAUtil_GetCode() //int a = 1; //} - [TestMethod] - public void Test_RSAUtil_ReadASNLength() - { - string filePath = "data.bin"; - - // 数据 - int intValue = 42; - float floatValue = 3.14f; - string stringValue = "Hello, Binary World!"; - - // 创建二进制文件流 - FileStream fileStream = new FileStream(filePath, FileMode.Create); - { - // 创建BinaryWriter对象 - BinaryWriter writer = new BinaryWriter(fileStream); - { - // 写入整数 - writer.Write(intValue); - - // 写入浮点数 - writer.Write(floatValue); - - // 写入字符串 - writer.Write(stringValue); - } - } - - Console.WriteLine("数据已成功写入二进制文件:" + filePath); - BinaryReader reader = new BinaryReader(fileStream) ; - int t = RSAUtils.ReadASNLength(reader) ; - Console.WriteLine(t); - } - [TestMethod] public void Test_RSAUtil_ReadASNLength_1() { diff --git a/test/compatibility_test/DBConnection_test.cs b/test/compatibility_test/DBConnection_test.cs index dbed073..b2f1380 100644 --- a/test/compatibility_test/DBConnection_test.cs +++ b/test/compatibility_test/DBConnection_test.cs @@ -3335,6 +3335,7 @@ public void Test_DBConnection_tryRun_function() DBConnection db = new DBConnection(); db.connect(SERVER, PORT); IList arg = new List(); + arg.Add(db.run("1")); db.tryRun("sleep", arg); db.close(); } diff --git a/test/compatibility_test/ExclusiveDBConnectionPool_test.cs b/test/compatibility_test/ExclusiveDBConnectionPool_test.cs index 3fc2962..afd0280 100644 --- a/test/compatibility_test/ExclusiveDBConnectionPool_test.cs +++ b/test/compatibility_test/ExclusiveDBConnectionPool_test.cs @@ -276,21 +276,6 @@ public void Test_ExclusiveDBConnectionPool_error() Assert.IsNotNull(exception); } - [TestMethod] - public void Test_ExclusiveDBConnectionPool_haSites() - { - conn = new DBConnection(); - pool = new ExclusiveDBConnectionPool("www", PORT, USER, PASSWORD, 10, true, true, HASTREAM_GROUP); - Assert.AreEqual(10, pool.getConnectionCount()); - } - - [TestMethod] - public void Test_ExclusiveDBConnectionPool_haSite11s() - { - pool = new ExclusiveDBConnectionPool("192.168.1.167", PORT, USER, PASSWORD, 10, true, true, HASTREAM_GROUP); - Assert.AreEqual(10, pool.getConnectionCount()); - } - [TestMethod] public void Test_ExclusiveDBConnectionPool_startup_error() { diff --git a/test/compatibility_test/data_test/AbstractTest.cs b/test/compatibility_test/data_test/AbstractTest.cs index 956f8c9..beb3d9b 100644 --- a/test/compatibility_test/data_test/AbstractTest.cs +++ b/test/compatibility_test/data_test/AbstractTest.cs @@ -125,7 +125,7 @@ public override void setObject(object value) throw new NotImplementedException(); } - protected override void writeScalarToOutputStream(ExtendedDataOutput @out) + public override void writeScalarToOutputStream(ExtendedDataOutput @out) { throw new NotImplementedException(); } diff --git a/test/compatibility_test/data_test/BasicVectorTest.cs b/test/compatibility_test/data_test/BasicVectorTest.cs index 92d6c1a..b5ec91d 100644 --- a/test/compatibility_test/data_test/BasicVectorTest.cs +++ b/test/compatibility_test/data_test/BasicVectorTest.cs @@ -716,7 +716,6 @@ public void Test_BasicMinuteVector() public void Test_BasicMinuteVector_set_data_error() { BasicMinuteVector blv = new BasicMinuteVector(1); - String re = null; blv.set(0, "wesdsd"); Assert.AreEqual(TimeSpan.MinValue, blv.getMinute(0)); diff --git a/test/compatibility_test/route_test/BatchTableWriter_test.cs b/test/compatibility_test/route_test/BatchTableWriter_test.cs index c1c1148..11c54ca 100644 --- a/test/compatibility_test/route_test/BatchTableWriter_test.cs +++ b/test/compatibility_test/route_test/BatchTableWriter_test.cs @@ -1348,15 +1348,15 @@ public void Test_BatchTableWriter_addTable() { DBConnection conn = new DBConnection(); conn.connect(SERVER, PORT, USER, PASSWORD); - conn.run("if(existsDatabase(\"dfs://dataXdemo\")){dropDatabase(\"dfs://dataXdemo\")}\n" + - "db = database(\"dfs://dataXdemo\", VALUE, 1..10)\n" + + conn.run("if(existsDatabase(\"dfs://dataXdemo1\")){dropDatabase(\"dfs://dataXdemo1\")}\n" + + "db = database(\"dfs://dataXdemo1\", VALUE, 1..10)\n" + "t = table(take(1..10, 100) as id, take([`A, `B, `C], 100) as sym, 1..100 as qty, 100..1 as price)\n" + "pt = db.createPartitionedTable(t, `pt, `id).append!(t)"); BatchTableWriter btw1 = new BatchTableWriter(SERVER, PORT, USER, PASSWORD); - btw1.addTable("dfs://dataXdemo", "pt", true); + btw1.addTable("dfs://dataXdemo1", "pt", true); try { - btw1.addTable("dfs://dataXdemo", "pt", true); + btw1.addTable("dfs://dataXdemo1", "pt", true); } catch(Exception e) { @@ -1364,10 +1364,10 @@ public void Test_BatchTableWriter_addTable() Console.WriteLine(e.Message); } - BatchTableWriter btw2 = new BatchTableWriter("192.168.1.116", 51872, USER, PASSWORD); + BatchTableWriter btw2 = new BatchTableWriter(SERVER, 12112, USER, PASSWORD); try { - btw2.addTable("dfs://dataXdemo", "pt", true); + btw2.addTable("dfs://dataXdemo1", "pt", true); } catch(Exception e) { @@ -1378,7 +1378,7 @@ public void Test_BatchTableWriter_addTable() BatchTableWriter btw3 = new BatchTableWriter(SERVER, PORT, USER, PASSWORD); try { - btw3.addTable("dfs://dataXdemo", "pt", false); + btw3.addTable("dfs://dataXdemo1", "pt", false); }catch(Exception e) { Console.WriteLine(e.Message); diff --git a/test/compatibility_test/route_test/PartitionedTableAppender_test.cs b/test/compatibility_test/route_test/PartitionedTableAppender_test.cs index bee13cd..464e26f 100644 --- a/test/compatibility_test/route_test/PartitionedTableAppender_test.cs +++ b/test/compatibility_test/route_test/PartitionedTableAppender_test.cs @@ -183,7 +183,7 @@ public void Test_PartitionedTableAppender_allDataType_null() DBConnection conn = new DBConnection(); conn.connect(SERVER, PORT, "admin", "123456"); var cols = new List() { }; - var colNames = new List() { "intv", "boolv", "charv", "shortv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "symbolv", "stringv", "uuidv", "datehourv", "ippaddrv", "int128v", "blobv" }; + var colNames = new List() { "intv", "boolv", "charv", "shortv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "symbolv", "stringv", "uuidv", "datehourv", "ippaddrv", "int128v" }; int rowNum = 0; cols.Add(new BasicIntVector(rowNum)); cols.Add(new BasicBooleanVector(rowNum)); @@ -315,7 +315,7 @@ public void Test_PartitionedTableAppender_columnType_not_match() { re = ex.Message; } - Assert.AreEqual("The input table doesn't match the schema of the target table.", re); + Assert.AreEqual("the size of colNames must be equal than cols", re); pool.shutdown(); } diff --git a/test/compatibility_test/route_test/autoFitTableUpsert_test.cs b/test/compatibility_test/route_test/autoFitTableUpsert_test.cs index 1b91053..7b5e7e1 100644 --- a/test/compatibility_test/route_test/autoFitTableUpsert_test.cs +++ b/test/compatibility_test/route_test/autoFitTableUpsert_test.cs @@ -196,10 +196,9 @@ public void Test_autoFitTableUpsert_indexedTable_allDateType_insert() script += "cstring = \"hello\" \"hi\" \"here\";\n"; script += "cdatehour = datehour(2012.06.15 15:32:10.158 2012.06.15 17:30:10.008 2014.09.29 23:55:42.693);\n"; script += "try{\n undef(`t,SHARED)\n }catch(ex){\n };\n"; - script += "t = indexedTable(`cint,cbool,cchar,cshort,cint,clong,cdate,cmonth,ctime,cminute,"; + script += "share indexedTable(`cint,cbool,cchar,cshort,cint,clong,cdate,cmonth,ctime,cminute,"; script += "csecond,cdatetime,ctimestamp,cnanotime,cnanotimestamp,cfloat,cdouble,"; - script += "cstring,cdatehour);"; - script += "share t as st;"; + script += "cstring,cdatehour) as st;;\n"; conn.run(script); BasicTable bt = (BasicTable)conn.run("table(true as cbool,'d' as cchar,86h as cshort,10 as cint,726l as clong,2021.09.23 as cdate,2021.10M as cmonth,14:55:26.903 as ctime,15:27m as cminute,14:27:35 as csecond,2018.11.11 11:11:11 as cdatetime,2010.09.29 11:35:47.295 as ctimestamp,12:25:45.284729843 as cnanotime,2018.09.15 15:32:32.734728902 as cnanotimestamp,5.7f as cfloat,0.86 as cdouble,\"single\" as cstring,datehour(2022.08.23 17:33:54.324) as cdatehour)"); AutoFitTableUpsert aftu = new AutoFitTableUpsert("", "st", conn, false, null, null); diff --git a/test/data_test/AbstractTest.cs b/test/data_test/AbstractTest.cs index 6a9a349..67b78fc 100644 --- a/test/data_test/AbstractTest.cs +++ b/test/data_test/AbstractTest.cs @@ -155,18 +155,18 @@ public void test_AbstractMatrix() bm.setColumnLabels(bsyv); Assert.AreEqual("a", bm.getColumnLabel(0).getString()); Assert.AreEqual("[a,b,c]", bm.getColumnLabels().getString()); - Exception exception = null; + String re = null; try { bm.getObject(); } catch (Exception e) { - exception = e; + re = e.Message; } - Assert.AreEqual("The method or operation is not implemented.", exception.Message); + Assert.AreEqual(true, re.Contains("The method or operation is not implemented.") || re.Contains("未实现该方法或操作。")); - BasicMatrix bm1 = new BasicMatrix(1, 1); + BasicMatrix bm1 = new BasicMatrix(1, 1); Exception exception1 = null; try { @@ -212,99 +212,97 @@ public void test_AbstractMatrix_write() public void test_AbstractScalar() { BasicScalar bm = new BasicScalar(2); - Exception exception = null; + String re = null; try { bm.isNull(); } catch (Exception e) { - exception = e; + re = e.Message; } - Assert.AreEqual("The method or operation is not implemented.", exception.Message); - Exception exception1 = null; + Assert.AreEqual(true, re.Contains("The method or operation is not implemented.") || re.Contains("未实现该方法或操作。")); + String re1 = null; try { bm.setNull(); } catch (Exception e) { - exception1 = e; + re1 = e.Message; } - Assert.AreEqual("The method or operation is not implemented.", exception1.Message); - Exception exception2 = null; - try - { + Assert.AreEqual(true, re1.Contains("The method or operation is not implemented.") || re1.Contains("未实现该方法或操作。")); + String re2 = null; + try + { bm.getNumber(); } catch (Exception e) { - exception2 = e; - } - Assert.AreEqual("The method or operation is not implemented.", exception2.Message); - Exception exception3 = null; + re2 = e.Message; + } + Assert.AreEqual(true, re2.Contains("The method or operation is not implemented.") || re2.Contains("未实现该方法或操作。")); + String re3 = null; try { bm.getTemporal(); } catch (Exception e) { - exception3 = e; - } - Assert.AreEqual("The method or operation is not implemented.", exception3.Message); - Exception exception4 = null; - try - { + re3 = e.Message; + } + Assert.AreEqual(true, re3.Contains("The method or operation is not implemented.") || re3.Contains("未实现该方法或操作。")); + String re4 = null; + try + { bm.getDataCategory(); } catch (Exception e) { - exception4 = e; - } - Assert.AreEqual("The method or operation is not implemented.", exception4.Message); - Exception exception5 = null; - try - { + re4 = e.Message; + } + Assert.AreEqual(true, re4.Contains("The method or operation is not implemented.") || re4.Contains("未实现该方法或操作。")); + String re5 = null; + try + { bm.getDataType(); } catch (Exception e) { - exception5 = e; - } - Assert.AreEqual("The method or operation is not implemented.", exception5.Message); - Exception exception6 = null; - try - { + re5 = e.Message; + } + Assert.AreEqual(true, re5.Contains("The method or operation is not implemented.") || re5.Contains("未实现该方法或操作。")); + String re6 = null; + try + { bm.toDataTable(); } catch (Exception e) { - exception6 = e; - } - Assert.AreEqual("The scalar can not be convert to datatable", exception6.Message); - Exception exception7 = null; - try - { + re6 = e.Message; + } + Assert.AreEqual("The scalar can not be convert to datatable", re6); + String re7 = null; + try + { bm.getScale(); } catch (Exception e) { - exception7 = e; - } - Assert.AreEqual("The method or operation is not implemented.", exception7.Message); - Exception exception8 = null; - try - { + re7 = e.Message; + } + Assert.AreEqual(true, re7.Contains("The method or operation is not implemented.") || re7.Contains("未实现该方法或操作。")); + String re8 = null; + try + { bm.toString(); } catch (Exception e) { - exception8 = e; - } - Assert.AreEqual("The method or operation is not implemented.", exception8.Message); - Assert.AreEqual(1, bm.columns()); + re8 = e.Message; + } + Assert.AreEqual(true, re8.Contains("The method or operation is not implemented.") || re8.Contains("未实现该方法或操作。")); + Assert.AreEqual(1, bm.columns()); } - - } } diff --git a/test/data_test/BasicDictionaryTest.cs b/test/data_test/BasicDictionaryTest.cs index fa866aa..1ad168f 100644 --- a/test/data_test/BasicDictionaryTest.cs +++ b/test/data_test/BasicDictionaryTest.cs @@ -149,7 +149,7 @@ public void Test_BasicDictionary_writeCompressed() { BasicDictionary sc1 = new BasicDictionary(DATA_TYPE.DT_INT, DATA_TYPE.DT_DICTIONARY); @out = null; - Exception ex1 = null; + String re = null; try { sc1.writeCompressed(@out); @@ -157,16 +157,16 @@ public void Test_BasicDictionary_writeCompressed() } catch (Exception e) { - ex1 = e; + re = e.Message; } - Assert.AreEqual("The method or operation is not implemented.", ex1.Message); + Assert.AreEqual(true, re.Contains("The method or operation is not implemented.") || re.Contains("未实现该方法或操作。")); } [TestMethod] public void Test_BasicDictionary_getString() { BasicDictionary sc1 = new BasicDictionary(DATA_TYPE.DT_INT, DATA_TYPE.DT_INT); Console.Out.WriteLine(sc1.put((IScalar)conn.run("1"), (BasicInt)conn.run("1"))); - Exception ex1 = null; + String re = null; try { sc1.getString(); @@ -174,9 +174,9 @@ public void Test_BasicDictionary_getString() } catch (Exception e) { - ex1 = e; + re = e.Message; } - Assert.AreEqual("The method or operation is not implemented.",ex1.Message); + Assert.AreEqual(true, re.Contains("The method or operation is not implemented.") || re.Contains("未实现该方法或操作。")); } [TestMethod] @@ -184,7 +184,7 @@ public void Test_BasicDictionary_getObject() { BasicDictionary sc1 = new BasicDictionary(DATA_TYPE.DT_INT, DATA_TYPE.DT_INT); Console.Out.WriteLine(sc1.put((IScalar)conn.run("1"), (BasicInt)conn.run("1"))); - Exception ex1 = null; + String re = null; try { sc1.getObject(); @@ -192,9 +192,9 @@ public void Test_BasicDictionary_getObject() } catch (Exception e) { - ex1 = e; + re = e.Message; } - Assert.AreEqual("The method or operation is not implemented.", ex1.Message); + Assert.AreEqual(true, re.Contains("The method or operation is not implemented.") || re.Contains("未实现该方法或操作。")); } } } diff --git a/test/data_test/BasicMatrixTest.cs b/test/data_test/BasicMatrixTest.cs index a89a471..fdf7622 100644 --- a/test/data_test/BasicMatrixTest.cs +++ b/test/data_test/BasicMatrixTest.cs @@ -630,7 +630,7 @@ public void Test_BasicStringMatrix() Assert.IsNotNull(ex); Assert.AreEqual("LITERAL", bcv.getDataCategory().ToString()); - Assert.AreEqual("DT_SYMBOL", bcv.getDataType().ToString()); + Assert.AreEqual("DT_STRING", bcv.getDataType().ToString()); Assert.AreEqual("dolphindb.data.BasicString", bcv.getElementClass().ToString()); } @@ -919,5 +919,1124 @@ public void Test_BasicStringMatrix_Remain() Console.WriteLine(e.Message); } } + [TestMethod] + public void test_BasicDecimal32Matrix() + { + BasicDecimal32Matrix re1 = new BasicDecimal32Matrix(0, 0, 0); + Console.WriteLine(re1.getString()); + Assert.AreEqual("\n", re1.getString()); + Assert.AreEqual(DATA_CATEGORY.DENARY, re1.getDataCategory()); + Assert.AreEqual("dolphindb.data.BasicDecimal32", re1.getElementClass().ToString()); + Assert.AreEqual(DATA_TYPE.DT_DECIMAL32, re1.getDataType()); + + BasicDecimal32Matrix re2 = new BasicDecimal32Matrix(3, 4, 0); + Console.WriteLine(re2.getString()); + Assert.AreEqual("#0 #1 #2 #3\n" + + "0 0 0 0 \n" + + "0 0 0 0 \n" + + "0 0 0 0 \n", re2.getString()); + + IList list = new List(); + list.Add(new decimal[] { 1, 2, 3 }); + list.Add(new decimal[] { 4, 5, 6 }); + BasicDecimal32Matrix re3 = new BasicDecimal32Matrix(3, 2, list, 2); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 #1 \n" + + "1.00 4.00\n" + + "2.00 5.00\n" + + "3.00 6.00\n", re3.getString()); + IList list1 = new List(); + list1.Add(new String[] { "1", "2", "3" }); + list1.Add(new String[] { "4", "5", "6" }); + BasicDecimal32Matrix re4 = new BasicDecimal32Matrix(3, 2, list1, 2); + Console.WriteLine(re4.getString()); + Assert.AreEqual("#0 #1 \n" + + "1.00 4.00\n" + + "2.00 5.00\n" + + "3.00 6.00\n", re4.getString()); + String exception = null; + try + { + BasicDecimal32Matrix re5 = new BasicDecimal32Matrix(4, 2, list, 2); + } + catch (Exception ex) + { + exception = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception); + String exception1 = null; + try + { + BasicDecimal32Matrix re6 = new BasicDecimal32Matrix(3, 3, list, 2); + } + catch (Exception ex) + { + exception1 = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception1); + + String exception2 = null; + try + { + BasicDecimal32Matrix re7 = new BasicDecimal32Matrix(4, 2, list1, 2); + } + catch (Exception ex) + { + exception2 = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception2); + + String exception3 = null; + try + { + BasicDecimal32Matrix re8 = new BasicDecimal32Matrix(3, 3, list1, 2); + } + catch (Exception ex) + { + exception3 = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception3); + } + + [TestMethod] + public void test_BasicDecimal32Matrix_scale_not_true() + { + IList list = new List(); + list.Add(new decimal[] { 999999999, 0, -999999999 }); + list.Add(new decimal[] { 999999999, 999999999, 999999999 }); + list.Add(new decimal[] { -999999999, -999999999, -999999999 }); + String exception = null; + try + { + BasicDecimal32Matrix re3 = new BasicDecimal32Matrix(3, 3, list, -1); + } + catch (Exception ex) + { + exception = ex.Message; + } + Assert.AreEqual("Scale -1 is out of bounds, it must be in [0,9].", exception); + String exception1 = null; + try + { + BasicDecimal32Matrix re3 = new BasicDecimal32Matrix(3, 3, list, 10); + } + catch (Exception ex) + { + exception1 = ex.Message; + } + Assert.AreEqual("Scale 10 is out of bounds, it must be in [0,9].", exception1); + + List list1 = new List(); + list1.Add(new String[] { "999999999", "0", "-999999999" }); + list1.Add(new String[] { "999999999", "999999999", "999999999" }); + list1.Add(new String[] { "-999999999", "-999999999", "-999999999" }); + String exception2 = null; + try + { + BasicDecimal32Matrix re3 = new BasicDecimal32Matrix(3, 3, list1, -1); + } + catch (Exception ex) + { + exception2 = ex.Message; + } + Assert.AreEqual("Scale -1 is out of bounds, it must be in [0,9].", exception2); + String exception3 = null; + try + { + BasicDecimal32Matrix re3 = new BasicDecimal32Matrix(3, 3, list1, 10); + } + catch (Exception ex) + { + exception3 = ex.Message; + } + Assert.AreEqual("Scale 10 is out of bounds, it must be in [0,9].", exception3); + } + [TestMethod] + public void test_BasicDecimal32Matrix_decimal() + { + IList list = new List(); + list.Add(new decimal[] { 999999999, 0, -999999999 }); + list.Add(new decimal[] { 999999999, 999999999, 999999999 }); + list.Add(new decimal[] { -999999999, -999999999, -999999999 }); + BasicDecimal32Matrix re1 = new BasicDecimal32Matrix(3, 3, list, 0); + Console.WriteLine(re1.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "999999999 999999999 -999999999\n" + + "0 999999999 -999999999\n" + + "-999999999 999999999 -999999999\n", re1.getString()); + + List list1 = new List(); + list1.Add(new decimal[] { 99999, 0, -99999 }); + list1.Add(new decimal[] { 99999, 99999, 99999 }); + list1.Add(new decimal[] { -99999, -99999, -1999 }); + BasicDecimal32Matrix re2 = new BasicDecimal32Matrix(3, 3, list1, 4); + Console.WriteLine(re2.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "99999.0000 99999.0000 -99999.0000\n" + + "0.0000 99999.0000 -99999.0000\n" + + "-99999.0000 99999.0000 -1999.0000 \n", re2.getString()); + + List list2 = new List(); + list2.Add(new decimal[] { 1, 0, -1 }); + BasicDecimal32Matrix re3 = new BasicDecimal32Matrix(3, 1, list2, 9); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 \n" + + "1.000000000 \n" + + "0.000000000 \n" + + "-1.000000000\n", re3.getString()); + } + [TestMethod] + public void test_BasicDecimal32Matrix_string() + { + IList list = new List(); + list.Add(new String[] { "999999999", "0", "-999999999" }); + list.Add(new String[] { "999999999", "999999999", "999999999" }); + list.Add(new String[] { "-999999999", "-999999999", "-999999999" }); + BasicDecimal32Matrix re1 = new BasicDecimal32Matrix(3, 3, list, 0); + Console.WriteLine(re1.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "999999999 999999999 -999999999\n" + + "0 999999999 -999999999\n" + + "-999999999 999999999 -999999999\n", re1.getString()); + List list1 = new List(); + list1.Add(new String[] { "99999", "0", "-99999" }); + list1.Add(new String[] { "99999", "99999", "99999" }); + list1.Add(new String[] { "-99999", "-99999", "-1999" }); + BasicDecimal32Matrix re2 = new BasicDecimal32Matrix(3, 3, list1, 4); + Console.WriteLine(re2.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "99999.0000 99999.0000 -99999.0000\n" + + "0.0000 99999.0000 -99999.0000\n" + + "-99999.0000 99999.0000 -1999.0000 \n", re2.getString()); + + List list2 = new List(); + list2.Add(new String[] { "1", "0", "-1" }); + BasicDecimal32Matrix re3 = new BasicDecimal32Matrix(3, 1, list2, 9); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 \n" + + "1.000000000 \n" + + "0.000000000 \n" + + "-1.000000000\n", re3.getString()); + List list3 = new List(); + list3.Add(new String[] { "-1.9999", "0", "-1.00000009", "-1.999999999999" }); + list3.Add(new String[] { "1.9999", "0", "1.00000009", "1.999999999999" }); + list3.Add(new String[] { "-0.9999", "0.01", "-0.00000009", "-0.999999999999" }); + list3.Add(new String[] { "0.9999", "-0.001", "0.00000009", "0.999999999999" }); + BasicDecimal32Matrix re4 = new BasicDecimal32Matrix(4, 4, list3, 9); + Console.WriteLine(re4.getString()); + Assert.AreEqual("#0 #1 #2 #3 \n" + + "-1.999900000 1.999900000 -0.999900000 0.999900000 \n" + + "0.000000000 0.000000000 0.010000000 -0.001000000\n" + + "-1.000000090 1.000000090 -0.000000090 0.000000090 \n" + + "-2.000000000 2.000000000 -1.000000000 1.000000000 \n", re4.getString()); + + List list4 = new List(); + list4.Add(new String[] { "0.49", "-123.44", "132.50", "-0.51" }); + BasicDecimal32Matrix re5 = new BasicDecimal32Matrix(4, 1, list4, 0); + Console.WriteLine(re5.getString()); + Assert.AreEqual("#0 \n" + + "0 \n" + + "-123\n" + + "133 \n" + + "-1 \n", re5.getString()); + } + + [TestMethod] + public void test_BasicDecimal32Matrix_setNull() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal32Matrix re1 = new BasicDecimal32Matrix(3, 1, list, 0); + Assert.AreEqual(false, re1.isNull(0, 0)); + re1.setNull(0, 0); + Assert.AreEqual(true, re1.isNull(0, 0)); + Assert.AreEqual("#0 \n" + + " \n" + + "0 \n" + + "-111\n", re1.getString()); + } + + [TestMethod] + public void test_BasicDecimal32Matrix_setDecimal() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal32Matrix re1 = new BasicDecimal32Matrix(2, 2, 0); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(1, 1).getString()); + re1.setDecimal(0, 0, 1.999990m); + re1.setDecimal(0, 1, -0.99999999m); + re1.setDecimal(1, 0, 999.9999999m); + re1.setDecimal(1, 1, -999.99999m); + Assert.AreEqual("#0 #1 \n" + + "2 -1 \n" + + "1000 -1000\n", re1.getString()); + BasicDecimal32Matrix re2 = new BasicDecimal32Matrix(2, 2, 6); + re2.setDecimal(0, 0, 1.999990m); + re2.setDecimal(0, 1, -0.99999999m); + re2.setDecimal(1, 0, 999.9999999m); + re2.setDecimal(1, 1, -999.99999m); + Console.WriteLine(re2.getString()); + Assert.AreEqual(6, re2.getScale()); + Assert.AreEqual(new BasicDecimal32("1.999990", 6).getString(), re2.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal32("-1.000000", 6).getString(), re2.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal32("1000.000000", 6).getString(), re2.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal32("-999.999990", 6).getString(), re2.get(1, 1).getString()); + + Assert.AreEqual("1.99999", re2.getDecimal(0, 0).ToString()); + Assert.AreEqual("-1", re2.getDecimal(0, 1).ToString()); + Assert.AreEqual("1000", re2.getDecimal(1, 0).ToString()); + Assert.AreEqual("-999.99999", re2.getDecimal(1, 1).ToString()); + } + + [TestMethod] + public void test_BasicDecimal32Matrix_setString() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal32Matrix re1 = new BasicDecimal32Matrix(2, 2, 0); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(1, 1).getString()); + re1.setString(0, 0, "1.999990"); + re1.setString(0, 1, "-0.99999999"); + re1.setString(1, 0, "999.9999999"); + re1.setString(1, 1, "-999.99999"); + Assert.AreEqual("#0 #1 \n" + + "2 -1 \n" + + "1000 -1000\n", re1.getString()); + BasicDecimal32Matrix re2 = new BasicDecimal32Matrix(2, 2, 6); + re2.setString(0, 0, "1.999990"); + re2.setString(0, 1, "-0.99999999"); + re2.setString(1, 0, "999.9999999"); + re2.setString(1, 1, "-999.99999"); + Console.WriteLine(re2.getString()); + Assert.AreEqual(6, re2.getScale()); + Assert.AreEqual(new BasicDecimal32("1.999990", 6).getString(), re2.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal32("-1.000000", 6).getString(), re2.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal32("1000.000000", 6).getString(), re2.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal32("-999.999990", 6).getString(), re2.get(1, 1).getString()); + } + + [TestMethod] + public void test_BasicDecimal32Matrix_set() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal32Matrix re1 = new BasicDecimal32Matrix(2, 2, 0); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal32(0, 0).getString(), re1.get(1, 1).getString()); + IScalar bd1 = new BasicDecimal32("1.999990", 6); + IScalar bd2 = new BasicDecimal32("-0.99999999",8); + IScalar bd3 = new BasicDecimal32("999.999999", 6); + IScalar bd4 = new BasicDecimal32("-999.99999", 5); + re1.set(0, 0, bd1); + re1.set(0, 1, bd2); + re1.set(1, 0, bd3); + re1.set(1, 1, bd4); + Assert.AreEqual("#0 #1 \n" + + "2 -1 \n" + + "1000 -1000\n", re1.getString()); + BasicDecimal32Matrix re2 = new BasicDecimal32Matrix(2, 2, 6); + re2.set(0, 0, bd1); + re2.set(0, 1, bd2); + re2.set(1, 0, bd3); + re2.set(1, 1, bd4); + Console.WriteLine(re2.getString()); + Assert.AreEqual(6, re2.getScale()); + Assert.AreEqual(new BasicDecimal32("1.999990", 6).getString(), re2.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal32("-1.000000", 6).getString(), re2.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal32("999.999999", 6).getString(), re2.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal32("-999.999990", 6).getString(), re2.get(1, 1).getString()); + } + + [TestMethod] + public void test_BasicDecimal32Matrix_set_null() + { + IList list = new List(); + list.Add(new String[] { "9999999.99", "-9999999.99" }); + BasicDecimal32Matrix re1 = new BasicDecimal32Matrix(2, 1, list, 2); + BasicDecimal32 bd1 = new BasicDecimal32("1.99999", 9); + bd1.setNull(); + re1.set(0, 0, bd1); + re1.isNull(0, 0); + BasicDecimal32 bd2 = new BasicDecimal32(-2147483648, 0); + BasicDecimal32 bd3 = new BasicDecimal32(1, 0); + bd3.setNull(); + re1.set(1, 0, bd2); + re1.isNull(1, 0); + Assert.AreEqual("", re1.get(0, 0).getString()); + Assert.AreEqual("", re1.get(1, 0).getString()); + } + + [TestMethod] + public void test_BasicDecimal32Matrix_set_entity_not_support() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal32Matrix re1 = new BasicDecimal32Matrix(2, 2, 0); + + String exception = null; + try + { + re1.set(0, 0, new BasicDecimal64("1.99999", 9)); + } + catch (Exception ex) + { + exception = ex.Message; + } + Assert.AreEqual("the type of value must be BasicDecimal32. ", exception); + } + + [TestMethod] + public void test_BasicDecimal64Matrix() + { + BasicDecimal64Matrix re1 = new BasicDecimal64Matrix(0, 0, 0); + Console.WriteLine(re1.getString()); + Assert.AreEqual("\n", re1.getString()); + Assert.AreEqual(DATA_CATEGORY.DENARY, re1.getDataCategory()); + Assert.AreEqual("dolphindb.data.BasicDecimal64", re1.getElementClass().ToString()); + Assert.AreEqual(DATA_TYPE.DT_DECIMAL64, re1.getDataType()); + + BasicDecimal64Matrix re2 = new BasicDecimal64Matrix(3, 4, 0); + Console.WriteLine(re2.getString()); + Assert.AreEqual("#0 #1 #2 #3\n" + + "0 0 0 0 \n" + + "0 0 0 0 \n" + + "0 0 0 0 \n", re2.getString()); + + IList list = new List(); + list.Add(new decimal[] { 1, 2, 3 }); + list.Add(new decimal[] { 4, 5, 6 }); + BasicDecimal64Matrix re3 = new BasicDecimal64Matrix(3, 2, list, 2); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 #1 \n" + + "1.00 4.00\n" + + "2.00 5.00\n" + + "3.00 6.00\n", re3.getString()); + List list1 = new List(); + list1.Add(new String[] { "1", "2", "3" }); + list1.Add(new String[] { "4", "5", "6" }); + BasicDecimal64Matrix re4 = new BasicDecimal64Matrix(3, 2, list1, 2); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 #1 \n" + + "1.00 4.00\n" + + "2.00 5.00\n" + + "3.00 6.00\n", re3.getString()); + String exception = null; + try + { + BasicDecimal64Matrix re5 = new BasicDecimal64Matrix(4, 2, list, 2); + } + catch (Exception ex) + { + exception = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception); + String exception1 = null; + try + { + BasicDecimal64Matrix re6 = new BasicDecimal64Matrix(3, 3, list, 2); + } + catch (Exception ex) + { + exception1 = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception1); + + String exception2 = null; + try + { + BasicDecimal64Matrix re7 = new BasicDecimal64Matrix(4, 2, list1, 2); + } + catch (Exception ex) + { + exception2 = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception2); + + String exception3 = null; + try + { + BasicDecimal64Matrix re8 = new BasicDecimal64Matrix(3, 3, list1, 2); + } + catch (Exception ex) + { + exception3 = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception3); + } + + [TestMethod] + public void test_BasicDecimal64Matrix_scale_not_true() + { + IList list = new List(); + list.Add(new decimal[] { 999999999, 0, -999999999 }); + list.Add(new decimal[] { 999999999, 999999999, 999999999 }); + list.Add(new decimal[] { -999999999, -999999999, -999999999 }); + String exception = null; + try + { + BasicDecimal64Matrix re3 = new BasicDecimal64Matrix(3, 3, list, -1); + } + catch (Exception ex) + { + exception = ex.Message; + } + Assert.AreEqual("Scale -1 is out of bounds, it must be in [0,18].", exception); + String exception1 = null; + try + { + BasicDecimal64Matrix re3 = new BasicDecimal64Matrix(3, 3, list, 19); + } + catch (Exception ex) + { + exception1 = ex.Message; + } + Assert.AreEqual("Scale 19 is out of bounds, it must be in [0,18].", exception1); + + List list1 = new List(); + list1.Add(new String[] { "999999999999999999", "0", "-999999999999999999" }); + list1.Add(new String[] { "999999999999999999", "999999999999999999", "999999999999999999" }); + list1.Add(new String[] { "-999999999999999999", "-999999999999999999", "-999999999999999999" }); + String exception2 = null; + try + { + BasicDecimal64Matrix re3 = new BasicDecimal64Matrix(3, 3, list1, -1); + } + catch (Exception ex) + { + exception2 = ex.Message; + } + Assert.AreEqual("Scale -1 is out of bounds, it must be in [0,18].", exception2); + String exception3 = null; + try + { + BasicDecimal64Matrix re3 = new BasicDecimal64Matrix(3, 3, list1, 19); + } + catch (Exception ex) + { + exception3 = ex.Message; + } + Assert.AreEqual("Scale 19 is out of bounds, it must be in [0,18].", exception3); + } + + [TestMethod] + public void test_BasicDecimal64Matrix_decimal() + { + IList list = new List(); + list.Add(new decimal[] { 999999999999999999L, 0, -999999999999999999L }); + list.Add(new decimal[] { 999999999999999999L, 999999999999999999L, 999999999999999999L }); + list.Add(new decimal[] { -999999999999999999L, -999999999999999999l, -999999999999999999L }); + BasicDecimal64Matrix re1 = new BasicDecimal64Matrix(3, 3, list, 0); + Console.WriteLine(re1.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "999999999999999999 999999999999999999 -999999999999999999\n" + + "0 999999999999999999 -999999999999999999\n" + + "-999999999999999999 999999999999999999 -999999999999999999\n", re1.getString()); + + List list1 = new List(); + list1.Add(new decimal[] { 99999, 0, -99999 }); + list1.Add(new decimal[] { 99999, 99999, 99999 }); + list1.Add(new decimal[] { -99999, -99999, -1999 }); + BasicDecimal64Matrix re2 = new BasicDecimal64Matrix(3, 3, list1, 13); + Console.WriteLine(re2.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "99999.0000000000000 99999.0000000000000 -99999.0000000000000\n" + + "0.0000000000000 99999.0000000000000 -99999.0000000000000\n" + + "-99999.0000000000000 99999.0000000000000 -1999.0000000000000 \n", re2.getString()); + + List list2 = new List(); + list2.Add(new decimal[] { 1, 0, -1 }); + BasicDecimal64Matrix re3 = new BasicDecimal64Matrix(3, 1, list2, 18); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 \n" + + "1.000000000000000000 \n" + + "0.000000000000000000 \n" + + "-1.000000000000000000\n", re3.getString()); + } + + [TestMethod] + public void test_BasicDecimal64Matrix_string() + { + IList list = new List(); + list.Add(new String[] { "999999999999999999", "0", "-999999999999999999" }); + list.Add(new String[] { "999999999999999999", "999999999999999999", "999999999999999999" }); + list.Add(new String[] { "-999999999999999999", "-999999999999999999", "-999999999999999999" }); + BasicDecimal64Matrix re1 = new BasicDecimal64Matrix(3, 3, list, 0); + Console.WriteLine(re1.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "999999999999999999 999999999999999999 -999999999999999999\n" + + "0 999999999999999999 -999999999999999999\n" + + "-999999999999999999 999999999999999999 -999999999999999999\n", re1.getString()); + List list1 = new List(); + list1.Add(new String[] { "99999", "0", "-99999" }); + list1.Add(new String[] { "99999", "99999", "99999" }); + list1.Add(new String[] { "-99999", "-99999", "-1999" }); + BasicDecimal64Matrix re2 = new BasicDecimal64Matrix(3, 3, list1, 13); + Console.WriteLine(re2.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "99999.0000000000000 99999.0000000000000 -99999.0000000000000\n" + + "0.0000000000000 99999.0000000000000 -99999.0000000000000\n" + + "-99999.0000000000000 99999.0000000000000 -1999.0000000000000 \n", re2.getString()); + + List list2 = new List(); + list2.Add(new String[] { "1", "0", "-1" }); + BasicDecimal64Matrix re3 = new BasicDecimal64Matrix(3, 1, list2, 18); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 \n" + + "1.000000000000000000 \n" + + "0.000000000000000000 \n" + + "-1.000000000000000000\n", re3.getString()); + List list3 = new List(); + list3.Add(new String[] { "-1.9999", "0", "-1.00000000000009", "-1.999999999999999999999999" }); + list3.Add(new String[] { "1.9999", "0", "1.00000000009", "1.999999999999999999999999" }); + list3.Add(new String[] { "-0.9999", "0.01", "-0.00000000009", "-0.999999999999999999999999" }); + list3.Add(new String[] { "0.9999", "-0.001", "0.00000000000000000009", "0.999999999999999999999999" }); + BasicDecimal64Matrix re4 = new BasicDecimal64Matrix(4, 4, list3, 18); + Console.WriteLine(re4.getString()); + Assert.AreEqual("#0 #1 #2 #3 \n" + + "-1.999900000000000000 1.999900000000000000 -0.999900000000000000 0.999900000000000000 \n" + + "0.000000000000000000 0.000000000000000000 0.010000000000000000 -0.001000000000000000\n" + + "-1.000000000000090000 1.000000000090000000 -0.000000000090000000 0.000000000000000000 \n" + + "-2.000000000000000000 2.000000000000000000 -1.000000000000000000 1.000000000000000000 \n", re4.getString()); + + List list4 = new List(); + list4.Add(new String[] { "0.49", "-123.44", "132.50", "-0.51" }); + BasicDecimal64Matrix re5 = new BasicDecimal64Matrix(4, 1, list4, 0); + Console.WriteLine(re5.getString()); + Assert.AreEqual("#0 \n" + + "0 \n" + + "-123\n" + + "133 \n" + + "-1 \n", re5.getString()); + } + + [TestMethod] + public void test_BasicDecimal64Matrix_setNull() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal64Matrix re1 = new BasicDecimal64Matrix(3, 1, list, 0); + Assert.AreEqual(false, re1.isNull(0, 0)); + re1.setNull(0, 0); + Assert.AreEqual(true, re1.isNull(0, 0)); + Assert.AreEqual("", re1.get(0, 0).getString()); + } + + [TestMethod] + public void test_BasicDecimal64Matrix_setDecimal() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal64Matrix re1 = new BasicDecimal64Matrix(2, 2, 0); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(1, 1).getString()); + re1.setDecimal(0, 0, 1.999990m); + re1.setDecimal(0, 1, -0.99999999m); + re1.setDecimal(1, 0, 999.9999999m); + re1.setDecimal(1, 1, -999.99999m); + Assert.AreEqual("#0 #1 \n" + + "2 -1 \n" + + "1000 -1000\n", re1.getString()); + BasicDecimal64Matrix re2 = new BasicDecimal64Matrix(2, 2, 6); + re2.setDecimal(0, 0, 1.999990m); + re2.setDecimal(0, 1, -0.99999999m); + re2.setDecimal(1, 0, 999.9999999m); + re2.setDecimal(1, 1, -999.99999m); + Console.WriteLine(re2.getString()); + Assert.AreEqual(6, re2.getScale()); + Assert.AreEqual(new BasicDecimal64("1.999990", 6).getString(), re2.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal64("-1.000000", 6).getString(), re2.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal64("1000.000000", 6).getString(), re2.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal64("-999.999990", 6).getString(), re2.get(1, 1).getString()); + + Assert.AreEqual("1.99999", re2.getDecimal(0, 0).ToString()); + Assert.AreEqual("-1", re2.getDecimal(0, 1).ToString()); + Assert.AreEqual("1000", re2.getDecimal(1, 0).ToString()); + Assert.AreEqual("-999.99999", re2.getDecimal(1, 1).ToString()); + } + + [TestMethod] + public void test_BasicDecimal64Matrix_setString() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal64Matrix re1 = new BasicDecimal64Matrix(2, 2, 0); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(1, 1).getString()); + re1.setString(0, 0, "1.999990"); + re1.setString(0, 1, "-0.99999999"); + re1.setString(1, 0, "999.9999999"); + re1.setString(1, 1, "-999.99999"); + Assert.AreEqual("#0 #1 \n" + + "2 -1 \n" + + "1000 -1000\n", re1.getString()); + BasicDecimal64Matrix re2 = new BasicDecimal64Matrix(2, 2, 6); + re2.setString(0, 0, "1.999990"); + re2.setString(0, 1, "-0.99999999"); + re2.setString(1, 0, "999.9999999"); + re2.setString(1, 1, "-999.99999"); + Console.WriteLine(re2.getString()); + Assert.AreEqual(6, re2.getScale()); + Assert.AreEqual(new BasicDecimal64("1.999990", 6).getString(), re2.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal64("-1.000000", 6).getString(), re2.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal64("1000.000000", 6).getString(), re2.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal64("-999.999990", 6).getString(), re2.get(1, 1).getString()); + } + + [TestMethod] + public void test_BasicDecimal64Matrix_set() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal64Matrix re1 = new BasicDecimal64Matrix(2, 2, 0); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal64(0, 0).getString(), re1.get(1, 1).getString()); + IScalar bd1 = new BasicDecimal64("1.999990", 6); + IScalar bd2 = new BasicDecimal64("-0.99999999", 8); + IScalar bd3 = new BasicDecimal64("999.999999", 6); + IScalar bd4 = new BasicDecimal64("-999.99999", 5); + re1.set(0, 0, bd1); + re1.set(0, 1, bd2); + re1.set(1, 0, bd3); + re1.set(1, 1, bd4); + Assert.AreEqual("#0 #1 \n" + + "2 -1 \n" + + "1000 -1000\n", re1.getString()); + BasicDecimal64Matrix re2 = new BasicDecimal64Matrix(2, 2, 6); + re2.set(0, 0, bd1); + re2.set(0, 1, bd2); + re2.set(1, 0, bd3); + re2.set(1, 1, bd4); + Console.WriteLine(re2.getString()); + Assert.AreEqual(6, re2.getScale()); + Assert.AreEqual(new BasicDecimal64("1.999990", 6).getString(), re2.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal64("-1.000000", 6).getString(), re2.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal64("999.999999", 6).getString(), re2.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal64("-999.999990", 6).getString(), re2.get(1, 1).getString()); + } + + [TestMethod] + public void test_BasicDecimal64Matrix_set_null() + { + IList list = new List(); + list.Add(new String[] { "999999999", "-999999999" }); + BasicDecimal64Matrix re1 = new BasicDecimal64Matrix(2, 1, list, 2); + BasicDecimal64 bd1 = new BasicDecimal64("1.99999", 9); + bd1.setNull(); + re1.set(0, 0, bd1); + re1.isNull(0, 0); + BasicDecimal64 bd2 = new BasicDecimal64("", 0); + re1.set(1, 0, bd2); + re1.isNull(1, 0); + Assert.AreEqual("", re1.get(0, 0).getString()); + Assert.AreEqual("", re1.get(1, 0).getString()); + } + + [TestMethod] + public void test_BasicDecimal64Matrix_set_entity_not_support() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal64Matrix re1 = new BasicDecimal64Matrix(2, 2, 0); + + String exception = null; + try + { + re1.set(0, 0, new BasicDecimal128("1.99999", 9)); + } + catch (Exception ex) + { + exception = ex.Message; + } + Assert.AreEqual("value type must be BasicDecimal64. ", exception); + } + + [TestMethod] + public void test_BasicDecimal128Matrix() + { + BasicDecimal128Matrix re1 = new BasicDecimal128Matrix(0, 0, 0); + Console.WriteLine(re1.getString()); + Assert.AreEqual("\n", re1.getString()); + Assert.AreEqual(DATA_CATEGORY.DENARY, re1.getDataCategory()); + Assert.AreEqual("dolphindb.data.BasicDecimal128", re1.getElementClass().ToString()); + Assert.AreEqual(DATA_TYPE.DT_DECIMAL128, re1.getDataType()); + + BasicDecimal128Matrix re2 = new BasicDecimal128Matrix(3, 4, 0); + Console.WriteLine(re2.getString()); + Assert.AreEqual("#0 #1 #2 #3\n" + + "0 0 0 0 \n" + + "0 0 0 0 \n" + + "0 0 0 0 \n", re2.getString()); + + IList list = new List(); + list.Add(new decimal[] { 1, 2, 3 }); + list.Add(new decimal[] { 4, 5, 6 }); + BasicDecimal128Matrix re3 = new BasicDecimal128Matrix(3, 2, list, 2); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 #1 \n" + + "1.00 4.00\n" + + "2.00 5.00\n" + + "3.00 6.00\n", re3.getString()); + List list1 = new List(); + list1.Add(new String[] { "1", "2", "3" }); + list1.Add(new String[] { "4", "5", "6" }); + BasicDecimal128Matrix re4 = new BasicDecimal128Matrix(3, 2, list1, 2); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 #1 \n" + + "1.00 4.00\n" + + "2.00 5.00\n" + + "3.00 6.00\n", re3.getString()); + String exception = null; + try + { + BasicDecimal128Matrix re5 = new BasicDecimal128Matrix(4, 2, list, 2); + } + catch (Exception ex) + { + exception = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception); + String exception1 = null; + try + { + BasicDecimal128Matrix re6 = new BasicDecimal128Matrix(3, 3, list, 2); + } + catch (Exception ex) + { + exception1 = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception1); + + String exception2 = null; + try + { + BasicDecimal64Matrix re7 = new BasicDecimal64Matrix(4, 2, list1, 2); + } + catch (Exception ex) + { + exception2 = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception2); + + String exception3 = null; + try + { + BasicDecimal64Matrix re8 = new BasicDecimal64Matrix(3, 3, list1, 2); + } + catch (Exception ex) + { + exception3 = ex.Message; + } + Assert.AreEqual("the total size of list must be equal to rows * columns", exception3); + } + + [TestMethod] + public void test_BasicDecimal128Matrix_scale_not_true() + { + IList list = new List(); + list.Add(new decimal[] { 999999999, 0, -999999999 }); + list.Add(new decimal[] { 999999999, 999999999, 999999999 }); + list.Add(new decimal[] { -999999999, -999999999, -999999999 }); + String exception = null; + try + { + BasicDecimal128Matrix re3 = new BasicDecimal128Matrix(3, 3, list, -1); + } + catch (Exception ex) + { + exception = ex.Message; + } + Assert.AreEqual("Scale -1 is out of bounds, it must be in [0,38].", exception); + String exception1 = null; + try + { + BasicDecimal128Matrix re3 = new BasicDecimal128Matrix(3, 3, list, 39); + } + catch (Exception ex) + { + exception1 = ex.Message; + } + Assert.AreEqual("Scale 39 is out of bounds, it must be in [0,38].", exception1); + + List list1 = new List(); + list1.Add(new String[] { "999999999", "0", "-999999999" }); + list1.Add(new String[] { "999999999", "999999999", "999999999" }); + list1.Add(new String[] { "-999999999", "-999999999", "-999999999" }); + String exception2 = null; + try + { + BasicDecimal128Matrix re3 = new BasicDecimal128Matrix(3, 3, list1, -1); + } + catch (Exception ex) + { + exception2 = ex.Message; + } + Assert.AreEqual("Scale -1 is out of bounds, it must be in [0,38].", exception2); + String exception3 = null; + try + { + BasicDecimal128Matrix re3 = new BasicDecimal128Matrix(3, 3, list1, 39); + } + catch (Exception ex) + { + exception3 = ex.Message; + } + Assert.AreEqual("Scale 39 is out of bounds, it must be in [0,38].", exception3); + } + + [TestMethod] + public void test_BasicDecimal128Matrix_decimal() + { + IList list = new List(); + list.Add(new decimal[] { 79228162514264337593543950335m, 0m, -79228162514264337593543950335m }); + list.Add(new decimal[] { 79228162514264337593543950335m, 79228162514264337593543950335m, 79228162514264337593543950335m }); + list.Add(new decimal[] { -79228162514264337593543950335m, -79228162514264337593543950335m, -79228162514264337593543950335m }); + BasicDecimal128Matrix re1 = new BasicDecimal128Matrix(3, 3, list, 0); + Console.WriteLine(re1.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "79228162514264337593543950335 79228162514264337593543950335 -79228162514264337593543950335\n" + + "0 79228162514264337593543950335 -79228162514264337593543950335\n" + + "-79228162514264337593543950335 79228162514264337593543950335 -79228162514264337593543950335\n", re1.getString()); + + List list1 = new List(); + list1.Add(new decimal[] { 9999999999999999999m, 0m, -9999999999999999999m }); + list1.Add(new decimal[] { 9999999999999999999m, 9999999999999999999m, 9999999999999999999m }); + list1.Add(new decimal[] { -9999999999999999999m, -9999999999999999999m, -9999999999999999999m }); + BasicDecimal128Matrix re2 = new BasicDecimal128Matrix(3, 3, list1, 19); + Console.WriteLine(re2.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "9999999999999999999.0000000000000000000 9999999999999999999.0000000000000000000 -9999999999999999999.0000000000000000000\n" + + "0.0000000000000000000 9999999999999999999.0000000000000000000 -9999999999999999999.0000000000000000000\n" + + "-9999999999999999999.0000000000000000000 9999999999999999999.0000000000000000000 -9999999999999999999.0000000000000000000\n", re2.getString()); + + List list2 = new List(); + list2.Add(new decimal[] { 1m, 0m, -1m }); + BasicDecimal128Matrix re3 = new BasicDecimal128Matrix(3, 1, list2, 38); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 \n" + + "1.00000000000000000000000000000000000000 \n" + + "0.00000000000000000000000000000000000000 \n" + + "-1.00000000000000000000000000000000000000\n", re3.getString()); + } + + [TestMethod] + public void test_BasicDecimal128Matrix_string() + { + IList list = new List(); + list.Add(new String[] { "99999999999999999999999999999999999999", "0", "-99999999999999999999999999999999999999" }); + list.Add(new String[] { "99999999999999999999999999999999999999", "99999999999999999999999999999999999999", "99999999999999999999999999999999999999" }); + list.Add(new String[] { "-99999999999999999999999999999999999999", "-99999999999999999999999999999999999999", "-99999999999999999999999999999999999999" }); + BasicDecimal128Matrix re1 = new BasicDecimal128Matrix(3, 3, list, 0); + Console.WriteLine(re1.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "99999999999999999999999999999999999999 99999999999999999999999999999999999999 -99999999999999999999999999999999999999\n" + + "0 99999999999999999999999999999999999999 -99999999999999999999999999999999999999\n" + + "-99999999999999999999999999999999999999 99999999999999999999999999999999999999 -99999999999999999999999999999999999999\n", re1.getString()); + List list1 = new List(); + list1.Add(new String[] { "9999999999999999999.9999999999999999999", "0", "-9999999999999999999" }); + list1.Add(new String[] { "9999999999999999999.0000000000000000009", "9999999999999999999", "9999999999999999999" }); + list1.Add(new String[] { "-9999999999999999999.0000000000000000009", "-9999999999999999999", "-9999999999999999999" }); + BasicDecimal128Matrix re2 = new BasicDecimal128Matrix(3, 3, list1, 19); + Console.WriteLine(re2.getString()); + Assert.AreEqual("#0 #1 #2 \n" + + "9999999999999999999.9999999999999999999 9999999999999999999.0000000000000000009 -9999999999999999999.0000000000000000009\n" + + "0.0000000000000000000 9999999999999999999.0000000000000000000 -9999999999999999999.0000000000000000000\n" + + "-9999999999999999999.0000000000000000000 9999999999999999999.0000000000000000000 -9999999999999999999.0000000000000000000\n", re2.getString()); + + List list2 = new List(); + list2.Add(new String[] { "1", "0", "-1" }); + BasicDecimal128Matrix re3 = new BasicDecimal128Matrix(3, 1, list2, 38); + Console.WriteLine(re3.getString()); + Assert.AreEqual("#0 \n" + + "1.00000000000000000000000000000000000000 \n" + + "0.00000000000000000000000000000000000000 \n" + + "-1.00000000000000000000000000000000000000\n", re3.getString()); + List list3 = new List(); + list3.Add(new String[] { "-1.9999", "0", "-1.00000009", "-1.999999999999" }); + list3.Add(new String[] { "1.9999", "0", "1.00000009", "1.999999999999" }); + list3.Add(new String[] { "-0.9999", "0.01", "-0.00000009", "-0.999999999999" }); + list3.Add(new String[] { "0.9999", "-0.001", "0.00000009", "0.999999999999" }); + BasicDecimal128Matrix re4 = new BasicDecimal128Matrix(4, 4, list3, 9); + Console.WriteLine(re4.getString()); + Assert.AreEqual("#0 #1 #2 #3 \n" + + "-1.999900000 1.999900000 -0.999900000 0.999900000 \n" + + "0.000000000 0.000000000 0.010000000 -0.001000000\n" + + "-1.000000090 1.000000090 -0.000000090 0.000000090 \n" + + "-2.000000000 2.000000000 -1.000000000 1.000000000 \n", re4.getString()); + + List list4 = new List(); + list4.Add(new String[] { "0.49", "-123.44", "132.50", "-0.51" }); + BasicDecimal128Matrix re5 = new BasicDecimal128Matrix(4, 1, list4, 0); + Console.WriteLine(re5.getString()); + Assert.AreEqual("#0 \n" + + "0 \n" + + "-123\n" + + "133 \n" + + "-1 \n", re5.getString()); + } + + [TestMethod] + public void test_BasicDecimal128Matrix_setNull() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal128Matrix re1 = new BasicDecimal128Matrix(3, 1, list, 0); + Assert.AreEqual(false, re1.isNull(0, 0)); + re1.setNull(0, 0); + Assert.AreEqual(true, re1.isNull(0, 0)); + Assert.AreEqual("", re1.get(0, 0).getString()); + } + + [TestMethod] + public void test_BasicDecimal128Matrix_setDecimal() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal128Matrix re1 = new BasicDecimal128Matrix(2, 2, 0); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(1, 1).getString()); + re1.setDecimal(0, 0, 1.999990m); + re1.setDecimal(0, 1, -0.99999999m); + re1.setDecimal(1, 0, 999.9999999m); + re1.setDecimal(1, 1, -999.99999m); + Assert.AreEqual("#0 #1 \n" + + "2 -1 \n" + + "1000 -1000\n", re1.getString()); + BasicDecimal128Matrix re2 = new BasicDecimal128Matrix(2, 2, 6); + re2.setDecimal(0, 0, 1.999990m); + re2.setDecimal(0, 1, -0.99999999m); + re2.setDecimal(1, 0, 999.9999999m); + re2.setDecimal(1, 1, -999.99999m); + Console.WriteLine(re2.getString()); + Assert.AreEqual(6, re2.getScale()); + Assert.AreEqual(new BasicDecimal128("1.999990", 6).getString(), re2.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal128("-1.000000", 6).getString(), re2.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal128("1000.000000", 6).getString(), re2.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal128("-999.999990", 6).getString(), re2.get(1, 1).getString()); + + Assert.AreEqual("1.99999", re2.getDecimal(0, 0).ToString()); + Assert.AreEqual("-1", re2.getDecimal(0, 1).ToString()); + Assert.AreEqual("1000", re2.getDecimal(1, 0).ToString()); + Assert.AreEqual("-999.99999", re2.getDecimal(1, 1).ToString()); + } + + [TestMethod] + public void test_BasicDecimal128Matrix_setString() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal128Matrix re1 = new BasicDecimal128Matrix(2, 2, 0); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(1, 1).getString()); + re1.setString(0, 0, "1.999990"); + re1.setString(0, 1, "-0.99999999"); + re1.setString(1, 0, "999.9999999"); + re1.setString(1, 1, "-999.99999"); + Assert.AreEqual("#0 #1 \n" + + "2 -1 \n" + + "1000 -1000\n", re1.getString()); + BasicDecimal128Matrix re2 = new BasicDecimal128Matrix(2, 2, 6); + re2.setString(0, 0, "1.999990"); + re2.setString(0, 1, "-0.99999999"); + re2.setString(1, 0, "999.9999999"); + re2.setString(1, 1, "-999.99999"); + Console.WriteLine(re2.getString()); + Assert.AreEqual(6, re2.getScale()); + Assert.AreEqual(new BasicDecimal128("1.999990", 6).getString(), re2.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal128("-1.000000", 6).getString(), re2.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal128("1000.000000", 6).getString(), re2.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal128("-999.999990", 6).getString(), re2.get(1, 1).getString()); + } + + [TestMethod] + public void test_BasicDecimal128Matrix_set() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal128Matrix re1 = new BasicDecimal128Matrix(2, 2, 0); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal128(0, 0).getString(), re1.get(1, 1).getString()); + IScalar bd1 = new BasicDecimal128("1.999990", 6); + IScalar bd2 = new BasicDecimal128("-0.99999999", 8); + IScalar bd3 = new BasicDecimal128("999.999999", 6); + IScalar bd4 = new BasicDecimal128("-999.99999", 5); + re1.set(0, 0, bd1); + re1.set(0, 1, bd2); + re1.set(1, 0, bd3); + re1.set(1, 1, bd4); + Assert.AreEqual("#0 #1 \n" + + "2 -1 \n" + + "1000 -1000\n", re1.getString()); + BasicDecimal128Matrix re2 = new BasicDecimal128Matrix(2, 2, 6); + re2.set(0, 0, bd1); + re2.set(0, 1, bd2); + re2.set(1, 0, bd3); + re2.set(1, 1, bd4); + Console.WriteLine(re2.getString()); + Assert.AreEqual(6, re2.getScale()); + Assert.AreEqual(new BasicDecimal128("1.999990", 6).getString(), re2.get(0, 0).getString()); + Assert.AreEqual(new BasicDecimal128("-1.000000", 6).getString(), re2.get(0, 1).getString()); + Assert.AreEqual(new BasicDecimal128("999.999999", 6).getString(), re2.get(1, 0).getString()); + Assert.AreEqual(new BasicDecimal128("-999.999990", 6).getString(), re2.get(1, 1).getString()); + } + + [TestMethod] + public void test_BasicDecimal128Matrix_set_null() + { + IList list = new List(); + list.Add(new String[] { "999999999", "-999999999" }); + BasicDecimal128Matrix re1 = new BasicDecimal128Matrix(2, 1, list, 2); + BasicDecimal128 bd1 = new BasicDecimal128("1.99999", 9); + bd1.setNull(); + re1.set(0, 0, bd1); + re1.isNull(0, 0); + BasicDecimal128 bd2 = new BasicDecimal128(" -170141183460469231731687303715884105728", 0); + re1.set(1, 0, bd2); + re1.isNull(1, 0); + Console.WriteLine(re1.getString()); + Console.WriteLine(re1.get(0, 0)); + + Assert.AreEqual("", re1.get(0, 0).getString()); + Assert.AreEqual("", re1.get(1, 0).getString()); + } + + [TestMethod] + public void test_BasicDecimal128Matrix_set_entity_not_support() + { + IList list = new List(); + list.Add(new String[] { "111", "0", "-111" }); + BasicDecimal128Matrix re1 = new BasicDecimal128Matrix(2, 2, 0); + + String exception = null; + try + { + re1.set(0, 0, new BasicDecimal64("1.99999", 9)); + } + catch (Exception ex) + { + exception = ex.Message; + } + Assert.AreEqual("value type must be BasicDecimal128. ", exception); + } + } } diff --git a/test/data_test/BasicScalarTest.cs b/test/data_test/BasicScalarTest.cs index ac9b59f..2062a74 100644 --- a/test/data_test/BasicScalarTest.cs +++ b/test/data_test/BasicScalarTest.cs @@ -569,7 +569,7 @@ public void Test_BasicShort() sc.setObject(99); Assert.AreEqual(99, sc.getValue()); Assert.AreEqual(0, sc.hashBucket(-1)); - Assert.AreEqual(99, sc.GetHashCode()); + Assert.AreEqual(sc.GetHashCode(), sc.GetHashCode()); Assert.AreEqual(true, sc.Equals(sc)); Assert.AreEqual(false, sc.Equals('c')); Assert.AreEqual("INTEGRAL", sc.getDataCategory().ToString()); @@ -1425,7 +1425,7 @@ public void test_BasicDecimal32_getTemporal() catch (Exception ex) { re = ex.Message; } - Assert.AreEqual("The method or operation is not implemented.", re); + Assert.AreEqual(true, re.Contains("The method or operation is not implemented.") || re.Contains("δʵָ÷")); } [TestMethod] @@ -1543,7 +1543,7 @@ public void Test_BasicDecimal32_hashBucket() catch (Exception e) { string s = e.Message; - Assert.AreEqual("The method or operation is not implemented.", s); + Assert.AreEqual(true, s.Contains("The method or operation is not implemented.") || s.Contains("δʵָ÷")); } } @@ -1973,7 +1973,7 @@ public void test_BasicDecimal64_getTemporal() catch (Exception ex) { re = ex.Message; } - Assert.AreEqual("The method or operation is not implemented.", re); + Assert.AreEqual(true, re.Contains("The method or operation is not implemented.") || re.Contains("δʵָ÷")); } @@ -2070,7 +2070,7 @@ public void Test_BasicDecimal64_hashBucket() catch (Exception e) { string s = e.Message; - Assert.AreEqual("The method or operation is not implemented.", s); + Assert.AreEqual(true, s.Contains("The method or operation is not implemented.") || s.Contains("δʵָ÷")); } } @@ -2546,7 +2546,7 @@ public void test_BasicDecimal128_run_NULL() } catch (Exception e) { re = e.Message; } - Assert.AreEqual("Value was either too large or too small for a Decimal.", re); + Assert.AreEqual(true, re.Contains("Value was either too large or too small for a Decimal.") || re.Contains("ֵ Decimal ̫̫С")); } [TestMethod] @@ -2628,7 +2628,7 @@ public void test_BasicDecimal128_getTemporal() { re = e.Message; } - Assert.AreEqual("The method or operation is not implemented.", re); + Assert.AreEqual(true, re.Contains("The method or operation is not implemented.") || re.Contains("δʵָ÷")); } [TestMethod] @@ -2644,7 +2644,7 @@ public void test_BasicDecimal128_hashBucket() { re = e.Message; } - Assert.AreEqual("The method or operation is not implemented.", re); + Assert.AreEqual(true, re.Contains("The method or operation is not implemented.") || re.Contains("δʵָ÷")); } [TestMethod] diff --git a/test/data_test/BasicVectorTest.cs b/test/data_test/BasicVectorTest.cs index 2cb1107..452995a 100644 --- a/test/data_test/BasicVectorTest.cs +++ b/test/data_test/BasicVectorTest.cs @@ -847,9 +847,8 @@ public void Test_BasicNanoTimeVector() try { blv.add("24:30:10.008007006"); } - catch (Exception e) { - string s = e.Message; - Assert.AreEqual("Input string was not in a correct format.", s); + catch (Exception ex) { + Assert.AreEqual(true, ex.Message.Contains("Input string was not in a correct format.")|| ex.Message.Contains("ַĸʽȷ")); } //blv.add("new DateTime(1970, 1, 1)"); @@ -1001,9 +1000,8 @@ public void Test_BasicSecondVector() { blv.add("24:30:10"); } - catch (Exception e) { - string s = e.Message; - Assert.AreEqual("Input string was not in a correct format.", s); + catch (Exception ex) { + Assert.AreEqual(true, ex.Message.Contains("Input string was not in a correct format.")|| ex.Message.Contains("ַĸʽȷ")); } Assert.AreEqual("TEMPORAL", blv.getDataCategory().ToString()); Assert.AreEqual("dolphindb.data.BasicSecond", blv.getElementClass().ToString()); @@ -1147,7 +1145,7 @@ public void Test_BasicStringVector() { ex1 = e; } - Assert.AreEqual("The method or operation is not implemented.", ex1.Message); + Assert.AreEqual(true, ex1.Message.Contains("δʵָ÷") || ex1.Message.Contains("The method or operation is not implemented.")); IScalar scalar = (IScalar)conn.run("blob(\"1\")"); Console.Out.WriteLine(((BasicString)scalar).getBytes()); @@ -1227,7 +1225,7 @@ public void Test_BasicSymbolVector() { string s = ex.Message; - Assert.AreEqual(s, "The method or operation is not implemented."); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try @@ -1237,10 +1235,9 @@ public void Test_BasicSymbolVector() catch (Exception ex) { - string s = ex.Message; - Assert.AreEqual(s, "The method or operation is not implemented."); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } - + biv.asof((IScalar)conn.run("6")); try @@ -1250,7 +1247,7 @@ public void Test_BasicSymbolVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } biv.serialize(0, 0, @out);//-------- Assert.AreEqual(4, biv.getUnitLength()); @@ -1261,7 +1258,7 @@ public void Test_BasicSymbolVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } @@ -1367,7 +1364,7 @@ public void Test_BasicArrayVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1376,7 +1373,7 @@ public void Test_BasicArrayVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1385,7 +1382,7 @@ public void Test_BasicArrayVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1394,7 +1391,7 @@ public void Test_BasicArrayVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1403,7 +1400,7 @@ public void Test_BasicArrayVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1412,7 +1409,7 @@ public void Test_BasicArrayVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1421,7 +1418,7 @@ public void Test_BasicArrayVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1430,7 +1427,7 @@ public void Test_BasicArrayVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1439,7 +1436,7 @@ public void Test_BasicArrayVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } //Console.Out.WriteLine(bcv.get(0).getObject()); @@ -1492,7 +1489,7 @@ public void Test_BasicAnyVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1501,7 +1498,7 @@ public void Test_BasicAnyVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1519,7 +1516,7 @@ public void Test_BasicAnyVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1528,7 +1525,7 @@ public void Test_BasicAnyVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1537,7 +1534,7 @@ public void Test_BasicAnyVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1546,7 +1543,7 @@ public void Test_BasicAnyVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1555,7 +1552,7 @@ public void Test_BasicAnyVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } try { @@ -1565,7 +1562,7 @@ public void Test_BasicAnyVector() } catch (Exception ex) { - Assert.AreEqual("The method or operation is not implemented.", ex.Message); + Assert.AreEqual(true, ex.Message.Contains("δʵָ÷") || ex.Message.Contains("The method or operation is not implemented.")); } Assert.AreEqual("MIXED", bcv.getDataCategory().ToString()); @@ -3036,8 +3033,8 @@ public void Test_BasicDecimal64Vector_set() } bdv.set(0, "1.123456"); Assert.AreEqual("1.12346", bdv.get(0).getObject().ToString()); - bdv.set(0, new BasicDecimal64("2.12345678", 2)); - Assert.AreEqual("2.12000", bdv.get(0).getObject().ToString()); + bdv.set(0, new BasicDecimal64("2.12445678", 6)); + Assert.AreEqual("2.12446", bdv.get(0).getObject().ToString()); conn.close(); } diff --git a/test/route_test/MultithreadTableWriter_test.cs b/test/route_test/MultithreadTableWriter_test.cs index c8c8385..49b2e3d 100644 --- a/test/route_test/MultithreadTableWriter_test.cs +++ b/test/route_test/MultithreadTableWriter_test.cs @@ -3009,7 +3009,7 @@ public void Test_MultithreadedTableWriter_dfs_table_huge_data_single_thread() ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(2000); long total = 0; @@ -3022,7 +3022,7 @@ public void Test_MultithreadedTableWriter_dfs_table_huge_data_single_thread() } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -3058,7 +3058,7 @@ public void Test_MultithreadedTableWriter_dfs_table_huge_data_single_thread_tsdb ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(3000); long total = 0; @@ -3071,7 +3071,7 @@ public void Test_MultithreadedTableWriter_dfs_table_huge_data_single_thread_tsdb } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -3107,7 +3107,7 @@ public void Test_MultithreadedTableWriter_dfs_table_huge_data_multiple_thread_ts ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(3000); long total = 0; @@ -3120,7 +3120,7 @@ public void Test_MultithreadedTableWriter_dfs_table_huge_data_multiple_thread_ts } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -3157,7 +3157,7 @@ public void Test_MultithreadedTableWriter_dfs_table_partitionType_HASH() ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); long total = 0; @@ -3170,7 +3170,7 @@ public void Test_MultithreadedTableWriter_dfs_table_partitionType_HASH() } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -3206,7 +3206,7 @@ public void Test_MultithreadedTableWriter_dfs_table_partitionType_VALUE() ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); long total = 0; @@ -3219,7 +3219,7 @@ public void Test_MultithreadedTableWriter_dfs_table_partitionType_VALUE() } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -3255,7 +3255,7 @@ public void Test_MultithreadedTableWriter_dfs_table_partitionType_RANGE() ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); long total = 0; @@ -3268,7 +3268,7 @@ public void Test_MultithreadedTableWriter_dfs_table_partitionType_RANGE() } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -3304,7 +3304,7 @@ public void Test_MultithreadedTableWriter_dfs_table_partitionType_LIST() ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); long total = 0; @@ -3317,7 +3317,7 @@ public void Test_MultithreadedTableWriter_dfs_table_partitionType_LIST() } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -3353,7 +3353,7 @@ public void Test_MultithreadedTableWriter_dfs_table_compo_partition_first_partit ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(3000); long totalSentRows = 0; @@ -3365,7 +3365,7 @@ public void Test_MultithreadedTableWriter_dfs_table_compo_partition_first_partit } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(totalSentRows, 3000000); } @@ -3777,7 +3777,7 @@ public void Test_MultithreadedTableWriter_dimensional_table_huge_data_single_thr ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(2000); long total = 0; @@ -3790,7 +3790,7 @@ public void Test_MultithreadedTableWriter_dimensional_table_huge_data_single_thr } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -3852,7 +3852,7 @@ public void Test_MultithreadedTableWriter_dimensional_table_huge_data_single_thr List x = new List(new IScalar[] { new BasicInt(i), new BasicString("AA" + (i % 99).ToString()), new BasicString("BB" + (i % 99).ToString()), new BasicDouble(i % 999 + 0.1), new BasicInt(i % 999) }); ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); long total = 0; @@ -3865,7 +3865,7 @@ public void Test_MultithreadedTableWriter_dimensional_table_huge_data_single_thr } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -4352,7 +4352,7 @@ public void Test_MultithreadedTableWriter_threadCount_larger_than_partition() ErrorCodeInfo pErrorInfo = mtw.insert(x); } MultithreadedTableWriter.Status status = mtw.getStatus(); - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); bool flag = true; @@ -4363,7 +4363,7 @@ public void Test_MultithreadedTableWriter_threadCount_larger_than_partition() } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -4400,7 +4400,7 @@ public void Test_MultithreadedTableWriter_threadCount_less_than_partition() ErrorCodeInfo pErrorInfo = mtw.insert(x); } MultithreadedTableWriter.Status status = mtw.getStatus(); - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); bool flag = true; @@ -4411,7 +4411,7 @@ public void Test_MultithreadedTableWriter_threadCount_less_than_partition() } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -4448,7 +4448,7 @@ public void Test_MultithreadedTableWriter_throttle_double() ErrorCodeInfo pErrorInfo = mtw.insert(x); } MultithreadedTableWriter.Status status = mtw.getStatus(); - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); bool flag = true; @@ -4459,7 +4459,7 @@ public void Test_MultithreadedTableWriter_throttle_double() } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -4496,7 +4496,7 @@ public void Test_MultithreadedTableWriter_enableHighAvailabity_insert_dfs_table( ErrorCodeInfo pErrorInfo = mtw.insert(x); } MultithreadedTableWriter.Status status = mtw.getStatus(); - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); bool flag = true; @@ -4507,7 +4507,7 @@ public void Test_MultithreadedTableWriter_enableHighAvailabity_insert_dfs_table( } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -4556,7 +4556,7 @@ public void Test_MultithreadedTableWriter_enableHighAvailabity_insert_haStreamTa ErrorCodeInfo pErrorInfo = mtw.insert(x); } MultithreadedTableWriter.Status status = mtw.getStatus(); - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); bool flag = true; @@ -4567,7 +4567,7 @@ public void Test_MultithreadedTableWriter_enableHighAvailabity_insert_haStreamTa } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -4619,7 +4619,7 @@ public void Test_MultithreadedTableWriter_enableHighAvailabity_insert_haStreamTa ErrorCodeInfo pErrorInfo = mtw.insert(x); } MultithreadedTableWriter.Status status = mtw.getStatus(); - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); bool flag = true; @@ -4630,7 +4630,7 @@ public void Test_MultithreadedTableWriter_enableHighAvailabity_insert_haStreamTa } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -4689,7 +4689,7 @@ public void Test_MultithreadedTableWriter_setNotifyOnSuccessr_dfs_table_huge_dat ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(2000); long total = 0; @@ -4702,7 +4702,7 @@ public void Test_MultithreadedTableWriter_setNotifyOnSuccessr_dfs_table_huge_dat } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } @@ -4764,7 +4764,7 @@ public void Test_MultithreadedTableWriter_setNotifyOnSuccess_dfs_table_huge_data ErrorCodeInfo pErrorInfo = mtw.insert(x); } - for (int i = 0; i < 10; i++) + for (int i = 0; i < 30; i++) { Thread.Sleep(1000); long total = 0; @@ -4777,7 +4777,7 @@ public void Test_MultithreadedTableWriter_setNotifyOnSuccess_dfs_table_huge_data } else { - if (i == 9) + if (i == 29) { Assert.AreEqual(total, 3000000); } diff --git a/test/streaming/cep_test/EventClientTest.cs b/test/streaming/cep_test/EventClientTest.cs index b6423b8..a5385d4 100644 --- a/test/streaming/cep_test/EventClientTest.cs +++ b/test/streaming/cep_test/EventClientTest.cs @@ -1,2126 +1,2213 @@ -//using Microsoft.VisualStudio.TestTools.UnitTesting; -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using System.Text; -//using dolphindb; -//using dolphindb.data; -//using dolphindb.streaming; -//using System.Threading; -//using dolphindb_config; -//using dolphindb.streaming.cep; - -//namespace dolphindb_csharp_api_test.cep_test -//{ -// [TestClass] -// public class EventClientTest -// { - -// public static DBConnection streamConn; -// private string SERVER = MyConfigReader.SERVER; -// static private int PORT = MyConfigReader.PORT; -// private readonly string USER = MyConfigReader.USER; -// private readonly string PASSWORD = MyConfigReader.PASSWORD; -// private string LOCALHOST = MyConfigReader.LOCALHOST; -// private readonly int LOCALPORT = MyConfigReader.LOCALPORT; -// static private int SUB_FLAG = MyConfigReader.SUB_FLAG; -// private string NODE1_HOST = MyConfigReader.NODE1_HOST; -// private readonly int NODE1_PORT = MyConfigReader.NODE1_PORT; -// public static string[] HASTREAM_GROUP = MyConfigReader.HASTREAM_GROUP; -// private readonly int HASTREAM_GROUPID = MyConfigReader.HASTREAM_GROUPID; -// private readonly int TIMEOUT = 10000; -// public static DBConnection conn; -// static EventSender sender; -// static EventSchema scheme; -// static EventClient client; - -// public void clear_env() -// { -// try -// { -// DBConnection conn = new DBConnection(); -// conn.connect(SERVER, PORT, "admin", "123456"); -// conn.run("a = getStreamingStat().pubTables\n" + -// "for(i in a){\n" + -// "\tstopPublishTable(i.subscriber.split(\":\")[0],int(i.subscriber.split(\":\")[1]),i.tableName,i.actions)\n" + -// "}"); -// conn.run("def getAllShare(){\n" + -// "\treturn select name from objs(true) where shared=1\n" + -// "\t}\n" + -// "\n" + -// "def clearShare(){\n" + -// "\tlogin(`admin,`123456)\n" + -// "\tallShare=exec name from pnodeRun(getAllShare)\n" + -// "\tfor(i in allShare){\n" + -// "\t\ttry{\n" + -// "\t\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],clearTablePersistence,objByName(i))\n" + -// "\t\t\t}catch(ex1){}\n" + -// "\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],undef,i,SHARED)\n" + -// "\t}\n" + -// "\ttry{\n" + -// "\t\tPST_DIR=rpc(getControllerAlias(),getDataNodeConfig{getNodeAlias()})['persistenceDir']\n" + -// "\t}catch(ex1){}\n" + -// "}\n" + -// "clearShare()"); -// } -// catch (Exception ex) -// { -// Console.WriteLine(ex.ToString()); -// } -// } - -// [TestInitialize] -// public void TestInitialize() -// { -// conn = new DBConnection(); -// conn.connect(SERVER, PORT, "admin", "123456"); -// clear_env(); -// } - -// [TestCleanup] -// public void TestCleanup() -// { -// conn.close(); -// try { client.unsubscribe(SERVER, PORT, "inputTable", "test1"); } catch (Exception ex) { } -// try { client.unsubscribe(SERVER, PORT, "intput", "test1"); } catch (Exception ex) { } -// try { client.unsubscribe(SERVER, PORT, "inputTable", "StreamingApi"); } catch (Exception ex) { } -// try { client.unsubscribe(SERVER, PORT, "intput", "StreamingApi"); } catch (Exception ex) { } -// clear_env(); - -// } - -// public static void Preparedata(long count) -// { -// String script = "login(`admin, `123456); \n" + -// "n=" + count + ";\n" + -// "boolv = bool(rand([true, false, NULL], n));\n" + -// "charv = char(rand(rand(-100..100, 1000) join take(char(), 4), n));\n" + -// "shortv = short(rand(rand(-100..100, 1000) join take(short(), 4), n));\n" + -// "intv = int(rand(rand(-100..100, 1000) join take(int(), 4), n));\n" + -// "longv = long(rand(rand(-100..100, 1000) join take(long(), 4), n));\n" + -// "doublev = double(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n));\n" + -// "floatv = float(rand(rand(-100..100, 1000)*0.23 join take(float(), 4), n));\n" + -// "datev = date(rand(rand(-100..100, 1000) join take(date(), 4), n));\n" + -// "monthv = month(rand(1967.12M+rand(-100..100, 1000) join take(month(), 4), n));\n" + -// "timev = time(rand(rand(0..100, 1000) join take(time(), 4), n));\n" + -// "minutev = minute(rand(12:13m+rand(-100..100, 1000) join take(minute(), 4), n));\n" + -// "secondv = second(rand(12:13:12+rand(-100..100, 1000) join take(second(), 4), n));\n" + -// "datetimev = datetime(rand(1969.12.23+rand(-100..100, 1000) join take(datetime(), 4), n));\n" + -// "timestampv = timestamp(rand(1970.01.01T00:00:00.023+rand(-100..100, 1000) join take(timestamp(), 4), n));\n" + -// "nanotimev = nanotime(rand(12:23:45.452623154+rand(-100..100, 1000) join take(nanotime(), 4), n));\n" + -// "nanotimestampv = nanotimestamp(rand(rand(-100..100, 1000) join take(nanotimestamp(), 4), n));\n" + -// "symbolv = rand((\"syms\"+string(rand(100, 1000))) join take(string(), 4), n);\n" + -// "stringv = rand((\"stringv\"+string(rand(100, 1000))) join take(string(), 4), n);\n" + -// "uuidv = rand(rand(uuid(), 1000) join take(uuid(), 4), n);\n" + -// "datehourv = datehour(rand(datehour(1969.12.31T12:45:12)+rand(-100..100, 1000) join take(datehour(), 4), n));\n" + -// "ippaddrv = rand(rand(ipaddr(), 1000) join take(ipaddr(), 4), n);\n" + -// "int128v = rand(rand(int128(), 1000) join take(int128(), 4), n);\n" + -// "blobv = blob(string(rand((\"blob\"+string(rand(100, 1000))) join take(\"\", 4), n)));\n" + -// "complexv = rand(complex(rand(100, 1000), rand(100, 1000)) join NULL, n);\n" + -// "pointv = rand(point(rand(100, 1000), rand(100, 1000)) join NULL, n);\n" + -// "decimal32v = decimal32(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 3);\n" + -// "decimal64v = decimal64(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 8);\n" + -// "decimal128v = decimal128(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 10);\n" + -// "share table(boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, stringv, datehourv, uuidv, ippaddrv, int128v, blobv) as data;\n"; -// conn.run(script); -// } - -// public static void Preparedata_array(long count1, long count2) -// { -// String script1 = "login(`admin, `123456); \n" + -// "n=" + count1 + ";\n" + -// "m=" + count2 + ";\n" + -// "cbool = array(BOOL[]).append!(cut(take([true, false, NULL], n), m))\n" + -// "cchar = array(CHAR[]).append!(cut(take(char(-100..100 join NULL), n), m))\n" + -// "cshort = array(SHORT[]).append!(cut(take(short(-100..100 join NULL), n), m))\n" + -// "cint = array(INT[]).append!(cut(take(-100..100 join NULL, n), m))\n" + -// "clong = array(LONG[]).append!(cut(take(long(-100..100 join NULL), n), m))\n" + -// "cdouble = array(DOUBLE[]).append!(cut(take(-100..100 join NULL, n) + 0.254, m))\n" + -// "cfloat = array(FLOAT[]).append!(cut(take(-100..100 join NULL, n) + 0.254f, m))\n" + -// "cdate = array(DATE[]).append!(cut(take(2012.01.01..2012.02.29, n), m))\n" + -// "cmonth = array(MONTH[]).append!(cut(take(2012.01M..2013.12M, n), m))\n" + -// "ctime = array(TIME[]).append!(cut(take(09:00:00.000 + 0..99 * 1000, n), m))\n" + -// "cminute = array(MINUTE[]).append!(cut(take(09:00m..15:59m, n), m))\n" + -// "csecond = array(SECOND[]).append!(cut(take(09:00:00 + 0..999, n), m))\n" + -// "cdatetime = array(DATETIME[]).append!(cut(take(2012.01.01T09:00:00 + 0..999, n), m))\n" + -// "ctimestamp = array(TIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000 + 0..999 * 1000, n), m))\n" + -// "cnanotime =array(NANOTIME[]).append!(cut(take(09:00:00.000000000 + 0..999 * 1000000000, n), m))\n" + -// "cnanotimestamp = array(NANOTIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000000000 + 0..999 * 1000000000, n), m))\n" + -// "cuuid = array(UUID[]).append!(cut(take(uuid([\"5d212a78-cc48-e3b1-4235-b4d91473ee87\", \"5d212a78-cc48-e3b1-4235-b4d91473ee88\", \"5d212a78-cc48-e3b1-4235-b4d91473ee89\", \"\"]), n), m))\n" + -// "cdatehour = array(DATEHOUR[]).append!(cut(take(datehour(1..10 join NULL), n), m))\n" + -// "cipaddr = array(IPADDR[]).append!(cut(take(ipaddr([\"192.168.100.10\", \"192.168.100.11\", \"192.168.100.14\", \"\"]), n), m))\n" + -// "cint128 = array(INT128[]).append!(cut(take(int128([\"e1671797c52e15f763380b45e841ec32\", \"e1671797c52e15f763380b45e841ec33\", \"e1671797c52e15f763380b45e841ec35\", \"\"]), n), m))\n" + -// "ccomplex = array( COMPLEX[]).append!(cut(rand(complex(rand(100, 1000), rand(100, 1000)) join NULL, n), m))\n" + -// "cpoint = array(POINT[]).append!(cut(rand(point(rand(100, 1000), rand(100, 1000)) join NULL, n), m))\n" + -// "cdecimal32 = array(DECIMAL32(2)[]).append!(cut(decimal32(take(-100..100 join NULL, n) + 0.254, 3), m))\n" + -// "cdecimal64 = array(DECIMAL64(7)[]).append!(cut(decimal64(take(-100..100 join NULL, n) + 0.25467, 4), m))\n" + -// "cdecimal128 = array(DECIMAL128(19)[]).append!(cut(decimal128(take(-100..100 join NULL, n) + 0.25467, 5), m))\n" + -// "share table(cbool, cchar, cshort, cint, clong, cdouble, cfloat, cdate, cmonth, ctime, cminute, csecond, cdatetime, ctimestamp, cnanotime, cnanotimestamp, cdatehour, cuuid, cipaddr, cint128) as data;\n"; -// conn.run(script1); -// } - -// public static void Preparedata_array_decimal(long count1, long count2) -// { -// String script1 = "login(`admin, `123456); \n" + -// "n=" + count1 + ";\n" + -// "m=" + count2 + ";\n" + -// "cdecimal32 = array(DECIMAL32(2)[]).append!(cut(decimal32(take(-100..100 join NULL, n) + 0.254, 3), m))\n" + -// "cdecimal64 = array(DECIMAL64(7)[]).append!(cut(decimal64(take(-100..100 join NULL, n) + 0.25467, 4), m))\n" + -// "cdecimal128 = array(DECIMAL128(19)[]).append!(cut(decimal128(take(-100..100 join NULL, n) + 0.25467, 5), m))\n" + -// "share table( cdecimal32, cdecimal64,cdecimal128) as data;"; -// conn.run(script1); -// } - -// public void checkData(BasicTable exception, BasicTable resTable) -// { -// Assert.AreEqual(exception.rows(), resTable.rows()); -// for (int i = 0; i < exception.columns(); i++) -// { -// Console.Out.WriteLine("col" + resTable.getColumnName(i)); -// Assert.AreEqual(exception.getColumn(i).getString(), resTable.getColumn(i).getString()); -// } -// } - -// class Handler : EventMessageHandler -// { - -// public void doEvent(String eventType, List attribute) -// { -// Console.Out.WriteLine("eventType: " + eventType); -// for (int i = 0; i < attribute.Count; i++) -// { -// Console.Out.WriteLine(attribute[i].ToString()); -// } - -// try -// { -// conn.run("tableInsert{outputTable}", attribute); -// } -// catch (Exception e) -// { -// System.Console.Out.WriteLine(e.ToString()); -// } -// } -// }; - -// class Handler1 : EventMessageHandler -// { - -// public void doEvent(String eventType, List attribute) -// { -// Console.Out.WriteLine("eventType: " + eventType); -// for (int i = 0; i < attribute.Count; i++) -// { -// Console.Out.WriteLine(attribute[i].ToString()); -// } - -// if (eventType.Equals("MarketData")) -// { -// try -// { -// conn.run("tableInsert{outputTable}", attribute); -// } -// catch (Exception e) -// { -// System.Console.Out.WriteLine(e.ToString()); -// } -// } -// else -// { -// try -// { -// conn.run("tableInsert{outputTable1}", attribute); -// } -// catch (Exception e) -// { -// System.Console.Out.WriteLine(e.ToString()); -// } -// } -// } -// }; - -// class Handler_array : EventMessageHandler -// { - -// public void doEvent(String eventType, List attributes) -// { -// Console.WriteLine("eventType: " + eventType); -// String boolv = attributes[0].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String charv = attributes[1].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String shortv = attributes[2].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String intv = attributes[3].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String longv = attributes[4].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String doublev = attributes[5].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String floatv = attributes[6].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String datev = attributes[7].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String monthv = attributes[8].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String timev = attributes[9].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String minutev = attributes[10].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String secondv = attributes[11].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String datetimev = attributes[12].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String timestampv = attributes[13].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String nanotimev = attributes[14].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String nanotimestampv = attributes[15].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String datehourv = attributes[16].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); -// String uuidv = attributes[17].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); -// String ippaddrv = attributes[18].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); -// String int128v = attributes[19].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); -// String pointv = attributes[20].getString().Replace("(,)", "(NULL,NULL)"); -// pointv = pointv.Substring(1, pointv.Length - 1); -// String[] separators = { "),(" }; -// String[] point1 = pointv.Split(separators, StringSplitOptions.None); -// String point2 = null; -// StringBuilder re1 = new StringBuilder(); -// StringBuilder re2 = new StringBuilder(); -// for (int i = 0; i < point1.Length; i++) -// { -// point2 = point1[i]; -// String[] dataType3 = point2.Split(','); -// re1.Append(dataType3[0]); -// re1.Append(' '); -// re2.Append(dataType3[1]); -// re2.Append(' '); -// } -// pointv = re1 + "," + re2; -// pointv = pointv.Replace("(", "").Replace(")", ""); - -// String complex1 = attributes[21].getString().Replace(",,", ",NULL+NULL,").Replace("[,", "[NULL+NULL,").Replace(",]", ",NULL+NULL]"); -// complex1 = complex1.Substring(1, complex1.Length - 1); -// String[] complex2 = complex1.Split(','); -// String complex3 = null; -// StringBuilder re11 = new StringBuilder(); -// StringBuilder re21 = new StringBuilder(); -// for (int i = 0; i < complex2.Length; i++) -// { -// complex3 = complex2[i]; -// String[] complex4 = complex3.Split('+'); -// re11.Append(complex4[0]); -// re11.Append(' '); -// re21.Append(complex4[1]); -// re21.Append(' '); -// } -// complex1 = re11 + "," + re21; -// String complexv = complex1.Replace("i", ""); - -// String decimal32v = attributes[22].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String decimal64v = attributes[23].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String decimal128v = attributes[24].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); - -// for (int i = 0; i < attributes.Count; i++) -// { -// //attributes[i].getString(); -// Console.WriteLine(attributes[i].getString()); -// } -// String script = null; -// //script = String.Format("insert into outputTable values( {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},[datehour({0})],[uuid({0})],[ipaddr({0})],[int128({0})],[point({0})],[complex({0})],{0},{0},{0})", boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, datehourv, uuidv, ippaddrv, int128v, pointv, complexv, decimal32v, decimal64v, decimal128v); -// script = String.Format("insert into outputTable values( {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},[datehour({16})],[uuid({17})],[ipaddr({18})],[int128({19})])", boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, datehourv, uuidv, ippaddrv, int128v); -// conn.run(script); -// } -// }; - -// class Handler_array_decimal : EventMessageHandler -// { - -// public void doEvent(String eventType, List attributes) -// { -// String decimal32v = attributes[0].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String decimal64v = attributes[1].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String decimal128v = attributes[2].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); - -// for (int i = 0; i < attributes.Count; i++) -// { -// //attributes[i].getString(); -// Console.WriteLine(attributes[i].getString()); -// } -// String script = null; -// script = String.Format("insert into outputTable values( {0},{1},{2})", decimal32v, decimal64v, decimal128v); -// conn.run(script); -// } -// }; - - - -// public void PrepareUser(String userName, String password) -// { -// DBConnection conn = new DBConnection(); -// conn.connect(SERVER, PORT, "admin", "123456"); -// conn.run("def create_user(){try{deleteUser(`" + userName + ")}catch(ex){};createUser(`" + userName + ", '" + password + "');};" + -// "rpc(getControllerAlias(),create_user);"); -// } - - -// [TestMethod] -// public void test_EventClient_EventScheme_null() -// { -// List eventSchemas = new List(); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("eventSchema must be non-null and non-empty.", re); -// } - -// [TestMethod] -// public void test_EventClient_EventType_null() -// { -// EventSchema scheme = new EventSchema(null, new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("eventSchema must be non-null and non-empty.", re); -// } - -// [TestMethod] -// public void test_EventClient_EventType_null_1() -// { -// EventSchema scheme = new EventSchema("", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("eventType must be non-empty.", re); -// } - -// [TestMethod] -// public void test_EventClient_EventType_repetition() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "time", "time1", "time2", "time3" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// EventSchema scheme1 = new EventSchema("market", new List { "market", "time0", "time1", "time2", "time3" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); - -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// eventSchemas.Add(scheme1); -// List eventTimeFields = new List() { "market" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("EventType must be unique.", re); -// } - -// [TestMethod] -// public void test_EventClient_fieldNames_null() -// { -// EventSchema scheme = new EventSchema("market", new List { "", "market", "time3", "time2", "time3" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "market" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("eventKey in eventSchema must be non-empty.", re); -// } - -// [TestMethod] -// public void test_EventClient_fieldNames_repetition() -// { -// conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "time", "time" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "time" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("EventSchema cannot has duplicated fieldName in fieldNames.", re); -// } - -// [TestMethod] -// public void test_EventClient_fieldNames_one_colume() -// { -// String script = "share streamTable(1:0, [`timestamp], [TIMESTAMP]) as outputTable;\n" + -// "class MarketData{\n" + -// "timestamp :: TIMESTAMP\n" + -// "def MarketData(t){\n" + -// "timestamp = t\n" + -// "}\n" + -// "}\n" + -// "class MainMonitor{\n" + -// "def MainMonitor(){}\n" + -// "def updateMarketData(event)\n" + -// "def onload(){addEventListener(updateMarketData,'MarketData',,'all')}\n" + -// "def updateMarketData(event){emitEvent(event)}\n" + -// "}\n" + -// "dummy = table(array(TIMESTAMP, 0) as timestamp, array(STRING, 0) as eventType, array(BLOB, 0) as blobs);\n" + -// "share streamTable(array(TIMESTAMP, 0) as timestamp, array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput\n" + -// "schema = table(1:0, `eventType`eventKeys`eventValuesTypeString`eventValueTypeID`eventValuesFormID, [STRING, STRING, STRING, INT[], INT[]])\n" + -// "insert into schema values(\"MarketData\", \"timestamp\", \"TIMESTAMP\", 12, 0)\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schema, outputTable=intput, eventTimeField = \"timestamp\")\n"; -// conn.run(script); -// EventSchema scheme = new EventSchema("market", new List { "timestamp" }, new List { DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "timestamp" }; -// List commonFields = new List(); - -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "intput", "test1", handler, -1, true, "admin", "123456"); -// conn.run("marketData1 = MarketData(now());\n appendEvent(inputSerializer, [marketData1])"); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// Assert.AreEqual(1, re.rows()); -// BasicTable re1 = (BasicTable)conn.run("select timestamp from intput"); -// checkData(re1, re); -// client.unsubscribe(SERVER, PORT, "intput", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_FieldTypes_null() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, null, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("the number of eventKey, eventTypes, eventForms and eventExtraParams (if set) must have the same length.", re); -// } - -// [TestMethod] -// public void test_EventClient_FieldTypes_not_support() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_VOID, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("the number of eventKey, eventTypes, eventForms and eventExtraParams (if set) must have the same length.", re); -// } - -// [TestMethod] -// public void test_EventClient_FieldForms_null() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_VOID, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, null); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("the number of eventKey, eventTypes, eventForms and eventExtraParams (if set) must have the same length.", re); -// } - -// [TestMethod] -// public void test_EventClient_FieldForms_null_1() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_VOID, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List()); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("the number of eventKey, eventTypes, eventForms and eventExtraParams (if set) must have the same length.", re); -// } - -// [TestMethod] -// public void test_EventClient_FieldForms_not_support() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("FieldForm only can be DF_SCALAR or DF_VECTOR.", re); -// } - - -// //[TestMethod] -// //public void test_EventClient_attrExtraParams_null() -// //{ -// // EventSchema scheme = new EventSchema(); -// // scheme.setEventType("market"); -// // scheme.setFieldNames(Arrays.asList("market", "code", "decimal32", "decimal64", "decimal128")); -// // scheme.setFieldTypes(Arrays.asList(DT_STRING, DT_STRING, DT_DECIMAL32, DT_DECIMAL64, DT_DECIMAL128)); -// // scheme.setFieldForms(Arrays.asList(DF_SCALAR, DF_SCALAR, DF_SCALAR, DF_SCALAR, DF_SCALAR)); -// // List eventSchemas = Collections.singletonList(scheme); -// // List eventTimeFields = new List(); -// // List commonFields = new List(); -// // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// //} - -// //[TestMethod] -// //public void test_EventClient_attrExtraParams_set_not_true() -// //{ -// // EventSchema scheme = new EventSchema(); -// // scheme.setEventType("market"); -// // scheme.setFieldNames(Arrays.asList("decimal32", "decimal64", "decimal128")); -// // scheme.setFieldTypes(Arrays.asList(DT_DECIMAL32, DT_DECIMAL64, DT_DECIMAL128)); -// // scheme.setFieldForms(Arrays.asList(DF_SCALAR, DF_SCALAR, DF_SCALAR)); -// // scheme.setFieldExtraParams(Arrays.asList(10, 19, 39)); -// // List eventSchemas = Collections.singletonList(scheme); -// // List eventTimeFields = new List(); -// // List commonFields = new List(); -// // String re = null; -// // try -// // { -// // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL32 scale 10 is out of bounds, it must be in [0,9].", re); - -// // scheme.setFieldExtraParams(Arrays.asList(1, 19, 39)); -// // String re1 = null; -// // try -// // { -// // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re1 = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL64 scale 19 is out of bounds, it must be in [0,18].", re1); - -// // scheme.setFieldExtraParams(Arrays.asList(1, 18, 39)); -// // String re2 = null; -// // try -// // { -// // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re2 = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL128 scale 39 is out of bounds, it must be in [0,38].", re2); - -// // scheme.setFieldExtraParams(Arrays.asList(-1, 10, 10)); -// // String re3 = null; -// // try -// // { -// // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re3 = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL32 scale -1 is out of bounds, it must be in [0,9].", re3); - -// // scheme.setFieldExtraParams(Arrays.asList(1, -1, 0)); -// // String re4 = null; -// // try -// // { -// // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re4 = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL64 scale -1 is out of bounds, it must be in [0,18].", re4); - -// // scheme.setFieldExtraParams(Arrays.asList(0, 0, -1)); -// // String re5 = null; -// // try -// // { -// // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re5 = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL128 scale -1 is out of bounds, it must be in [0,38].", re5); -// //} - -// [TestMethod] -// public void test_EventClient_eventTimeFields_not_exist() -// { - -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "datetimev" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Event market doesn't contain eventTimeKey datetimev.", re); -// } - -// [TestMethod] -// public void test_EventClient_eventTimeFields_not_time_column() -// { - -// conn.run("share streamTable(1000000:0, `string`eventType`event, [STRING,STRING,BLOB]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "code" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "market" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("The first column of the output table must be temporal if eventTimeKey is specified.", re); -// } - -// [TestMethod] -// public void test_EventClient_eventTimeFields_two_column() -// { -// conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); -// String script = "share streamTable(1:0, `timestamp`time, [TIMESTAMP,TIME]) as outputTable;\n" + -// "share streamTable(1:0, `string`timestamp, [STRING,TIMESTAMP]) as outputTable1;\n" + -// "class MarketData{\n" + -// "timestamp :: TIMESTAMP\n" + -// "time :: TIME\n" + -// "def MarketData(t,t1){\n" + -// "timestamp = t\n" + -// "time = t1\n" + -// "}\n" + -// "}\n" + -// "class MarketData1{\n" + -// "string :: STRING\n" + -// "timestamp :: TIMESTAMP\n" + -// "def MarketData1(s,t){\n" + -// "string = s\n" + -// "timestamp = t\n" + -// "}\n" + -// "}\n" + -// "share streamTable(array(TIMESTAMP, 0) as timestamp, array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput\n" + -// "schema = table(1:0, `eventType`eventKeys`eventValuesTypeString`eventValueTypeID`eventValuesFormID, [STRING, STRING, STRING, INT[], INT[]])\n" + -// "insert into schema values(\"MarketData\", \"timestamp,time\", \"TIMESTAMP,TIME\", [12 8], [0 0])\n" + -// "insert into schema values(\"MarketData1\", \"string,timestamp\", \"STRING,TIMESTAMP\", [18 12], [0 0])\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schema, outputTable=intput, eventTimeField = \"timestamp\")\n"; -// conn.run(script); -// EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "time" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("MarketData1", new List { "string", "timestamp" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); -// List eventTimeFields = new List() { "time", "timestamp" }; -// List commonFields = new List(); - -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler1 handler1 = new Handler1(); -// client.subscribe(SERVER, PORT, "intput", "test1", handler1, -1, true, "admin", "123456"); -// conn.run("marketData1 = MarketData(now(),time(1));\n marketData2 = MarketData1(\"tesrtttt\",now());\n appendEvent(inputSerializer, [marketData1,marketData2])"); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// BasicTable re1 = (BasicTable)conn.run("select * from outputTable1"); -// BasicTable re2 = (BasicTable)conn.run("select timestamp from intput"); - -// Assert.AreEqual(1, re.rows()); -// Assert.AreEqual(1, re1.rows()); -// Assert.AreEqual(re2.getColumn(0).get(0).getString(), re.getColumn(0).get(0).getString()); -// Assert.AreEqual("00:00:00.001", re.getColumn(1).get(0).getString()); -// Assert.AreEqual("tesrtttt", re1.getColumn(0).get(0).getString()); -// Assert.AreEqual(re2.getColumn(0).get(1).getString(), re1.getColumn(1).get(0).getString()); -// client.unsubscribe(SERVER, PORT, "intput", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_commonFields_one_column() -// { -// String script = "share streamTable(1:0, `timestamp`time`commonKey, [TIMESTAMP,TIME,TIMESTAMP]) as outputTable;\n" + -// "share streamTable(1:0, `string`timestamp`commonKey, [STRING,TIMESTAMP,TIMESTAMP]) as outputTable1;\n" + -// "class MarketData{\n" + -// "timestamp :: TIMESTAMP\n" + -// "time :: TIME\n" + -// "def MarketData(t,t1){\n" + -// "timestamp = t\n" + -// "time = t1\n" + -// "}\n" + -// "}\n" + -// "class MarketData1{\n" + -// "string :: STRING\n" + -// "timestamp :: TIMESTAMP\n" + -// "def MarketData1(s,t){\n" + -// "string = s\n" + -// "timestamp = t\n" + -// "}\n" + -// "}\n" + -// "share streamTable(array(TIMESTAMP, 0) as timestamp, array(STRING, 0) as eventType, array(BLOB, 0) as blobs,array(TIMESTAMP, 0) as commonKey) as intput\n" + -// "schema = table(1:0, `eventType`eventKeys`eventValuesTypeString`eventValueTypeID`eventValuesFormID, [STRING, STRING, STRING, INT[], INT[]])\n" + -// "insert into schema values(\"MarketData\", \"timestamp,time\", \"TIMESTAMP,TIME\", [12 8], [0 0])\n" + -// "insert into schema values(\"MarketData1\", \"string,timestamp\", \"STRING,TIMESTAMP\", [18 12], [0 0])\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schema, outputTable=intput, eventTimeField = \"timestamp\", commonField = \"timestamp\")\n"; -// conn.run(script); - -// EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "time" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("MarketData1", new List { "string", "timestamp" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); -// List eventTimeFields = new List() { "time", "timestamp" }; -// List commonFields = new List() { "timestamp" }; - -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler1 handler1 = new Handler1(); -// client.subscribe(SERVER, PORT, "intput", "test1", handler1, -1, true, "admin", "123456"); -// conn.run("marketData1 = MarketData(now(),time(1));\n marketData2 = MarketData1(\"tesrtttt\",now());\n appendEvent(inputSerializer, [marketData1,marketData2])"); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// BasicTable re1 = (BasicTable)conn.run("select * from outputTable1"); -// BasicTable re2 = (BasicTable)conn.run("select timestamp from intput"); - -// Assert.AreEqual(1, re.rows()); -// Assert.AreEqual(1, re1.rows()); -// Assert.AreEqual(re2.getColumn(0).get(0).getString(), re.getColumn(0).get(0).getString()); -// Assert.AreEqual("00:00:00.001", re.getColumn(1).get(0).getString()); -// Assert.AreEqual("tesrtttt", re1.getColumn(0).get(0).getString()); -// Assert.AreEqual(re2.getColumn(0).get(0).getString(), re1.getColumn(1).get(0).getString()); -// client.unsubscribe(SERVER, PORT, "intput", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_commonFields_two_column() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("market1", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); -// List eventTimeFields = new List() ; -// List commonFields = new List() { "time", "market" }; - -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// List attributes = new List(); -// attributes.Add(new BasicString("123456")); -// attributes.Add(new BasicTime(10)); -// sender.sendEvent("market", attributes); - -// List attributes1 = new List(); -// attributes1.Add(new BasicString("tesrtrrr")); -// attributes1.Add(new BasicTime(12)); -// sender.sendEvent("market1", attributes1); - -// BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// Assert.AreEqual(2, re.rows()); -// Assert.AreEqual("10:45:03.100", re.getColumn(2).get(0).getString()); -// Assert.AreEqual("12:45:03.100", re.getColumn(2).get(1).getString()); -// Assert.AreEqual("123456", re.getColumn(3).get(0).getString()); -// Assert.AreEqual("tesrtrrr", re.getColumn(3).get(1).getString()); -// } - -// public void subscribePrepare() -// { -// conn.run("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "comment1" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "timestamp" }; -// List commonFields = new List() { "comment1" }; - -// sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_SERVER_null() -// { -// subscribePrepare(); -// String re = null; -// Handler1 handler1 = new Handler1(); -// try -// { -// client.subscribe(null, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Database connection is not established yet.", re); -// } -// [TestMethod] -// public void test_EventClient_subscribe_SERVER_not_true() -// { -// subscribePrepare(); -// String re = null; -// Handler1 handler1 = new Handler1(); -// try -// { -// client.subscribe("erer", PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Database connection is not established yet.", re); -// } -// [TestMethod] -// public void test_EventClient_subscribe_port_0() -// { -// subscribePrepare(); -// String re = null; -// Handler1 handler1 = new Handler1(); -// try -// { -// client.subscribe(SERVER, 0, "inputTable", "test1", handler1, -1, true, "admin", "123456"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Database connection is not established yet.", re); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_port_not_true() -// { -// subscribePrepare(); -// String re = null; -// Handler1 handler1 = new Handler1(); -// try -// { -// client.subscribe(SERVER, 18888, "inputTable", "test1", handler1, -1, true, "admin", "123456"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Database connection is not established yet.", re); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_tableName_not_exist() -// { -// subscribePrepare(); -// String re = null; -// Handler1 handler1 = new Handler1(); -// try -// { -// client.subscribe(SERVER, PORT, "inputTable111", "test1", handler1, -1, true, "admin", "123456"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual(true, re.Contains("The shared table inputTable111 doesn't exist.")); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_tableName_null() -// { -// subscribePrepare(); -// String re = null; -// Handler1 handler1 = new Handler1(); -// try -// { -// client.subscribe(SERVER, PORT, null, "test1", handler1, -1, true, "admin", "123456"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("EventClient subscribe 'tableName' param cannot be null or empty.", re); -// String re1 = null; -// try -// { -// client.subscribe(SERVER, PORT, "", "test1", handler1, -1, true, "admin", "123456"); -// } -// catch (Exception ex) -// { -// re1 = ex.Message; -// } -// Assert.AreEqual("EventClient subscribe 'tableName' param cannot be null or empty.", re1); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_actionName_exist() -// { -// subscribePrepare(); -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable1;"); -// String re = null; -// Handler1 handler1 = new Handler1(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); -// client.subscribe(SERVER, PORT, "inputTable1", "test1", handler1, -1, true, "admin", "123456"); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// client.unsubscribe(SERVER, PORT, "inputTable1", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_actionName_null() -// { -// subscribePrepare(); -// Handler1 handler1 = new Handler1(); -// client.subscribe(SERVER, PORT, "inputTable", null, handler1, -1, true, "admin", "123456"); -// client.unsubscribe(SERVER, PORT, "inputTable", null); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_handler_null() -// { -// subscribePrepare(); -// String re = null; -// client.subscribe(SERVER, PORT, "inputTable", "test1", null, -1, true, "admin", "123456"); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } -// [TestMethod] -// public void test_EventClient_subscribe_offset_negative_1() -// { -// subscribePrepare(); -// conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// sender.sendEvent("MarketData", attributes); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// Assert.AreEqual(1, re.rows()); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } -// [TestMethod] -// public void test_EventClient_subscribe_offset_negative_2() -// { -// subscribePrepare(); -// conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// sender.sendEvent("MarketData", attributes); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -2, true, "admin", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// Assert.AreEqual(1, re.rows()); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } -// [TestMethod] -// public void test_EventClient_subscribe_offset_0() -// { -// subscribePrepare(); -// conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// sender.sendEvent("MarketData", attributes); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, 0, true, "admin", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// Assert.AreEqual(2, re.rows()); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_offset_1() -// { -// subscribePrepare(); -// conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// sender.sendEvent("MarketData", attributes); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, 1, true, "admin", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// Assert.AreEqual(1, re.rows()); -// } -// [TestMethod] -// public void test_EventClient_subscribe_offset_not_match() -// { -// subscribePrepare(); -// conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// sender.sendEvent("MarketData", attributes); -// String re = null; -// Handler handler = new Handler(); -// try -// { -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, 2, true, "admin", "123456"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual(true, re.Contains("Can't find the message with offset")); -// } -// [TestMethod] -// public void test_EventClient_subscribe_reconnect_true() -// { -// subscribePrepare(); -// conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// sender.sendEvent("MarketData", attributes); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, false, "admin", "123456"); -// Thread.Sleep(1000); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_reconnect_false() -// { -// subscribePrepare(); -// conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// sender.sendEvent("MarketData", attributes); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); -// Thread.Sleep(1000); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_user_error() -// { -// subscribePrepare(); -// String re = null; -// Handler1 handler1 = new Handler1(); -// try -// { -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin123", "123456"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual(true, re.Contains("The user name or password is incorrect")); -// } - - -// [TestMethod] -// public void test_EventClient_subscribe_password_error() -// { -// subscribePrepare(); -// String re = null; -// Handler1 handler1 = new Handler1(); -// try -// { -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456WWW"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual(true, re.Contains("The user name or password is incorrect")); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_admin() -// { -// PrepareUser("user1", "123456"); -// DBConnection conn = new DBConnection(); -// conn.connect(SERVER, PORT, "user1", "123456"); -// conn.run("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;"); -// conn.run("addAccessControl(`inputTable)"); -// conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); -// subscribePrepare(); - -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// Assert.AreEqual(1, re.rows()); -// } -// [TestMethod] -// public void test_EventClient_subscribe_other_user() -// { -// PrepareUser("user1", "123456"); -// DBConnection conn = new DBConnection(); -// conn.connect(SERVER, PORT, "user1", "123456"); -// conn.run("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;"); -// conn.run("addAccessControl(`inputTable)"); -// conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); -// subscribePrepare(); - -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "user1", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// Assert.AreEqual(1, re.rows()); -// } -// [TestMethod] -// public void test_EventClient_other_user_unallow() -// { -// PrepareUser("user1", "123456"); -// PrepareUser("user2", "123456"); -// DBConnection conn = new DBConnection(); -// conn.connect(SERVER, PORT, "user1", "123456"); -// conn.run("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;"); -// conn.run("addAccessControl(`inputTable)"); -// EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "comment1" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); - -// List eventTimeFields = new List() { "timestamp"}; -// List commonFields = new List() { "comment1" }; -// sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// String re = null; -// Handler1 handler1 = new Handler1(); -// try -// { -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "user2", "123456"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual(true, re.Contains("No access to shared table [inputTable]")); -// } -// [TestMethod] -// public void test_EventClient_subscribe_unsubscribe_resubscribe() -// { -// subscribePrepare(); -// conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// sender.sendEvent("MarketData", attributes); -// Handler handler = new Handler(); -// for (int i = 0; i < 10; i++) -// { -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(200); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(200); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// Assert.AreEqual(20, re.rows()); -// } -// [TestMethod] -// public void test_EventClient_subscribe_duplicated() -// { -// subscribePrepare(); -// Handler1 handler1 = new Handler1(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); -// String re = null; -// try -// { -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual(true, re.Contains("already be subscribed")); -// } - -// [TestMethod] -// public void test_EventClient_not_subscribe_unsubscribe() -// { -// subscribePrepare(); -// String re = null; -// try -// { -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Console.WriteLine(re); -// Assert.AreEqual(true, re.Contains("/inputTable/test1 doesn't exist.")); - -// } - -// [TestMethod] -// public void test_EventClient_unsubscribe_duplicated() -// { -// subscribePrepare(); -// Handler1 handler1 = new Handler1(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// String re = null; -// try -// { -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Console.WriteLine(re); -// Assert.AreEqual(true, re.Contains("/inputTable/test1 doesn't exist.")); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_haStreamTable() -// { -// String script = "try{\ndropStreamTable(`inputTable)\n}catch(ex){\n}\n" + -// "table = table(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]);\n" + -// "haStreamTable(" + HASTREAM_GROUPID + ", table, `inputTable, 100000);\n" + -// "share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;\n"; -// conn.run(script); -// EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "comment1" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); - -// List eventTimeFields = new List() { "timestamp" }; -// List commonFields = new List() { "comment1" }; - -// sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); - -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// Assert.AreEqual(1, re.rows()); -// } -// //[TestMethod] -// public void test_EventClient_subscribe_haStreamTable_leader() -// { -// BasicString StreamLeaderTmp = (BasicString)conn.run(String.Format("getStreamingLeader(%d)", HASTREAM_GROUPID)); -// String StreamLeader = StreamLeaderTmp.getString(); -// BasicString StreamLeaderSERVERTmp = (BasicString)conn.run(String.Format("(exec SERVER from rpc(getControllerAlias(), getClusterPerf) where name=\"{0}\")[0]", StreamLeader)); -// String StreamLeaderSERVER = StreamLeaderSERVERTmp.getString(); -// BasicInt StreamLeaderPortTmp = (BasicInt)conn.run(String.Format("(exec port from rpc(getControllerAlias(), getClusterPerf) where mode = 0 and name=\"{0}\")[0]", StreamLeader)); -// int StreamLeaderPort = StreamLeaderPortTmp.getInt(); -// Console.Out.WriteLine(StreamLeaderSERVER); -// Console.Out.WriteLine(StreamLeaderPort); -// DBConnection conn1 = new DBConnection(); -// conn1.connect(StreamLeaderSERVER, StreamLeaderPort, "admin", "123456"); -// String script = "try{\ndropStreamTable(`inputTable_1)\n}catch(ex){\n}\n" + -// "table = table(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]);\n" + -// "haStreamTable(" + HASTREAM_GROUPID + ", table, `inputTable_1, 100000);\n" + -// "share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;\n"; -// conn1.run(script); - -// EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "comment1" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "timestamp" }; -// List commonFields = new List() { "comment1" }; - -// sender = new EventSender(conn, "inputTable_1", eventSchemas, eventTimeFields, commonFields); -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// Handler handler = new Handler(); -// client.subscribe(StreamLeaderSERVER, StreamLeaderPort, "inputTable_1", "test1", handler, -1, true, "admin", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn1.run("select * from outputTable"); -// Assert.AreEqual(1, re.rows()); -// Assert.AreEqual("2024.03.22T10:45:03.100", re.getColumn(0).get(0).getString()); -// Assert.AreEqual("123456", re.getColumn(1).get(0).getString()); -// client.unsubscribe(StreamLeaderSERVER, StreamLeaderPort, "inputTable_1", "test1"); -// } - -// //[TestMethod]//not support -// public void test_EventClient_subscribe_haStreamTable_follower() -// { -// String script0 = "leader = getStreamingLeader(" + HASTREAM_GROUPID + ");\n" + -// "groupSitesStr = (exec sites from getStreamingRaftGroups() where id ==" + HASTREAM_GROUPID + ")[0];\n" + -// "groupSites = split(groupSitesStr, \",\");\n" + -// "followerInfo = exec top 1 * from rpc(getControllerAlias(), getClusterPerf) where site in groupSites and name!=leader;"; -// conn.run(script0); -// BasicString StreamFollowerSERVERTmp = (BasicString)conn.run("(exec SERVER from followerInfo)[0]"); -// String StreamFollowerSERVER = StreamFollowerSERVERTmp.getString(); -// BasicInt StreamFollowerPortTmp = (BasicInt)conn.run("(exec port from followerInfo)[0]"); -// int StreamFollowerPort = StreamFollowerPortTmp.getInt(); -// Console.Out.WriteLine(StreamFollowerSERVER); -// Console.Out.WriteLine(StreamFollowerPort); -// DBConnection conn1 = new DBConnection(); -// conn1.connect(StreamFollowerSERVER, StreamFollowerPort, "admin", "123456"); -// String script = "try{\ndropStreamTable(`inputTable_1)\n}catch(ex){\n}\n" + -// "table = table(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]);\n" + -// "haStreamTable(" + HASTREAM_GROUPID + ", table, `inputTable_1, 100000);\n" + -// "share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;\n"; -// conn1.run(script); -// EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "comment1" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "timestamp" }; -// List commonFields = new List() { "comment1" }; -// sender = new EventSender(conn, "inputTable_1", eventSchemas, eventTimeFields, commonFields); -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// List attributes = new List(); -// attributes.Add(new BasicTimestamp(10)); -// attributes.Add(new BasicString("123456")); -// Handler handler = new Handler(); -// client.subscribe(StreamFollowerSERVER, StreamFollowerPort, "inputTable_1", "test1", handler, -1, true, "user1", "123456"); -// sender.sendEvent("MarketData", attributes); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn1.run("select * from outputTable"); -// Assert.AreEqual(1, re.rows()); -// Assert.AreEqual("2024.03.22T10:45:03.100", re.getColumn(0).get(0).getString()); -// Assert.AreEqual("123456", re.getColumn(1).get(0).getString()); -// client.unsubscribe(StreamFollowerSERVER, StreamFollowerPort, "inputTable_1", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_special_char() -// { -// String script = "share streamTable(1:0, `timestamp`time, [STRING,TIMESTAMP]) as outputTable;\n" + -// "class MarketData{\n" + -// "string :: STRING\n" + -// "timestamp :: TIMESTAMP\n" + -// "def MarketData(s,t){\n" + -// "string = s\n" + -// "timestamp = t\n" + -// "}\n" + -// "}\n" + -// "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs,array(STRING, 0) as comment1,array(TIMESTAMP, 0) as comment2 ) as intput\n" + -// "schema = table(1:0, `eventType`eventKeys`eventValuesTypeString`eventValueTypeID`eventValuesFormID, [STRING, STRING, STRING, INT[], INT[]])\n" + -// "insert into schema values(\"MarketData\", \"string,timestamp\", \"STRING,TIMESTAMP\", [18 12], [0 0])\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schema, outputTable=intput, commonField = [\"string\",\"timestamp\"])\n"; -// conn.run(script); -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,STRING,TIMESTAMP]) as inputTable;"); -// EventSchema scheme = new EventSchema("MarketData", new List { "_market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "_market", "time" }; - -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// List attributes = new List(); -// attributes.Add(new BasicString("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ")); -// attributes.Add(new BasicTimestamp(1)); -// sender.sendEvent("MarketData", attributes); - -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "intput", "test1", handler, -1, true, "admin", "123456"); -// conn.run(" marketData1 = MarketData(\"!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; \",timestamp(1));\n appendEvent(inputSerializer, marketData1)"); -// Thread.Sleep(1000); - -// BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// BasicTable re1 = (BasicTable)conn.run("select * from intput"); -// BasicTable re2 = (BasicTable)conn.run("select * from outputTable"); - -// checkData(re, re1); -// Console.Out.WriteLine(re2.getString()); -// Assert.AreEqual("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ", re2.getColumn(0).get(0).getString()); -// client.unsubscribe(SERVER, PORT, "intput", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_all_dateType_1() -// { -// String script = "share streamTable(1:0, `eventTime`eventType`blobs, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + -// "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippAddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; -// conn.run(script); -// String script1 = "class event_all_dateType{\n" + -// "\tboolv :: BOOL\n" + -// "\tcharv :: CHAR\n" + -// "\tshortv :: SHORT\n" + -// "\tintv :: INT\n" + -// "\tlongv :: LONG\n" + -// "\tdoublev :: DOUBLE \n" + -// "\tfloatv :: FLOAT\n" + -// "\tdatev :: DATE\n" + -// "\tmonthv :: MONTH\n" + -// "\ttimev :: TIME\n" + -// "\tminutev :: MINUTE\n" + -// "\tsecondv :: SECOND\n" + -// "\tdatetimev :: DATETIME \n" + -// "\ttimestampv :: TIMESTAMP\n" + -// "\tnanotimev :: NANOTIME\n" + -// "\tnanotimestampv :: NANOTIMESTAMP\n" + -// // "\tsymbolv :: SYMBOL\n" + -// "\tstringv :: STRING\n" + -// "\tdatehourv :: DATEHOUR\n" + -// "\tuuidv :: UUID\n" + -// "\tippAddrv :: IPAddR \n" + -// "\tint128v :: INT128\n" + -// "\tblobv :: BLOB\n" + -// " def event_all_dateType(bool, char, short, int, long, double, float, date, month, time, minute, second, datetime, timestamp, nanotime, nanotimestamp, string, datehour, uuid, ippAddr, int128, blob){\n" + -// "\tboolv = bool\n" + -// "\tcharv = char\n" + -// "\tshortv = short\n" + -// "\tintv = int\n" + -// "\tlongv = long\n" + -// "\tdoublev = double\n" + -// "\tfloatv = float\n" + -// "\tdatev = date\n" + -// "\tmonthv = month\n" + -// "\ttimev = time\n" + -// "\tminutev = minute\n" + -// "\tsecondv = second\n" + -// "\tdatetimev = datetime\n" + -// "\ttimestampv = timestamp\n" + -// "\tnanotimev = nanotime\n" + -// "\tnanotimestampv = nanotimestamp\n" + -// // "\tsymbolv = symbol\n" + -// "\tstringv = string\n" + -// "\tdatehourv = datehour\n" + -// "\tuuidv = uuid\n" + -// "\tippAddrv = ippAddr\n" + -// "\tint128v = int128\n" + -// "\tblobv = blob\n" + -// " \t}\n" + -// "} \n" + -// "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// "eventType = 'event_all_dateType'\n" + -// "eventKeys = 'boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,stringv,datehourv,uuidv,ippAddrv,int128v,blobv';\n" + -// "typeV = [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE,MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB];\n" + -// "formV = [SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR];\n" + -// "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// "share streamTable(array(TIMESTAMP, 0) as eventTime, array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput;\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput, eventTimeField = \"timestampv\");"; -// conn.run(script1); -// EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "datetimev" }; -// List commonFields = new List(); -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "intput", "test1", handler, -1, true, "admin", "123456"); - -// Preparedata(1); -// String script2 = "data1=select * from data;\n" + -// "i = 0\n" + -// "\tall_data_type1=event_all_dateType(data1.row(i)[`boolv], data1.row(i)[`charv], data1.row(i)[`shortv], data1.row(i)[`intv],data1.row(i)[`longv], data1.row(i)[`doublev], data1.row(i)[`floatv], data1.row(i)[`datev],data1.row(i)[`monthv], data1.row(i)[`timev], data1.row(i)[`minutev], data1.row(i)[`secondv],data1.row(i)[`datetimev], data1.row(i)[`timestampv], data1.row(i)[`nanotimev], data1.row(i)[`nanotimestampv], data1.row(i)[`stringv], data1.row(i)[`datehourv], data1.row(i)[`uuidv], data1.row(i)[`ippaddrv],data1.row(i)[`int128v], blob(data1.row(i)[`blobv]))\n" + -// "\tappendEvent(inputSerializer, all_data_type1)\n"; -// conn.run(script2); -// Thread.Sleep(10000); -// BasicTable bt1 = (BasicTable)conn.run("select * from data;"); -// Assert.AreEqual(1, bt1.rows()); -// Thread.Sleep(20000); -// BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); -// Assert.AreEqual(1, bt2.rows()); -// checkData(bt1, bt2); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_all_dateType_100() -// { -// String script = "share streamTable(1:0, `eventTime`eventType`blobs, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + -// "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippAddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; -// conn.run(script); -// String script1 = "class event_all_dateType{\n" + -// "\tboolv :: BOOL\n" + -// "\tcharv :: CHAR\n" + -// "\tshortv :: SHORT\n" + -// "\tintv :: INT\n" + -// "\tlongv :: LONG\n" + -// "\tdoublev :: DOUBLE \n" + -// "\tfloatv :: FLOAT\n" + -// "\tdatev :: DATE\n" + -// "\tmonthv :: MONTH\n" + -// "\ttimev :: TIME\n" + -// "\tminutev :: MINUTE\n" + -// "\tsecondv :: SECOND\n" + -// "\tdatetimev :: DATETIME \n" + -// "\ttimestampv :: TIMESTAMP\n" + -// "\tnanotimev :: NANOTIME\n" + -// "\tnanotimestampv :: NANOTIMESTAMP\n" + -// // "\tsymbolv :: SYMBOL\n" + -// "\tstringv :: STRING\n" + -// "\tdatehourv :: DATEHOUR\n" + -// "\tuuidv :: UUID\n" + -// "\tippAddrv :: IPAddR \n" + -// "\tint128v :: INT128\n" + -// "\tblobv :: BLOB\n" + -// " def event_all_dateType(bool, char, short, int, long, double, float, date, month, time, minute, second, datetime, timestamp, nanotime, nanotimestamp, string, datehour, uuid, ippAddr, int128, blob){\n" + -// "\tboolv = bool\n" + -// "\tcharv = char\n" + -// "\tshortv = short\n" + -// "\tintv = int\n" + -// "\tlongv = long\n" + -// "\tdoublev = double\n" + -// "\tfloatv = float\n" + -// "\tdatev = date\n" + -// "\tmonthv = month\n" + -// "\ttimev = time\n" + -// "\tminutev = minute\n" + -// "\tsecondv = second\n" + -// "\tdatetimev = datetime\n" + -// "\ttimestampv = timestamp\n" + -// "\tnanotimev = nanotime\n" + -// "\tnanotimestampv = nanotimestamp\n" + -// // "\tsymbolv = symbol\n" + -// "\tstringv = string\n" + -// "\tdatehourv = datehour\n" + -// "\tuuidv = uuid\n" + -// "\tippAddrv = ippAddr\n" + -// "\tint128v = int128\n" + -// "\tblobv = blob\n" + -// " \t}\n" + -// "} \n" + -// "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// "eventType = 'event_all_dateType'\n" + -// "eventKeys = 'boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,stringv,datehourv,uuidv,ippAddrv,int128v,blobv';\n" + -// "typeV = [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE,MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB];\n" + -// "formV = [SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR];\n" + -// "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// "share streamTable(array(TIMESTAMP, 0) as eventTime, array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput;\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput, eventTimeField = \"timestampv\");"; -// conn.run(script1); -// EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "datetimev" }; -// List commonFields = new List(); -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "intput", "test1", handler, -1, true, "admin", "123456"); - -// Preparedata(100); -// String script2 = "data1=select * from data;\n" + -// "for(i in 0..99){\n" + -// "\tall_data_type1=event_all_dateType(data1.row(i)[`boolv], data1.row(i)[`charv], data1.row(i)[`shortv], data1.row(i)[`intv],data1.row(i)[`longv], data1.row(i)[`doublev], data1.row(i)[`floatv], data1.row(i)[`datev],data1.row(i)[`monthv], data1.row(i)[`timev], data1.row(i)[`minutev], data1.row(i)[`secondv],data1.row(i)[`datetimev], data1.row(i)[`timestampv], data1.row(i)[`nanotimev], data1.row(i)[`nanotimestampv],data1.row(i)[`stringv], data1.row(i)[`datehourv], data1.row(i)[`uuidv], data1.row(i)[`ippaddrv],data1.row(i)[`int128v], blob(data1.row(i)[`blobv]))\n" + -// "\tappendEvent(inputSerializer, all_data_type1)\n" + -// "\t}"; -// conn.run(script2); -// Thread.Sleep(10000); -// BasicTable bt1 = (BasicTable)conn.run("select * from data;"); -// Assert.AreEqual(100, bt1.rows()); -// Thread.Sleep(20000); -// BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); -// Assert.AreEqual(100, bt2.rows()); -// checkData(bt1, bt2); -// } - -// // [TestMethod] -// // public void test_EventClient_all_dateType_vector() { -// // Preparedata_array(100,10); -// // String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n"+ -// // "colNames=\"col\"+string(1..25);\n" + -// // "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[], DATEHOUR[],UUID[],IPADDR[],INT128[],POINT[],COMPLEX[],DECIMAL32(2)[],DECIMAL64(7)[],DECIMAL128(10)[]];\n" + -// // "share table(1:0,colNames,colTypes) as outputTable;\n" ; -// // conn.run(script); -// // String script1 ="class event_all_array_dateType{\n" + -// // "\tboolv :: BOOL VECTOR\n" + -// // "\tcharv :: CHAR VECTOR\n" + -// // "\tshortv :: SHORT VECTOR\n" + -// // "\tintv :: INT VECTOR\n" + -// // "\tlongv :: LONG VECTOR\n" + -// // "\tdoublev :: DOUBLE VECTOR\n" + -// // "\tfloatv :: FLOAT VECTOR\n" + -// // "\tdatev :: DATE VECTOR\n" + -// // "\tmonthv :: MONTH VECTOR\n" + -// // "\ttimev :: TIME VECTOR\n" + -// // "\tminutev :: MINUTE VECTOR\n" + -// // "\tsecondv :: SECOND VECTOR\n" + -// // "\tdatetimev :: DATETIME VECTOR \n" + -// // "\ttimestampv :: TIMESTAMP VECTOR\n" + -// // "\tnanotimev :: NANOTIME VECTOR\n" + -// // "\tnanotimestampv :: NANOTIMESTAMP VECTOR\n" + -// // "\t//stringv :: STRING VECTOR\n" + -// // "\tdatehourv :: DATEHOUR VECTOR\n" + -// // "\tuuidv :: UUID VECTOR\n" + -// // "\tippaddrv :: IPADDR VECTOR\n" + -// // "\tint128v :: INT128 VECTOR\n" + -// // "\t//blobv :: BLOB VECTOR\n" + -// // "\tpointv :: POINT VECTOR\n" + -// // "\tcomplexv :: COMPLEX VECTOR\n" + -// // "\tdecimal32v :: DECIMAL32(3) VECTOR\n" + -// // "\tdecimal64v :: DECIMAL64(8) VECTOR\n" + -// // "\tdecimal128v :: DECIMAL128(10) VECTOR \n" + -// // " def event_all_array_dateType(bool, char, short, int, long, double, float, date, month, time, minute, second, datetime, timestamp, nanotime, nanotimestamp, datehour, uuid, ippaddr, int128,point, complex, decimal32, decimal64, decimal128){\n" + -// // "\tboolv = bool\n" + -// // "\tcharv = char\n" + -// // "\tshortv = short\n" + -// // "\tintv = int\n" + -// // "\tlongv = long\n" + -// // "\tdoublev = double\n" + -// // "\tfloatv = float\n" + -// // "\tdatev = date\n" + -// // "\tmonthv = month\n" + -// // "\ttimev = time\n" + -// // "\tminutev = minute\n" + -// // "\tsecondv = second\n" + -// // "\tdatetimev = datetime\n" + -// // "\ttimestampv = timestamp\n" + -// // "\tnanotimev = nanotime\n" + -// // "\tnanotimestampv = nanotimestamp\n" + -// // "\t//stringv = string\n" + -// // "\tdatehourv = datehour\n" + -// // "\tuuidv = uuid\n" + -// // "\tippaddrv = ippaddr\n" + -// // "\tint128v = int128\n" + -// // "\t//blobv = blob\n" + -// // "\tpointv = point\n" + -// // "\tcomplexv = complex\n" + -// // "\tdecimal32v = decimal32\n" + -// // "\tdecimal64v = decimal64\n" + -// // "\tdecimal128v = decimal128\n" + -// // " \t}\n" + -// // "} \n" + -// // "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// // "eventType = 'event_all_dateType'\n" + -// // "eventKeys = 'boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,datehourv,uuidv,ippaddrv,int128v,pointv,complexv,decimal32v,decimal64v,decimal128v';\n" + -// // "typeV = [BOOL[], CHAR[], SHORT[], INT[], LONG[], DOUBLE[], FLOAT[], DATE[],MONTH[], TIME[], MINUTE[], SECOND[], DATETIME[], TIMESTAMP[], NANOTIME[], NANOTIMESTAMP[], DATEHOUR[], UUID[], IPADDR[], INT128[], POINT[], COMPLEX[], DECIMAL32(3)[], DECIMAL64(8)[], DECIMAL128(10)[]];\n" + -// // "formV = [VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR];\n" + -// // "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// // "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + -// // "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// // "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; -// // conn.run(script1); -// // EventSchema scheme = new EventSchema(); -// // scheme.setEventType("event_all_array_dateType"); -// // scheme.setFieldNames(Arrays.asList("boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippaddrv", "int128v", "pointv", "complexv", "decimal32v", "decimal64v", "decimal128v")); -// // scheme.setFieldTypes(Arrays.asList(DT_BOOL, DT_BYTE, DT_SHORT, DT_INT, DT_LONG, DT_DOUBLE, DT_FLOAT, DT_DATE,DT_MONTH, DT_TIME, DT_MINUTE, DT_SECOND, DT_DATETIME, DT_TIMESTAMP, DT_NANOTIME, DT_NANOTIMESTAMP, DT_DATEHOUR, DT_UUID, DT_IPADDR, DT_INT128, DT_POINT, DT_COMPLEX, DT_DECIMAL32, DT_DECIMAL64, DT_DECIMAL128)); -// // scheme.setFieldForms(Arrays.asList( DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR)); -// // List eventSchemas = Collections.singletonList(scheme); -// // List eventTimeFields = new List(); -// // List commonFields = new List(); -// // EventSender sender = EventSender.createEventSender(eventSchemas, eventTimeFields, commonFields); -// // sender.connect(conn,"inputTable"); -// // -// // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// // client.subscribe(SERVER, PORT, "intput1", "test1", handler, -1, true, "admin", "123456"); -// // -// // Preparedata_array(100,10); -// // BasicTable bt = (BasicTable)conn.run("select * from data"); -// // String script2 = "data1=select * from data;\n" + -// // "for(i in 0..9){\n" + -// // "\tevent_all_array_dateType1=event_all_array_dateType(data1.row(i)[`cbool], data1.row(i)[`cchar], data1.row(i)[`cshort], data1.row(i)[`cint],data1.row(i)[`clong], data1.row(i)[`cdouble], data1.row(i)[`cfloat], data1.row(i)[`cdate], data1.row(i)[`cmonth], data1.row(i)[`ctime], data1.row(i)[`cminute], data1.row(i)[`csecond], data1.row(i)[`cdatetime], data1.row(i)[`ctimestamp], data1.row(i)[`cnanotime], data1.row(i)[`cnanotimestamp], data1.row(i)[`cdatehour], data1.row(i)[`cuuid], data1.row(i)[`cipaddr], data1.row(i)[`cint128],data1.row(i)[`cpoint], data1.row(i)[`ccomplex], data1.row(i)[`cdecimal32], data1.row(i)[`cdecimal64], data1.row(i)[`cdecimal128])\n" + -// // "\tappendEvent(inputSerializer, event_all_array_dateType1)\n" + -// // "\t}" ; -// // conn.run(script2); -// // Thread.Sleep(10000); -// // for(int i=0;i attributes = new List(); -// // for(int j=0;j { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128 }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); - -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); - -// Handler_array handler_Array = new Handler_array(); -// client.subscribe(SERVER, PORT, "intput1", "test1", handler_Array, -1, true, "admin", "123456"); - -// Preparedata_array(100, 10); -// BasicTable bt = (BasicTable)conn.run("select * from data"); -// String script2 = "data1=select * from data;\n" + -// "for(i in 0..9){\n" + -// "\tevent_all_array_dateType1=event_all_array_dateType(data1.row(i)[`cbool], data1.row(i)[`cchar], data1.row(i)[`cshort], data1.row(i)[`cint],data1.row(i)[`clong], data1.row(i)[`cdouble], data1.row(i)[`cfloat], data1.row(i)[`cdate], data1.row(i)[`cmonth], data1.row(i)[`ctime], data1.row(i)[`cminute], data1.row(i)[`csecond], data1.row(i)[`cdatetime], data1.row(i)[`ctimestamp], data1.row(i)[`cnanotime], data1.row(i)[`cnanotimestamp], data1.row(i)[`cdatehour], data1.row(i)[`cuuid], data1.row(i)[`cipaddr], data1.row(i)[`cint128])\n" + -// "\tappendEvent(inputSerializer, event_all_array_dateType1)\n" + -// "\t}"; -// conn.run(script2); -// Thread.Sleep(5000); -// for (int i = 0; i < bt.rows(); i++) -// { -// List attributes = new List(); -// for (int j = 0; j < bt.columns(); j++) -// { -// IEntity pt = bt.getColumn(j).getEntity(i); -// Console.Out.WriteLine(pt.getDataType()); -// Console.Out.WriteLine(i + "У " + j + "У" + pt.getString()); -// attributes.Add(pt); -// } -// sender.sendEvent("event_all_array_dateType", attributes); -// } -// Thread.Sleep(1000); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(10, bt1.rows()); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); -// Assert.AreEqual(10, bt2.rows()); -// checkData(bt1, bt2); -// Thread.Sleep(10000); -// BasicTable bt3 = (BasicTable)conn.run("select * from outputTable;"); -// Assert.AreEqual(10, bt3.rows()); -// checkData(bt, bt3); -// } - -// ////[TestMethod] -// //public void test_EventClient_all_dateType_vector_decimal() -// //{ -// // String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + -// // "colNames=\"col\"+string(1..3);\n" + -// // "colTypes=[DECIMAL32(2)[],DECIMAL64(7)[],DECIMAL128(19)[]];\n" + -// // "share table(1:0,colNames,colTypes) as outputTable;\n"; -// // conn.run(script); -// // String script1 = "class event_all_array_dateType{\n" + -// // "\tdecimal32v :: DECIMAL32(2) VECTOR\n" + -// // "\tdecimal64v :: DECIMAL64(7) VECTOR\n" + -// // "\tdecimal128v :: DECIMAL128(19) VECTOR \n" + -// // " def event_all_array_dateType(decimal32, decimal64, decimal128){\n" + -// // "\tdecimal32v = decimal32\n" + -// // "\tdecimal64v = decimal64\n" + -// // "\tdecimal128v = decimal128\n" + -// // " \t}\n" + -// // "} \n" + -// // "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// // "eventType = 'event_all_array_dateType'\n" + -// // "eventKeys = 'decimal32v,decimal64v,decimal128v';\n" + -// // "typeV = [ DECIMAL32(2)[], DECIMAL64(7)[], DECIMAL128(19)[]];\n" + -// // "formV = [ VECTOR, VECTOR, VECTOR];\n" + -// // "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// // "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + -// // "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// // "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; -// // conn.run(script1); -// // EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "decimal32v", "decimal64v", "decimal128v" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }, new List { 2 ,7,19}); -// // List eventSchemas = new List(); -// // eventSchemas.Add(scheme); -// // List eventTimeFields = new List(); -// // List commonFields = new List(); - -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// // Handler_array_decimal handler_array_decimal = new Handler_array_decimal(); -// // client.subscribe(SERVER, PORT, "intput1", "test1", handler_array_decimal, -1, true, "admin", "123456"); - -// // Preparedata_array_decimal(100, 10); -// // BasicTable bt = (BasicTable)conn.run("select * from data"); -// // String script2 = "data1=select * from data;\n" + -// // "for(i in 0..9){\n" + -// // "\tevent_all_array_dateType1=event_all_array_dateType( data1.row(i)[`cdecimal32], data1.row(i)[`cdecimal64], data1.row(i)[`cdecimal128])\n" + -// // "\tappendEvent(inputSerializer, event_all_array_dateType1)\n" + -// // "\t}"; -// // conn.run(script2); -// // Thread.Sleep(5000); -// // for (int i = 0; i < bt.rows(); i++) -// // { -// // List attributes = new List(); -// // for (int j = 0; j < bt.columns(); j++) -// // { -// // IEntity pt = bt.getColumn(j).getEntity(i); -// // Console.Out.WriteLine(pt.getDataType()); -// // Console.Out.WriteLine(i + "У " + j + "У" + pt.getString()); -// // attributes.Add(pt); -// // } -// // sender.sendEvent("event_all_array_dateType", attributes); -// // } -// // Thread.Sleep(1000); -// // BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// // Assert.AreEqual(10, bt1.rows()); -// // BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); -// // Assert.AreEqual(10, bt2.rows()); -// // checkData(bt1, bt2); -// // Thread.Sleep(10000); -// // BasicTable bt3 = (BasicTable)conn.run("select * from outputTable;"); -// // Assert.AreEqual(10, bt3.rows()); -// // checkData(bt, bt3); -// //} - - -// [TestMethod]//not support -// public void test_EventClient_all_dateType_array() -// { -// String script0 = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + -// "colNames=\"col\"+string(1..20);\n" + -// "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[], DATEHOUR[],UUID[],IPADDR[],INT128[]];\n" + -// "share table(1:0,colNames,colTypes) as outputTable;\n"; -// conn.run(script0); - - -// EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL_ARRAY, DATA_TYPE.DT_BYTE_ARRAY, DATA_TYPE.DT_SHORT_ARRAY, DATA_TYPE.DT_INT_ARRAY, DATA_TYPE.DT_LONG_ARRAY, DATA_TYPE.DT_DOUBLE_ARRAY, DATA_TYPE.DT_FLOAT_ARRAY, DATA_TYPE.DT_DATE_ARRAY, DATA_TYPE.DT_MONTH_ARRAY, DATA_TYPE.DT_TIME_ARRAY, DATA_TYPE.DT_MINUTE_ARRAY, DATA_TYPE.DT_SECOND_ARRAY, DATA_TYPE.DT_DATETIME_ARRAY, DATA_TYPE.DT_TIMESTAMP_ARRAY, DATA_TYPE.DT_NANOTIME_ARRAY, DATA_TYPE.DT_NANOTIMESTAMP_ARRAY, DATA_TYPE.DT_DATEHOUR_ARRAY, DATA_TYPE.DT_UUID_ARRAY, DATA_TYPE.DT_IPADDR_ARRAY, DATA_TYPE.DT_INT128_ARRAY }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n"; -// conn.run(script); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler_array handler_array = new Handler_array(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler_array, -1, true, "admin", "123456"); -// Preparedata_array(100, 10); -// BasicTable bt = (BasicTable)conn.run("select * from data"); -// List attributes = new List(); -// for (int j = 0; j < bt.columns(); j++) -// { -// IEntity pt = (bt.getColumn(j)); -// Console.Out.WriteLine(pt.getDataType()); -// Console.Out.WriteLine(j + "У" + pt.getObject().ToString()); -// attributes.Add(pt); -// } -// sender.sendEvent("event_all_array_dateType", attributes); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(1, bt1.rows()); -// Assert.AreEqual(1, bt1.rows()); -// Thread.Sleep(2000); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } - -// //[TestMethod] -// public void test_EventClient_reconnect() -// { -// String script = "share streamTable(1:0, `timestamp`time`commonKey, [TIMESTAMP,TIME,TIMESTAMP]) as outputTable;\n" + -// "share streamTable(1:0, `string`timestamp`commonKey, [STRING,TIMESTAMP,TIMESTAMP]) as outputTable1;\n" + -// "class MarketData{\n" + -// "timestamp :: TIMESTAMP\n" + -// "time :: TIME\n" + -// "def MarketData(t,t1){\n" + -// "timestamp = t\n" + -// "time = t1\n" + -// "}\n" + -// "}\n" + -// "class MarketData1{\n" + -// "string :: STRING\n" + -// "timestamp :: TIMESTAMP\n" + -// "def MarketData1(s,t){\n" + -// "string = s\n" + -// "timestamp = t\n" + -// "}\n" + -// "}\n" + -// "share streamTable(array(TIMESTAMP, 0) as timestamp, array(STRING, 0) as eventType, array(BLOB, 0) as blobs,array(TIMESTAMP, 0) as commonKey) as intput\n" + -// "schema = table(1:0, `eventType`eventKeys`eventValuesTypeString`eventValueTypeID`eventValuesFormID, [STRING, STRING, STRING, INT[], INT[]])\n" + -// "insert into schema values(\"MarketData\", \"timestamp,time\", \"TIMESTAMP,TIME\", [12 8], [0 0])\n" + -// "insert into schema values(\"MarketData1\", \"string,timestamp\", \"STRING,TIMESTAMP\", [18 12], [0 0])\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schema, outputTable=intput, eventTimeField = \"timestamp\", commonField = \"timestamp\")\n"; -// conn.run(script); -// EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "time" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("MarketData1", new List { "string", "timestamp" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); - -// List eventTimeFields = new List() { "time", "timestamp" }; -// List commonFields = new List() { "timestamp" }; - -// EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler1 handler1 = new Handler1(); -// client.subscribe(SERVER, PORT, "intput", "test1", handler1, -1, true, "admin", "123456"); -// conn.run("marketData1 = MarketData(now(),time(1));\n marketData2 = MarketData1(\"tesrtttt\",now());\n appendEvent(inputSerializer, [marketData1,marketData2])"); -// Thread.Sleep(1000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable"); -// BasicTable re1 = (BasicTable)conn.run("select * from outputTable1"); -// BasicTable re2 = (BasicTable)conn.run("select timestamp from intput"); - -// Assert.AreEqual(1, re.rows()); -// Assert.AreEqual(1, re1.rows()); -// Assert.AreEqual(re2.getColumn(0).get(0).getString(), re.getColumn(0).get(0).getString()); -// Assert.AreEqual("00:00:00.001", re.getColumn(1).get(0).getString()); -// Assert.AreEqual("tesrtttt", re1.getColumn(0).get(0).getString()); -// Assert.AreEqual(re2.getColumn(0).get(0).getString(), re1.getColumn(1).get(0).getString()); -// client.unsubscribe(SERVER, PORT, "intput", "test1"); -// } - - - - -// } -//} +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using dolphindb; +using dolphindb.data; +using dolphindb.streaming; +using System.Threading; +using dolphindb_config; +using dolphindb.streaming.cep; + +namespace dolphindb_csharp_api_test.cep_test +{ + [TestClass] + public class EventClientTest + { + + public static DBConnection streamConn; + private string SERVER = MyConfigReader.SERVER; + static private int PORT = MyConfigReader.PORT; + private readonly string USER = MyConfigReader.USER; + private readonly string PASSWORD = MyConfigReader.PASSWORD; + private string LOCALHOST = MyConfigReader.LOCALHOST; + private readonly int LOCALPORT = MyConfigReader.LOCALPORT; + static private int SUB_FLAG = MyConfigReader.SUB_FLAG; + private string NODE1_HOST = MyConfigReader.NODE1_HOST; + private readonly int NODE1_PORT = MyConfigReader.NODE1_PORT; + public static string[] HASTREAM_GROUP = MyConfigReader.HASTREAM_GROUP; + private readonly int HASTREAM_GROUPID = MyConfigReader.HASTREAM_GROUPID; + private readonly int TIMEOUT = 10000; + public static DBConnection conn; + static EventSender sender; + static EventSchema scheme; + static EventClient client; + + public void clear_env() + { + try + { + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT, "admin", "123456"); + conn.run("a = getStreamingStat().pubTables\n" + + "for(i in a){\n" + + "\tstopPublishTable(i.subscriber.split(\":\")[0],int(i.subscriber.split(\":\")[1]),i.tableName,i.actions)\n" + + "}"); + conn.run("def getAllShare(){\n" + + "\treturn select name from objs(true) where shared=1\n" + + "\t}\n" + + "\n" + + "def clearShare(){\n" + + "\tlogin(`admin,`123456)\n" + + "\tallShare=exec name from pnodeRun(getAllShare)\n" + + "\tfor(i in allShare){\n" + + "\t\ttry{\n" + + "\t\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],clearTablePersistence,objByName(i))\n" + + "\t\t\t}catch(ex1){}\n" + + "\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],undef,i,SHARED)\n" + + "\t}\n" + + "\ttry{\n" + + "\t\tPST_DIR=rpc(getControllerAlias(),getDataNodeConfig{getNodeAlias()})['persistenceDir']\n" + + "\t}catch(ex1){}\n" + + "}\n" + + "clearShare()"); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + + [TestInitialize] + public void TestInitialize() + { + conn = new DBConnection(); + conn.connect(SERVER, PORT, "admin", "123456"); + clear_env(); + } + + [TestCleanup] + public void TestCleanup() + { + conn.close(); + try { client.unsubscribe(SERVER, PORT, "inputTable", "test1"); } catch (Exception ex) { } + try { client.unsubscribe(SERVER, PORT, "intput", "test1"); } catch (Exception ex) { } + try { client.unsubscribe(SERVER, PORT, "inputTable", "StreamingApi"); } catch (Exception ex) { } + try { client.unsubscribe(SERVER, PORT, "intput", "StreamingApi"); } catch (Exception ex) { } + clear_env(); + + } + + public static void Preparedata(long count) + { + String script = "login(`admin, `123456); \n" + + "n=" + count + ";\n" + + "boolv = bool(rand([true, false, NULL], n));\n" + + "charv = char(rand(rand(-100..100, 1000) join take(char(), 4), n));\n" + + "shortv = short(rand(rand(-100..100, 1000) join take(short(), 4), n));\n" + + "intv = int(rand(rand(-100..100, 1000) join take(int(), 4), n));\n" + + "longv = long(rand(rand(-100..100, 1000) join take(long(), 4), n));\n" + + "doublev = double(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n));\n" + + "floatv = float(rand(rand(-100..100, 1000)*0.23 join take(float(), 4), n));\n" + + "datev = date(rand(rand(-100..100, 1000) join take(date(), 4), n));\n" + + "monthv = month(rand(1967.12M+rand(-100..100, 1000) join take(month(), 4), n));\n" + + "timev = time(rand(rand(0..100, 1000) join take(time(), 4), n));\n" + + "minutev = minute(rand(12:13m+rand(-100..100, 1000) join take(minute(), 4), n));\n" + + "secondv = second(rand(12:13:12+rand(-100..100, 1000) join take(second(), 4), n));\n" + + "datetimev = datetime(rand(1969.12.23+rand(-100..100, 1000) join take(datetime(), 4), n));\n" + + "timestampv = timestamp(rand(1970.01.01T00:00:00.023+rand(-100..100, 1000) join take(timestamp(), 4), n));\n" + + "nanotimev = nanotime(rand(12:23:45.452623154+rand(-100..100, 1000) join take(nanotime(), 4), n));\n" + + "nanotimestampv = nanotimestamp(rand(rand(-100..100, 1000) join take(nanotimestamp(), 4), n));\n" + + "symbolv = rand((\"syms\"+string(rand(100, 1000))) join take(string(), 4), n);\n" + + "stringv = rand((\"stringv\"+string(rand(100, 1000))) join take(string(), 4), n);\n" + + "uuidv = rand(rand(uuid(), 1000) join take(uuid(), 4), n);\n" + + "datehourv = datehour(rand(datehour(1969.12.31T12:45:12)+rand(-100..100, 1000) join take(datehour(), 4), n));\n" + + "ippaddrv = rand(rand(ipaddr(), 1000) join take(ipaddr(), 4), n);\n" + + "int128v = rand(rand(int128(), 1000) join take(int128(), 4), n);\n" + + "blobv = blob(string(rand((\"blob\"+string(rand(100, 1000))) join take(\"\", 4), n)));\n" + + "complexv = rand(complex(rand(100, 1000), rand(100, 1000)) join NULL, n);\n" + + "pointv = rand(point(rand(100, 1000), rand(100, 1000)) join NULL, n);\n" + + "decimal32v = decimal32(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 3);\n" + + "decimal64v = decimal64(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 8);\n" + + "decimal128v = decimal128(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 10);\n" + + "share table(boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, stringv, datehourv, uuidv, ippaddrv, int128v, blobv) as data;\n"; + conn.run(script); + } + + public static void Preparedata_array(long count1, long count2) + { + String script1 = "login(`admin, `123456); \n" + + "n=" + count1 + ";\n" + + "m=" + count2 + ";\n" + + "cbool = array(BOOL[]).append!(cut(take([true, false, NULL], n), m))\n" + + "cchar = array(CHAR[]).append!(cut(take(char(-100..100 join NULL), n), m))\n" + + "cshort = array(SHORT[]).append!(cut(take(short(-100..100 join NULL), n), m))\n" + + "cint = array(INT[]).append!(cut(take(-100..100 join NULL, n), m))\n" + + "clong = array(LONG[]).append!(cut(take(long(-100..100 join NULL), n), m))\n" + + "cdouble = array(DOUBLE[]).append!(cut(take(-100..100 join NULL, n) + 0.254, m))\n" + + "cfloat = array(FLOAT[]).append!(cut(take(-100..100 join NULL, n) + 0.254f, m))\n" + + "cdate = array(DATE[]).append!(cut(take(2012.01.01..2012.02.29, n), m))\n" + + "cmonth = array(MONTH[]).append!(cut(take(2012.01M..2013.12M, n), m))\n" + + "ctime = array(TIME[]).append!(cut(take(09:00:00.000 + 0..99 * 1000, n), m))\n" + + "cminute = array(MINUTE[]).append!(cut(take(09:00m..15:59m, n), m))\n" + + "csecond = array(SECOND[]).append!(cut(take(09:00:00 + 0..999, n), m))\n" + + "cdatetime = array(DATETIME[]).append!(cut(take(2012.01.01T09:00:00 + 0..999, n), m))\n" + + "ctimestamp = array(TIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000 + 0..999 * 1000, n), m))\n" + + "cnanotime =array(NANOTIME[]).append!(cut(take(09:00:00.000000000 + 0..999 * 1000000000, n), m))\n" + + "cnanotimestamp = array(NANOTIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000000000 + 0..999 * 1000000000, n), m))\n" + + "cuuid = array(UUID[]).append!(cut(take(uuid([\"5d212a78-cc48-e3b1-4235-b4d91473ee87\", \"5d212a78-cc48-e3b1-4235-b4d91473ee88\", \"5d212a78-cc48-e3b1-4235-b4d91473ee89\", \"\"]), n), m))\n" + + "cdatehour = array(DATEHOUR[]).append!(cut(take(datehour(1..10 join NULL), n), m))\n" + + "cipaddr = array(IPADDR[]).append!(cut(take(ipaddr([\"192.168.100.10\", \"192.168.100.11\", \"192.168.100.14\", \"\"]), n), m))\n" + + "cint128 = array(INT128[]).append!(cut(take(int128([\"e1671797c52e15f763380b45e841ec32\", \"e1671797c52e15f763380b45e841ec33\", \"e1671797c52e15f763380b45e841ec35\", \"\"]), n), m))\n" + + "ccomplex = array( COMPLEX[]).append!(cut(rand(complex(rand(100, 1000), rand(100, 1000)) join NULL, n), m))\n" + + "cpoint = array(POINT[]).append!(cut(rand(point(rand(100, 1000), rand(100, 1000)) join NULL, n), m))\n" + + "cdecimal32 = array(DECIMAL32(2)[]).append!(cut(decimal32(take(-100..100 join NULL, n) + 0.254, 3), m))\n" + + "cdecimal64 = array(DECIMAL64(7)[]).append!(cut(decimal64(take(-100..100 join NULL, n) + 0.25467, 4), m))\n" + + "cdecimal128 = array(DECIMAL128(19)[]).append!(cut(decimal128(take(-100..100 join NULL, n) + 0.25467, 5), m))\n" + + "share table(cbool, cchar, cshort, cint, clong, cdouble, cfloat, cdate, cmonth, ctime, cminute, csecond, cdatetime, ctimestamp, cnanotime, cnanotimestamp, cdatehour, cuuid, cipaddr, cint128) as data;\n"; + conn.run(script1); + } + + public static void Preparedata_array_decimal(long count1, long count2) + { + String script1 = "login(`admin, `123456); \n" + + "n=" + count1 + ";\n" + + "m=" + count2 + ";\n" + + "cdecimal32 = array(DECIMAL32(2)[]).append!(cut(decimal32(take(-100..100 join NULL, n) + 0.254, 3), m))\n" + + "cdecimal64 = array(DECIMAL64(7)[]).append!(cut(decimal64(take(-100..100 join NULL, n) + 0.25467, 4), m))\n" + + "cdecimal128 = array(DECIMAL128(19)[]).append!(cut(decimal128(take(-100..100 join NULL, n) + 0.25467, 5), m))\n" + + "share table( cdecimal32, cdecimal64,cdecimal128) as data;"; + conn.run(script1); + } + + public void checkData(BasicTable exception, BasicTable resTable) + { + Assert.AreEqual(exception.rows(), resTable.rows()); + for (int i = 0; i < exception.columns(); i++) + { + Console.Out.WriteLine("col" + resTable.getColumnName(i)); + Assert.AreEqual(exception.getColumn(i).getString(), resTable.getColumn(i).getString()); + } + } + + class Handler : EventMessageHandler + { + + public void doEvent(String eventType, List attribute) + { + Console.Out.WriteLine("eventType: " + eventType); + for (int i = 0; i < attribute.Count; i++) + { + Console.Out.WriteLine(attribute[i].ToString()); + } + + try + { + conn.run("tableInsert{outputTable}", attribute); + } + catch (Exception e) + { + System.Console.Out.WriteLine(e.ToString()); + } + } + }; + + class Handler1 : EventMessageHandler + { + + public void doEvent(String eventType, List attribute) + { + Console.Out.WriteLine("eventType: " + eventType); + for (int i = 0; i < attribute.Count; i++) + { + Console.Out.WriteLine(attribute[i].ToString()); + } + + if (eventType.Equals("MarketData")) + { + try + { + conn.run("tableInsert{outputTable}", attribute); + } + catch (Exception e) + { + System.Console.Out.WriteLine(e.ToString()); + } + } + else + { + try + { + conn.run("tableInsert{outputTable1}", attribute); + } + catch (Exception e) + { + System.Console.Out.WriteLine(e.ToString()); + } + } + } + }; + + class Handler_array : EventMessageHandler + { + + public void doEvent(String eventType, List attributes) + { + var cols = new List() { }; + var colNames = new List() { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippaddrv", "int128v"}; + BasicArrayVector boolv = new BasicArrayVector(DATA_TYPE.DT_BOOL_ARRAY); + boolv.append((IVector)attributes[0]); + BasicArrayVector charv = new BasicArrayVector(DATA_TYPE.DT_BYTE_ARRAY); + charv.append((IVector)attributes[1]); + BasicArrayVector shortv = new BasicArrayVector(DATA_TYPE.DT_SHORT_ARRAY); + shortv.append((IVector)attributes[2]); + BasicArrayVector intv = new BasicArrayVector(DATA_TYPE.DT_INT_ARRAY); + intv.append((IVector)attributes[3]); + BasicArrayVector longv = new BasicArrayVector(DATA_TYPE.DT_LONG_ARRAY); + longv.append((IVector)attributes[4]); + BasicArrayVector doublev = new BasicArrayVector(DATA_TYPE.DT_DOUBLE_ARRAY); + doublev.append((IVector)attributes[5]); + BasicArrayVector floatv = new BasicArrayVector(DATA_TYPE.DT_FLOAT_ARRAY); + floatv.append((IVector)attributes[6]); + BasicArrayVector datev = new BasicArrayVector(DATA_TYPE.DT_DATE_ARRAY); + datev.append((IVector)attributes[7]); + BasicArrayVector monthv = new BasicArrayVector(DATA_TYPE.DT_MONTH_ARRAY); + monthv.append((IVector)attributes[8]); + BasicArrayVector timev = new BasicArrayVector(DATA_TYPE.DT_TIME_ARRAY); + timev.append((IVector)attributes[9]); + BasicArrayVector minutev = new BasicArrayVector(DATA_TYPE.DT_MINUTE_ARRAY); + minutev.append((IVector)attributes[10]); + BasicArrayVector secondv = new BasicArrayVector(DATA_TYPE.DT_SECOND_ARRAY); + secondv.append((IVector)attributes[11]); + BasicArrayVector datetimev = new BasicArrayVector(DATA_TYPE.DT_DATETIME_ARRAY); + datetimev.append((IVector)attributes[12]); + BasicArrayVector timestampv = new BasicArrayVector(DATA_TYPE.DT_TIMESTAMP_ARRAY); + timestampv.append((IVector)attributes[13]); + BasicArrayVector nanotimev = new BasicArrayVector(DATA_TYPE.DT_NANOTIME_ARRAY); + nanotimev.append((IVector)attributes[14]); + BasicArrayVector nanotimestampv = new BasicArrayVector(DATA_TYPE.DT_NANOTIMESTAMP_ARRAY); + nanotimestampv.append((IVector)attributes[15]); + BasicArrayVector datehourv = new BasicArrayVector(DATA_TYPE.DT_DATEHOUR_ARRAY); + datehourv.append((IVector)attributes[16]); + BasicArrayVector uuidv = new BasicArrayVector(DATA_TYPE.DT_UUID_ARRAY); + uuidv.append((IVector)attributes[17]); + BasicArrayVector ippaddrv = new BasicArrayVector(DATA_TYPE.DT_IPADDR_ARRAY); + ippaddrv.append((IVector)attributes[18]); + BasicArrayVector int128v = new BasicArrayVector(DATA_TYPE.DT_INT128_ARRAY); + int128v.append((IVector)attributes[19]); + + cols.Add(boolv); + cols.Add(charv); + cols.Add(shortv); + cols.Add(intv); + cols.Add(longv); + cols.Add(doublev); + cols.Add(floatv); + cols.Add(datev); + cols.Add(monthv); + cols.Add(timev); + cols.Add(minutev); + cols.Add(secondv); + cols.Add(datetimev); + cols.Add(timestampv); + cols.Add(nanotimev); + cols.Add(nanotimestampv); + cols.Add(datehourv); + cols.Add(uuidv); + cols.Add(ippaddrv); + cols.Add(int128v); + BasicTable bt = new BasicTable(colNames, cols); + + var variable = new Dictionary(); + variable.Add("table_tmp", bt); + conn.upload(variable); + conn.run("outputTable.tableInsert(table_tmp)"); + } + }; + + class Handler_array_decimal : EventMessageHandler + { + + public void doEvent(String eventType, List attributes) + { + + String decimal32v = attributes[0].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(",", "\" \"").Replace("[", "[\"").Replace("]", "\"]"); + String decimal64v = attributes[1].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(",", "\" \"").Replace("[", "[\"").Replace("]", "\"]"); + String decimal128v = attributes[2].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(",", "\" \"").Replace("[", "[\"").Replace("]", "\"]"); + + for (int i = 0; i < attributes.Count; i++) + { + //attributes[i].getString(); + Console.WriteLine(attributes[i].getString()); + } + String script = null; + script = String.Format("insert into outputTable values( decimal32({0},2),decimal64({1},7),decimal128({2},19))", decimal32v, decimal64v, decimal128v); + Console.WriteLine("script:" + script); + conn.run(script); + } + }; + + + + public void PrepareUser(String userName, String password) + { + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT, "admin", "123456"); + conn.run("def create_user(){try{deleteUser(`" + userName + ")}catch(ex){};createUser(`" + userName + ", '" + password + "');};" + + "rpc(getControllerAlias(),create_user);"); + } + + + [TestMethod] + public void test_EventClient_EventScheme_null() + { + List eventSchemas = new List(); + List eventTimeFields = new List(); + List commonFields = new List(); + String re = null; + try + { + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("eventSchemas must not be empty.", re); + } + + [TestMethod] + public void test_EventClient_EventType_null() + { + String re = null; + try + { + EventSchema scheme = new EventSchema("", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("eventType must be non-empty.", re); + } + + [TestMethod] + public void test_EventClient_EventType_repetition() + { + EventSchema scheme = new EventSchema("market", new List { "market", "time", "time1", "time2", "time3" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + EventSchema scheme1 = new EventSchema("market", new List { "market", "time0", "time1", "time2", "time3" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + + List eventSchemas = new List(); + eventSchemas.Add(scheme); + eventSchemas.Add(scheme1); + List eventTimeFields = new List() { "market" }; + List commonFields = new List(); + String re = null; + try + { + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("EventType must be unique.", re); + } + + [TestMethod] + public void test_EventClient_fieldNames_repetition() + { + conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "time", "time" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "time" }; + List commonFields = new List(); + String re = null; + try + { + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("fieldNames must be unique.", re); + } + + [TestMethod] + public void test_EventClient_fieldNames_one_colume() + { + String script = "share streamTable(1:0, [`timestamp], [TIMESTAMP]) as outputTable;\n" + + "class MarketData{\n" + + "timestamp :: TIMESTAMP\n" + + "def MarketData(t){\n" + + "timestamp = t\n" + + "}\n" + + "}\n" + + "class MainMonitor{\n" + + "def MainMonitor(){}\n" + + "def updateMarketData(event)\n" + + "def onload(){addEventListener(updateMarketData,'MarketData',,'all')}\n" + + "def updateMarketData(event){emitEvent(event)}\n" + + "}\n" + + "dummy = table(array(TIMESTAMP, 0) as timestamp, array(STRING, 0) as eventType, array(BLOB, 0) as blobs);\n" + + "share streamTable(array(TIMESTAMP, 0) as timestamp, array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput\n" + + "schema = table(1:0, `eventType`eventKeys`eventValuesTypeString`eventValueTypeID`eventValuesFormID, [STRING, STRING, STRING, INT[], INT[]])\n" + + "insert into schema values(\"MarketData\", \"timestamp\", \"TIMESTAMP\", 12, 0)\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schema, outputTable=intput, eventTimeField = \"timestamp\")\n"; + conn.run(script); + EventSchema scheme = new EventSchema("MarketData", new List { "timestamp" }, new List { DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "timestamp" }; + List commonFields = new List(); + + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "intput", "test1", handler, -1, true, "admin", "123456"); + conn.run("marketData1 = MarketData(now());\n appendEvent(inputSerializer, [marketData1])"); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + Assert.AreEqual(1, re.rows()); + BasicTable re1 = (BasicTable)conn.run("select timestamp from intput"); + checkData(re1, re); + client.unsubscribe(SERVER, PORT, "intput", "test1"); + } + + + [TestMethod] + public void test_EventClient_FieldForms_null_1() + { + String re = null; + try + { + EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_VOID, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List()); + + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("not support VOID type. ", re); + } + + [TestMethod] + public void test_EventClient_FieldForms_not_support() + { + String re = null; + try + { + EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("FieldForm only can be DF_SCALAR or DF_VECTOR.", re); + } + + + //[TestMethod] + //public void test_EventClient_attrExtraParams_null() + //{ + // EventSchema scheme = new EventSchema(); + // scheme.setEventType("market"); + // scheme.setFieldNames(Arrays.asList("market", "code", "decimal32", "decimal64", "decimal128")); + // scheme.setFieldTypes(Arrays.asList(DT_STRING, DT_STRING, DT_DECIMAL32, DT_DECIMAL64, DT_DECIMAL128)); + // scheme.setFieldForms(Arrays.asList(DF_SCALAR, DF_SCALAR, DF_SCALAR, DF_SCALAR, DF_SCALAR)); + // List eventSchemas = Collections.singletonList(scheme); + // List eventTimeFields = new List(); + // List commonFields = new List(); + // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + //} + + //[TestMethod] + //public void test_EventClient_attrExtraParams_set_not_true() + //{ + // EventSchema scheme = new EventSchema(); + // scheme.setEventType("market"); + // scheme.setFieldNames(Arrays.asList("decimal32", "decimal64", "decimal128")); + // scheme.setFieldTypes(Arrays.asList(DT_DECIMAL32, DT_DECIMAL64, DT_DECIMAL128)); + // scheme.setFieldForms(Arrays.asList(DF_SCALAR, DF_SCALAR, DF_SCALAR)); + // scheme.setFieldExtraParams(Arrays.asList(10, 19, 39)); + // List eventSchemas = Collections.singletonList(scheme); + // List eventTimeFields = new List(); + // List commonFields = new List(); + // String re = null; + // try + // { + // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL32 scale 10 is out of bounds, it must be in [0,9].", re); + + // scheme.setFieldExtraParams(Arrays.asList(1, 19, 39)); + // String re1 = null; + // try + // { + // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re1 = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL64 scale 19 is out of bounds, it must be in [0,18].", re1); + + // scheme.setFieldExtraParams(Arrays.asList(1, 18, 39)); + // String re2 = null; + // try + // { + // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re2 = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL128 scale 39 is out of bounds, it must be in [0,38].", re2); + + // scheme.setFieldExtraParams(Arrays.asList(-1, 10, 10)); + // String re3 = null; + // try + // { + // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re3 = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL32 scale -1 is out of bounds, it must be in [0,9].", re3); + + // scheme.setFieldExtraParams(Arrays.asList(1, -1, 0)); + // String re4 = null; + // try + // { + // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re4 = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL64 scale -1 is out of bounds, it must be in [0,18].", re4); + + // scheme.setFieldExtraParams(Arrays.asList(0, 0, -1)); + // String re5 = null; + // try + // { + // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re5 = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL128 scale -1 is out of bounds, it must be in [0,38].", re5); + //} + + [TestMethod] + public void test_EventClient_eventTimeFields_not_exist() + { + + EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "datetimev" }; + List commonFields = new List(); + String re = null; + try + { + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Event market doesn't contain eventTimeKey datetimev.", re); + } + + [TestMethod] + public void test_EventClient_eventTimeFields_two_column() + { + conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); + String script = "share streamTable(1:0, `timestamp`time, [TIMESTAMP,TIME]) as outputTable;\n" + + "share streamTable(1:0, `string`timestamp, [STRING,TIMESTAMP]) as outputTable1;\n" + + "class MarketData{\n" + + "timestamp :: TIMESTAMP\n" + + "time :: TIME\n" + + "def MarketData(t,t1){\n" + + "timestamp = t\n" + + "time = t1\n" + + "}\n" + + "}\n" + + "class MarketData1{\n" + + "string :: STRING\n" + + "timestamp :: TIMESTAMP\n" + + "def MarketData1(s,t){\n" + + "string = s\n" + + "timestamp = t\n" + + "}\n" + + "}\n" + + "share streamTable(array(TIMESTAMP, 0) as timestamp, array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput\n" + + "schema = table(1:0, `eventType`eventKeys`eventValuesTypeString`eventValueTypeID`eventValuesFormID, [STRING, STRING, STRING, INT[], INT[]])\n" + + "insert into schema values(\"MarketData\", \"timestamp,time\", \"TIMESTAMP,TIME\", [12 8], [0 0])\n" + + "insert into schema values(\"MarketData1\", \"string,timestamp\", \"STRING,TIMESTAMP\", [18 12], [0 0])\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schema, outputTable=intput, eventTimeField = \"timestamp\")\n"; + conn.run(script); + EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "time" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("MarketData1", new List { "string", "timestamp" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + List eventTimeFields = new List() { "time", "timestamp" }; + List commonFields = new List(); + + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler1 handler1 = new Handler1(); + client.subscribe(SERVER, PORT, "intput", "test1", handler1, -1, true, "admin", "123456"); + conn.run("marketData1 = MarketData(now(),time(1));\n marketData2 = MarketData1(\"tesrtttt\",now());\n appendEvent(inputSerializer, [marketData1,marketData2])"); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + BasicTable re1 = (BasicTable)conn.run("select * from outputTable1"); + BasicTable re2 = (BasicTable)conn.run("select timestamp from intput"); + + Assert.AreEqual(1, re.rows()); + Assert.AreEqual(1, re1.rows()); + Assert.AreEqual(re2.getColumn(0).get(0).getString(), re.getColumn(0).get(0).getString()); + Assert.AreEqual("00:00:00.001", re.getColumn(1).get(0).getString()); + Assert.AreEqual("tesrtttt", re1.getColumn(0).get(0).getString()); + Assert.AreEqual(re2.getColumn(0).get(1).getString(), re1.getColumn(1).get(0).getString()); + client.unsubscribe(SERVER, PORT, "intput", "test1"); + } + + [TestMethod] + public void test_EventClient_commonFields_one_column() + { + String script = "share streamTable(1:0, `timestamp`time`commonKey, [TIMESTAMP,TIME,TIMESTAMP]) as outputTable;\n" + + "share streamTable(1:0, `string`timestamp`commonKey, [STRING,TIMESTAMP,TIMESTAMP]) as outputTable1;\n" + + "class MarketData{\n" + + "timestamp :: TIMESTAMP\n" + + "time :: TIME\n" + + "def MarketData(t,t1){\n" + + "timestamp = t\n" + + "time = t1\n" + + "}\n" + + "}\n" + + "class MarketData1{\n" + + "string :: STRING\n" + + "timestamp :: TIMESTAMP\n" + + "def MarketData1(s,t){\n" + + "string = s\n" + + "timestamp = t\n" + + "}\n" + + "}\n" + + "share streamTable(array(TIMESTAMP, 0) as timestamp, array(STRING, 0) as eventType, array(BLOB, 0) as blobs,array(TIMESTAMP, 0) as commonKey) as intput\n" + + "schema = table(1:0, `eventType`eventKeys`eventValuesTypeString`eventValueTypeID`eventValuesFormID, [STRING, STRING, STRING, INT[], INT[]])\n" + + "insert into schema values(\"MarketData\", \"timestamp,time\", \"TIMESTAMP,TIME\", [12 8], [0 0])\n" + + "insert into schema values(\"MarketData1\", \"string,timestamp\", \"STRING,TIMESTAMP\", [18 12], [0 0])\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schema, outputTable=intput, eventTimeField = \"timestamp\", commonField = \"timestamp\")\n"; + conn.run(script); + + EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "time" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("MarketData1", new List { "string", "timestamp" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + List eventTimeFields = new List() { "time", "timestamp" }; + List commonFields = new List() { "timestamp" }; + + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler1 handler1 = new Handler1(); + client.subscribe(SERVER, PORT, "intput", "test1", handler1, -1, true, "admin", "123456"); + conn.run("marketData1 = MarketData(now(),time(1));\n marketData2 = MarketData1(\"tesrtttt\",now());\n appendEvent(inputSerializer, [marketData1,marketData2])"); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + BasicTable re1 = (BasicTable)conn.run("select * from outputTable1"); + BasicTable re2 = (BasicTable)conn.run("select timestamp from intput"); + + Assert.AreEqual(1, re.rows()); + Assert.AreEqual(1, re1.rows()); + Assert.AreEqual(re2.getColumn(0).get(0).getString(), re.getColumn(0).get(0).getString()); + Assert.AreEqual("00:00:00.001", re.getColumn(1).get(0).getString()); + Assert.AreEqual("tesrtttt", re1.getColumn(0).get(0).getString()); + Assert.AreEqual(re2.getColumn(0).get(0).getString(), re1.getColumn(1).get(0).getString()); + client.unsubscribe(SERVER, PORT, "intput", "test1"); + } + + [TestMethod] + public void test_EventClient_commonFields_two_column() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("market1", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + List attributes = new List(); + attributes.Add(new BasicString("123456")); + attributes.Add(new BasicTime(10)); + sender.sendEvent("market", attributes); + + List attributes1 = new List(); + attributes1.Add(new BasicString("tesrtrrr")); + attributes1.Add(new BasicTime(12)); + sender.sendEvent("market1", attributes1); + + BasicTable re = (BasicTable)conn.run("select * from inputTable"); + Assert.AreEqual(2, re.rows()); + Assert.AreEqual("00:00:00.010", re.getColumn(2).get(0).getString()); + Assert.AreEqual("00:00:00.012", re.getColumn(2).get(1).getString()); + Assert.AreEqual("123456", re.getColumn(3).get(0).getString()); + Assert.AreEqual("tesrtrrr", re.getColumn(3).get(1).getString()); + } + + public void subscribePrepare() + { + conn.run("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "comment1" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "timestamp" }; + List commonFields = new List() { "comment1" }; + + sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + } + + [TestMethod] + public void test_EventClient_subscribe_SERVER_null() + { + subscribePrepare(); + String re = null; + Handler1 handler1 = new Handler1(); + try + { + client.subscribe(null, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("host must be non-null.", re); + } + + [TestMethod] + public void test_EventClient_subscribe_SERVER_not_true() + { + subscribePrepare(); + String re = null; + Handler1 handler1 = new Handler1(); + try + { + client.subscribe("erer", PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Database connection is not established yet.", re); + } + [TestMethod] + public void test_EventClient_subscribe_port_0() + { + subscribePrepare(); + String re = null; + Handler1 handler1 = new Handler1(); + try + { + client.subscribe(SERVER, 0, "inputTable", "test1", handler1, -1, true, "admin", "123456"); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Database connection is not established yet.", re); + } + + [TestMethod] + public void test_EventClient_subscribe_port_not_true() + { + subscribePrepare(); + String re = null; + Handler1 handler1 = new Handler1(); + try + { + client.subscribe(SERVER, 18888, "inputTable", "test1", handler1, -1, true, "admin", "123456"); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Database connection is not established yet.", re); + } + + [TestMethod] + public void test_EventClient_subscribe_tableName_not_exist() + { + subscribePrepare(); + String re = null; + Handler1 handler1 = new Handler1(); + try + { + client.subscribe(SERVER, PORT, "inputTable111", "test1", handler1, -1, true, "admin", "123456"); + } + catch (Exception ex) + { + re = ex.Message; + } + Console.Out.WriteLine(re); + Assert.AreEqual(true, re.Contains(" Can't find the object with name inputTable111")); + } + + [TestMethod] + public void test_EventClient_subscribe_tableName_null() + { + subscribePrepare(); + String re = null; + Handler1 handler1 = new Handler1(); + try + { + client.subscribe(SERVER, PORT, null, "test1", handler1, -1, true, "admin", "123456"); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("tableName must be non-null.", re); + String re1 = null; + try + { + client.subscribe(SERVER, PORT, "", "test1", handler1, -1, true, "admin", "123456"); + } + catch (Exception ex) + { + re1 = ex.Message; + } + Assert.AreEqual("tableName must be non-empty.", re1); + } + + [TestMethod] + public void test_EventClient_subscribe_actionName_exist() + { + subscribePrepare(); + conn.run("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable1;"); + Handler1 handler1 = new Handler1(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); + client.subscribe(SERVER, PORT, "inputTable1", "test1", handler1, -1, true, "admin", "123456"); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + client.unsubscribe(SERVER, PORT, "inputTable1", "test1"); + } + + [TestMethod] + public void test_EventClient_subscribe_actionName_null() + { + subscribePrepare(); + Handler1 handler1 = new Handler1(); + String re = null; + try + { + client.subscribe(SERVER, PORT, "inputTable", null, handler1, -1, true, "admin", "123456"); + } + catch (Exception e) + { + re = e.Message; + } + Assert.AreEqual("actionName must be non-null.", re); + } + + [TestMethod] + public void test_EventClient_subscribe_handler_null() + { + subscribePrepare(); + String re = null; + try + { + client.subscribe(SERVER, PORT, "inputTable", "test1", null, -1, true, "admin", "123456"); + } + catch (Exception e){ + re = e.Message; + } + Assert.AreEqual("handler must be non-null.", re); + + } + [TestMethod] + public void test_EventClient_subscribe_offset_negative_1() + { + subscribePrepare(); + conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + sender.sendEvent("MarketData", attributes); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + Assert.AreEqual(1, re.rows()); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + [TestMethod] + public void test_EventClient_subscribe_offset_negative_2() + { + subscribePrepare(); + conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + sender.sendEvent("MarketData", attributes); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -2, true, "admin", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + Assert.AreEqual(1, re.rows()); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + [TestMethod] + public void test_EventClient_subscribe_offset_0() + { + subscribePrepare(); + conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + sender.sendEvent("MarketData", attributes); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, 0, true, "admin", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + Assert.AreEqual(2, re.rows()); + } + + [TestMethod] + public void test_EventClient_subscribe_offset_1() + { + subscribePrepare(); + conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + sender.sendEvent("MarketData", attributes); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, 1, true, "admin", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + Assert.AreEqual(1, re.rows()); + } + [TestMethod] + public void test_EventClient_subscribe_offset_not_match() + { + subscribePrepare(); + conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + sender.sendEvent("MarketData", attributes); + String re = null; + Handler handler = new Handler(); + try + { + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, 2, true, "admin", "123456"); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual(true, re.Contains("Can't find the message with offset")); + } + [TestMethod] + public void test_EventClient_subscribe_reconnect_true() + { + subscribePrepare(); + conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + sender.sendEvent("MarketData", attributes); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, false, "admin", "123456"); + Thread.Sleep(1000); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + + [TestMethod] + public void test_EventClient_subscribe_reconnect_false() + { + subscribePrepare(); + conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + sender.sendEvent("MarketData", attributes); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + Thread.Sleep(1000); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + + [TestMethod] + public void test_EventClient_subscribe_user_error() + { + subscribePrepare(); + String re = null; + Handler1 handler1 = new Handler1(); + try + { + client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin123", "123456"); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual(true, re.Contains("The user name or password is incorrect")); + } + + + [TestMethod] + public void test_EventClient_subscribe_password_error() + { + subscribePrepare(); + String re = null; + Handler1 handler1 = new Handler1(); + try + { + client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456WWW"); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual(true, re.Contains("The user name or password is incorrect")); + } + + [TestMethod] + public void test_EventClient_subscribe_admin() + { + PrepareUser("user1", "123456"); + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT, "user1", "123456"); + conn.run("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;"); + conn.run("addAccessControl(`inputTable)"); + conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); + subscribePrepare(); + + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + Assert.AreEqual(1, re.rows()); + } + [TestMethod] + public void test_EventClient_subscribe_other_user() + { + PrepareUser("user1", "123456"); + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT, "user1", "123456"); + conn.run("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;"); + conn.run("addAccessControl(`inputTable)"); + conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); + subscribePrepare(); + + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "user1", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + Assert.AreEqual(1, re.rows()); + } + [TestMethod] + public void test_EventClient_other_user_unallow() + { + PrepareUser("user1", "123456"); + PrepareUser("user2", "123456"); + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT, "user1", "123456"); + conn.run("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;"); + conn.run("addAccessControl(`inputTable)"); + EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "comment1" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + + List eventTimeFields = new List() { "timestamp" }; + List commonFields = new List() { "comment1" }; + sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + String re = null; + Handler1 handler1 = new Handler1(); + try + { + client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "user2", "123456"); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual(true, re.Contains("No access to shared table [inputTable]")); + } + [TestMethod] + public void test_EventClient_subscribe_unsubscribe_resubscribe() + { + subscribePrepare(); + conn.run("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;"); + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + sender.sendEvent("MarketData", attributes); + Handler handler = new Handler(); + for (int i = 0; i < 10; i++) + { + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(200); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(200); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + Assert.AreEqual(20, re.rows()); + } + [TestMethod] + public void test_EventClient_subscribe_duplicated() + { + subscribePrepare(); + Handler1 handler1 = new Handler1(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); + String re = null; + try + { + client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual(true, re.Contains("already be subscribed")); + } + + [TestMethod] + public void test_EventClient_not_subscribe_unsubscribe() + { + subscribePrepare(); + String re = null; + try + { + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + catch (Exception ex) + { + re = ex.Message; + } + Console.WriteLine(re); + Assert.AreEqual(true, re.Contains("/inputTable/test1 doesn't exist.")); + + } + + [TestMethod] + public void test_EventClient_unsubscribe_duplicated() + { + subscribePrepare(); + Handler1 handler1 = new Handler1(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler1, -1, true, "admin", "123456"); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + String re = null; + try + { + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + catch (Exception ex) + { + re = ex.Message; + } + Console.WriteLine(re); + Assert.AreEqual(true, re.Contains("/inputTable/test1 doesn't exist.")); + } + + [TestMethod] + public void test_EventClient_subscribe_haStreamTable() + { + String script = "try{\ndropStreamTable(`inputTable)\n}catch(ex){\n}\n" + + "table = table(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]);\n" + + "haStreamTable(" + HASTREAM_GROUPID + ", table, `inputTable, 100000);\n" + + "share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;\n"; + conn.run(script); + EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "comment1" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + + List eventTimeFields = new List() { "timestamp" }; + List commonFields = new List() { "comment1" }; + + sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + Assert.AreEqual(1, re.rows()); + } + //[TestMethod] + public void test_EventClient_subscribe_haStreamTable_leader() + { + BasicString StreamLeaderTmp = (BasicString)conn.run(String.Format("getStreamingLeader(%d)", HASTREAM_GROUPID)); + String StreamLeader = StreamLeaderTmp.getString(); + BasicString StreamLeaderSERVERTmp = (BasicString)conn.run(String.Format("(exec SERVER from rpc(getControllerAlias(), getClusterPerf) where name=\"{0}\")[0]", StreamLeader)); + String StreamLeaderSERVER = StreamLeaderSERVERTmp.getString(); + BasicInt StreamLeaderPortTmp = (BasicInt)conn.run(String.Format("(exec port from rpc(getControllerAlias(), getClusterPerf) where mode = 0 and name=\"{0}\")[0]", StreamLeader)); + int StreamLeaderPort = StreamLeaderPortTmp.getInt(); + Console.Out.WriteLine(StreamLeaderSERVER); + Console.Out.WriteLine(StreamLeaderPort); + DBConnection conn1 = new DBConnection(); + conn1.connect(StreamLeaderSERVER, StreamLeaderPort, "admin", "123456"); + String script = "try{\ndropStreamTable(`inputTable_1)\n}catch(ex){\n}\n" + + "table = table(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]);\n" + + "haStreamTable(" + HASTREAM_GROUPID + ", table, `inputTable_1, 100000);\n" + + "share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;\n"; + conn1.run(script); + + EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "comment1" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "timestamp" }; + List commonFields = new List() { "comment1" }; + + sender = new EventSender(conn, "inputTable_1", eventSchemas, eventTimeFields, commonFields); + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + Handler handler = new Handler(); + client.subscribe(StreamLeaderSERVER, StreamLeaderPort, "inputTable_1", "test1", handler, -1, true, "admin", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn1.run("select * from outputTable"); + Assert.AreEqual(1, re.rows()); + Assert.AreEqual("2024.03.22T10:45:03.100", re.getColumn(0).get(0).getString()); + Assert.AreEqual("123456", re.getColumn(1).get(0).getString()); + client.unsubscribe(StreamLeaderSERVER, StreamLeaderPort, "inputTable_1", "test1"); + } + + //[TestMethod]//not support + public void test_EventClient_subscribe_haStreamTable_follower() + { + String script0 = "leader = getStreamingLeader(" + HASTREAM_GROUPID + ");\n" + + "groupSitesStr = (exec sites from getStreamingRaftGroups() where id ==" + HASTREAM_GROUPID + ")[0];\n" + + "groupSites = split(groupSitesStr, \",\");\n" + + "followerInfo = exec top 1 * from rpc(getControllerAlias(), getClusterPerf) where site in groupSites and name!=leader;"; + conn.run(script0); + BasicString StreamFollowerSERVERTmp = (BasicString)conn.run("(exec SERVER from followerInfo)[0]"); + String StreamFollowerSERVER = StreamFollowerSERVERTmp.getString(); + BasicInt StreamFollowerPortTmp = (BasicInt)conn.run("(exec port from followerInfo)[0]"); + int StreamFollowerPort = StreamFollowerPortTmp.getInt(); + Console.Out.WriteLine(StreamFollowerSERVER); + Console.Out.WriteLine(StreamFollowerPort); + DBConnection conn1 = new DBConnection(); + conn1.connect(StreamFollowerSERVER, StreamFollowerPort, "admin", "123456"); + String script = "try{\ndropStreamTable(`inputTable_1)\n}catch(ex){\n}\n" + + "table = table(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]);\n" + + "haStreamTable(" + HASTREAM_GROUPID + ", table, `inputTable_1, 100000);\n" + + "share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;\n"; + conn1.run(script); + EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "comment1" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "timestamp" }; + List commonFields = new List() { "comment1" }; + sender = new EventSender(conn, "inputTable_1", eventSchemas, eventTimeFields, commonFields); + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + List attributes = new List(); + attributes.Add(new BasicTimestamp(10)); + attributes.Add(new BasicString("123456")); + Handler handler = new Handler(); + client.subscribe(StreamFollowerSERVER, StreamFollowerPort, "inputTable_1", "test1", handler, -1, true, "user1", "123456"); + sender.sendEvent("MarketData", attributes); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn1.run("select * from outputTable"); + Assert.AreEqual(1, re.rows()); + Assert.AreEqual("2024.03.22T10:45:03.100", re.getColumn(0).get(0).getString()); + Assert.AreEqual("123456", re.getColumn(1).get(0).getString()); + client.unsubscribe(StreamFollowerSERVER, StreamFollowerPort, "inputTable_1", "test1"); + } + + [TestMethod] + public void test_EventClient_subscribe_special_char() + { + String script = "share streamTable(1:0, `timestamp`time, [STRING,TIMESTAMP]) as outputTable;\n" + + "class MarketData{\n" + + "string :: STRING\n" + + "timestamp :: TIMESTAMP\n" + + "def MarketData(s,t){\n" + + "string = s\n" + + "timestamp = t\n" + + "}\n" + + "}\n" + + "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs,array(STRING, 0) as comment1,array(TIMESTAMP, 0) as comment2 ) as intput\n" + + "schema = table(1:0, `eventType`eventKeys`eventValuesTypeString`eventValueTypeID`eventValuesFormID, [STRING, STRING, STRING, INT[], INT[]])\n" + + "insert into schema values(\"MarketData\", \"string,timestamp\", \"STRING,TIMESTAMP\", [18 12], [0 0])\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schema, outputTable=intput, commonField = [\"string\",\"timestamp\"])\n"; + conn.run(script); + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,STRING,TIMESTAMP]) as inputTable;"); + EventSchema scheme = new EventSchema("MarketData", new List { "_market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "_market", "time" }; + + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + List attributes = new List(); + attributes.Add(new BasicString("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ")); + attributes.Add(new BasicTimestamp(1)); + sender.sendEvent("MarketData", attributes); + + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "intput", "test1", handler, -1, true, "admin", "123456"); + conn.run(" marketData1 = MarketData(\"!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; \",timestamp(1));\n appendEvent(inputSerializer, marketData1)"); + Thread.Sleep(1000); + + BasicTable re = (BasicTable)conn.run("select * from inputTable"); + BasicTable re1 = (BasicTable)conn.run("select * from intput"); + BasicTable re2 = (BasicTable)conn.run("select * from outputTable"); + + checkData(re, re1); + Console.Out.WriteLine(re2.getString()); + Assert.AreEqual("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ", re2.getColumn(0).get(0).getString()); + client.unsubscribe(SERVER, PORT, "intput", "test1"); + } + + [TestMethod] + public void test_EventClient_subscribe_all_dateType_1() + { + String script = "share streamTable(1:0, `eventTime`eventType`blobs, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + + "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippAddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; + conn.run(script); + String script1 = "class event_all_dateType{\n" + + "\tboolv :: BOOL\n" + + "\tcharv :: CHAR\n" + + "\tshortv :: SHORT\n" + + "\tintv :: INT\n" + + "\tlongv :: LONG\n" + + "\tdoublev :: DOUBLE \n" + + "\tfloatv :: FLOAT\n" + + "\tdatev :: DATE\n" + + "\tmonthv :: MONTH\n" + + "\ttimev :: TIME\n" + + "\tminutev :: MINUTE\n" + + "\tsecondv :: SECOND\n" + + "\tdatetimev :: DATETIME \n" + + "\ttimestampv :: TIMESTAMP\n" + + "\tnanotimev :: NANOTIME\n" + + "\tnanotimestampv :: NANOTIMESTAMP\n" + + // "\tsymbolv :: SYMBOL\n" + + "\tstringv :: STRING\n" + + "\tdatehourv :: DATEHOUR\n" + + "\tuuidv :: UUID\n" + + "\tippAddrv :: IPAddR \n" + + "\tint128v :: INT128\n" + + "\tblobv :: BLOB\n" + + " def event_all_dateType(bool, char, short, int, long, double, float, date, month, time, minute, second, datetime, timestamp, nanotime, nanotimestamp, string, datehour, uuid, ippAddr, int128, blob){\n" + + "\tboolv = bool\n" + + "\tcharv = char\n" + + "\tshortv = short\n" + + "\tintv = int\n" + + "\tlongv = long\n" + + "\tdoublev = double\n" + + "\tfloatv = float\n" + + "\tdatev = date\n" + + "\tmonthv = month\n" + + "\ttimev = time\n" + + "\tminutev = minute\n" + + "\tsecondv = second\n" + + "\tdatetimev = datetime\n" + + "\ttimestampv = timestamp\n" + + "\tnanotimev = nanotime\n" + + "\tnanotimestampv = nanotimestamp\n" + + // "\tsymbolv = symbol\n" + + "\tstringv = string\n" + + "\tdatehourv = datehour\n" + + "\tuuidv = uuid\n" + + "\tippAddrv = ippAddr\n" + + "\tint128v = int128\n" + + "\tblobv = blob\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_all_dateType'\n" + + "eventKeys = 'boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,stringv,datehourv,uuidv,ippAddrv,int128v,blobv';\n" + + "typeV = [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE,MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB];\n" + + "formV = [SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable(array(TIMESTAMP, 0) as eventTime, array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput, eventTimeField = \"timestampv\");"; + conn.run(script1); + EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "datetimev" }; + List commonFields = new List(); + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "intput", "test1", handler, -1, true, "admin", "123456"); + + Preparedata(1); + String script2 = "data1=select * from data;\n" + + "i = 0\n" + + "\tall_data_type1=event_all_dateType(data1.row(i)[`boolv], data1.row(i)[`charv], data1.row(i)[`shortv], data1.row(i)[`intv],data1.row(i)[`longv], data1.row(i)[`doublev], data1.row(i)[`floatv], data1.row(i)[`datev],data1.row(i)[`monthv], data1.row(i)[`timev], data1.row(i)[`minutev], data1.row(i)[`secondv],data1.row(i)[`datetimev], data1.row(i)[`timestampv], data1.row(i)[`nanotimev], data1.row(i)[`nanotimestampv], data1.row(i)[`stringv], data1.row(i)[`datehourv], data1.row(i)[`uuidv], data1.row(i)[`ippaddrv],data1.row(i)[`int128v], blob(data1.row(i)[`blobv]))\n" + + "\tappendEvent(inputSerializer, all_data_type1)\n"; + conn.run(script2); + Thread.Sleep(10000); + BasicTable bt1 = (BasicTable)conn.run("select * from data;"); + Assert.AreEqual(1, bt1.rows()); + Thread.Sleep(20000); + BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(1, bt2.rows()); + checkData(bt1, bt2); + } + + [TestMethod] + public void test_EventClient_subscribe_all_dateType_100() + { + String script = "share streamTable(1:0, `eventTime`eventType`blobs, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + + "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippAddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; + conn.run(script); + String script1 = "class event_all_dateType{\n" + + "\tboolv :: BOOL\n" + + "\tcharv :: CHAR\n" + + "\tshortv :: SHORT\n" + + "\tintv :: INT\n" + + "\tlongv :: LONG\n" + + "\tdoublev :: DOUBLE \n" + + "\tfloatv :: FLOAT\n" + + "\tdatev :: DATE\n" + + "\tmonthv :: MONTH\n" + + "\ttimev :: TIME\n" + + "\tminutev :: MINUTE\n" + + "\tsecondv :: SECOND\n" + + "\tdatetimev :: DATETIME \n" + + "\ttimestampv :: TIMESTAMP\n" + + "\tnanotimev :: NANOTIME\n" + + "\tnanotimestampv :: NANOTIMESTAMP\n" + + // "\tsymbolv :: SYMBOL\n" + + "\tstringv :: STRING\n" + + "\tdatehourv :: DATEHOUR\n" + + "\tuuidv :: UUID\n" + + "\tippAddrv :: IPAddR \n" + + "\tint128v :: INT128\n" + + "\tblobv :: BLOB\n" + + " def event_all_dateType(bool, char, short, int, long, double, float, date, month, time, minute, second, datetime, timestamp, nanotime, nanotimestamp, string, datehour, uuid, ippAddr, int128, blob){\n" + + "\tboolv = bool\n" + + "\tcharv = char\n" + + "\tshortv = short\n" + + "\tintv = int\n" + + "\tlongv = long\n" + + "\tdoublev = double\n" + + "\tfloatv = float\n" + + "\tdatev = date\n" + + "\tmonthv = month\n" + + "\ttimev = time\n" + + "\tminutev = minute\n" + + "\tsecondv = second\n" + + "\tdatetimev = datetime\n" + + "\ttimestampv = timestamp\n" + + "\tnanotimev = nanotime\n" + + "\tnanotimestampv = nanotimestamp\n" + + // "\tsymbolv = symbol\n" + + "\tstringv = string\n" + + "\tdatehourv = datehour\n" + + "\tuuidv = uuid\n" + + "\tippAddrv = ippAddr\n" + + "\tint128v = int128\n" + + "\tblobv = blob\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_all_dateType'\n" + + "eventKeys = 'boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,stringv,datehourv,uuidv,ippAddrv,int128v,blobv';\n" + + "typeV = [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE,MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB];\n" + + "formV = [SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable(array(TIMESTAMP, 0) as eventTime, array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput, eventTimeField = \"timestampv\");"; + conn.run(script1); + EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "datetimev" }; + List commonFields = new List(); + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "intput", "test1", handler, -1, true, "admin", "123456"); + + Preparedata(100); + String script2 = "data1=select * from data;\n" + + "for(i in 0..99){\n" + + "\tall_data_type1=event_all_dateType(data1.row(i)[`boolv], data1.row(i)[`charv], data1.row(i)[`shortv], data1.row(i)[`intv],data1.row(i)[`longv], data1.row(i)[`doublev], data1.row(i)[`floatv], data1.row(i)[`datev],data1.row(i)[`monthv], data1.row(i)[`timev], data1.row(i)[`minutev], data1.row(i)[`secondv],data1.row(i)[`datetimev], data1.row(i)[`timestampv], data1.row(i)[`nanotimev], data1.row(i)[`nanotimestampv],data1.row(i)[`stringv], data1.row(i)[`datehourv], data1.row(i)[`uuidv], data1.row(i)[`ippaddrv],data1.row(i)[`int128v], blob(data1.row(i)[`blobv]))\n" + + "\tappendEvent(inputSerializer, all_data_type1)\n" + + "\t}"; + conn.run(script2); + Thread.Sleep(10000); + BasicTable bt1 = (BasicTable)conn.run("select * from data;"); + Assert.AreEqual(100, bt1.rows()); + Thread.Sleep(20000); + BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(100, bt2.rows()); + checkData(bt1, bt2); + } + + // [TestMethod] + // public void test_EventClient_all_dateType_vector() { + // Preparedata_array(100,10); + // String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n"+ + // "colNames=\"col\"+string(1..25);\n" + + // "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[], DATEHOUR[],UUID[],IPADDR[],INT128[],POINT[],COMPLEX[],DECIMAL32(2)[],DECIMAL64(7)[],DECIMAL128(10)[]];\n" + + // "share table(1:0,colNames,colTypes) as outputTable;\n" ; + // conn.run(script); + // String script1 ="class event_all_array_dateType{\n" + + // "\tboolv :: BOOL VECTOR\n" + + // "\tcharv :: CHAR VECTOR\n" + + // "\tshortv :: SHORT VECTOR\n" + + // "\tintv :: INT VECTOR\n" + + // "\tlongv :: LONG VECTOR\n" + + // "\tdoublev :: DOUBLE VECTOR\n" + + // "\tfloatv :: FLOAT VECTOR\n" + + // "\tdatev :: DATE VECTOR\n" + + // "\tmonthv :: MONTH VECTOR\n" + + // "\ttimev :: TIME VECTOR\n" + + // "\tminutev :: MINUTE VECTOR\n" + + // "\tsecondv :: SECOND VECTOR\n" + + // "\tdatetimev :: DATETIME VECTOR \n" + + // "\ttimestampv :: TIMESTAMP VECTOR\n" + + // "\tnanotimev :: NANOTIME VECTOR\n" + + // "\tnanotimestampv :: NANOTIMESTAMP VECTOR\n" + + // "\t//stringv :: STRING VECTOR\n" + + // "\tdatehourv :: DATEHOUR VECTOR\n" + + // "\tuuidv :: UUID VECTOR\n" + + // "\tippaddrv :: IPADDR VECTOR\n" + + // "\tint128v :: INT128 VECTOR\n" + + // "\t//blobv :: BLOB VECTOR\n" + + // "\tpointv :: POINT VECTOR\n" + + // "\tcomplexv :: COMPLEX VECTOR\n" + + // "\tdecimal32v :: DECIMAL32(3) VECTOR\n" + + // "\tdecimal64v :: DECIMAL64(8) VECTOR\n" + + // "\tdecimal128v :: DECIMAL128(10) VECTOR \n" + + // " def event_all_array_dateType(bool, char, short, int, long, double, float, date, month, time, minute, second, datetime, timestamp, nanotime, nanotimestamp, datehour, uuid, ippaddr, int128,point, complex, decimal32, decimal64, decimal128){\n" + + // "\tboolv = bool\n" + + // "\tcharv = char\n" + + // "\tshortv = short\n" + + // "\tintv = int\n" + + // "\tlongv = long\n" + + // "\tdoublev = double\n" + + // "\tfloatv = float\n" + + // "\tdatev = date\n" + + // "\tmonthv = month\n" + + // "\ttimev = time\n" + + // "\tminutev = minute\n" + + // "\tsecondv = second\n" + + // "\tdatetimev = datetime\n" + + // "\ttimestampv = timestamp\n" + + // "\tnanotimev = nanotime\n" + + // "\tnanotimestampv = nanotimestamp\n" + + // "\t//stringv = string\n" + + // "\tdatehourv = datehour\n" + + // "\tuuidv = uuid\n" + + // "\tippaddrv = ippaddr\n" + + // "\tint128v = int128\n" + + // "\t//blobv = blob\n" + + // "\tpointv = point\n" + + // "\tcomplexv = complex\n" + + // "\tdecimal32v = decimal32\n" + + // "\tdecimal64v = decimal64\n" + + // "\tdecimal128v = decimal128\n" + + // " \t}\n" + + // "} \n" + + // "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + // "eventType = 'event_all_dateType'\n" + + // "eventKeys = 'boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,datehourv,uuidv,ippaddrv,int128v,pointv,complexv,decimal32v,decimal64v,decimal128v';\n" + + // "typeV = [BOOL[], CHAR[], SHORT[], INT[], LONG[], DOUBLE[], FLOAT[], DATE[],MONTH[], TIME[], MINUTE[], SECOND[], DATETIME[], TIMESTAMP[], NANOTIME[], NANOTIMESTAMP[], DATEHOUR[], UUID[], IPADDR[], INT128[], POINT[], COMPLEX[], DECIMAL32(3)[], DECIMAL64(8)[], DECIMAL128(10)[]];\n" + + // "formV = [VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR];\n" + + // "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + // "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + + // "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + // "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; + // conn.run(script1); + // EventSchema scheme = new EventSchema(); + // scheme.setEventType("event_all_array_dateType"); + // scheme.setFieldNames(Arrays.asList("boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippaddrv", "int128v", "pointv", "complexv", "decimal32v", "decimal64v", "decimal128v")); + // scheme.setFieldTypes(Arrays.asList(DT_BOOL, DT_BYTE, DT_SHORT, DT_INT, DT_LONG, DT_DOUBLE, DT_FLOAT, DT_DATE,DT_MONTH, DT_TIME, DT_MINUTE, DT_SECOND, DT_DATETIME, DT_TIMESTAMP, DT_NANOTIME, DT_NANOTIMESTAMP, DT_DATEHOUR, DT_UUID, DT_IPADDR, DT_INT128, DT_POINT, DT_COMPLEX, DT_DECIMAL32, DT_DECIMAL64, DT_DECIMAL128)); + // scheme.setFieldForms(Arrays.asList( DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR, DF_VECTOR)); + // List eventSchemas = Collections.singletonList(scheme); + // List eventTimeFields = new List(); + // List commonFields = new List(); + // EventSender sender = EventSender.createEventSender(eventSchemas, eventTimeFields, commonFields); + // sender.connect(conn,"inputTable"); + // + // EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + // client.subscribe(SERVER, PORT, "intput1", "test1", handler, -1, true, "admin", "123456"); + // + // Preparedata_array(100,10); + // BasicTable bt = (BasicTable)conn.run("select * from data"); + // String script2 = "data1=select * from data;\n" + + // "for(i in 0..9){\n" + + // "\tevent_all_array_dateType1=event_all_array_dateType(data1.row(i)[`cbool], data1.row(i)[`cchar], data1.row(i)[`cshort], data1.row(i)[`cint],data1.row(i)[`clong], data1.row(i)[`cdouble], data1.row(i)[`cfloat], data1.row(i)[`cdate], data1.row(i)[`cmonth], data1.row(i)[`ctime], data1.row(i)[`cminute], data1.row(i)[`csecond], data1.row(i)[`cdatetime], data1.row(i)[`ctimestamp], data1.row(i)[`cnanotime], data1.row(i)[`cnanotimestamp], data1.row(i)[`cdatehour], data1.row(i)[`cuuid], data1.row(i)[`cipaddr], data1.row(i)[`cint128],data1.row(i)[`cpoint], data1.row(i)[`ccomplex], data1.row(i)[`cdecimal32], data1.row(i)[`cdecimal64], data1.row(i)[`cdecimal128])\n" + + // "\tappendEvent(inputSerializer, event_all_array_dateType1)\n" + + // "\t}" ; + // conn.run(script2); + // Thread.Sleep(10000); + // for(int i=0;i attributes = new List(); + // for(int j=0;j { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128 }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + Handler_array handler_Array = new Handler_array(); + client.subscribe(SERVER, PORT, "intput1", "test1", handler_Array, -1, true, "admin", "123456"); + + Preparedata_array(100, 10); + BasicTable bt = (BasicTable)conn.run("select * from data"); + String script2 = "data1=select * from data;\n" + + "for(i in 0..9){\n" + + "\tevent_all_array_dateType1=event_all_array_dateType(data1.row(i)[`cbool], data1.row(i)[`cchar], data1.row(i)[`cshort], data1.row(i)[`cint],data1.row(i)[`clong], data1.row(i)[`cdouble], data1.row(i)[`cfloat], data1.row(i)[`cdate], data1.row(i)[`cmonth], data1.row(i)[`ctime], data1.row(i)[`cminute], data1.row(i)[`csecond], data1.row(i)[`cdatetime], data1.row(i)[`ctimestamp], data1.row(i)[`cnanotime], data1.row(i)[`cnanotimestamp], data1.row(i)[`cdatehour], data1.row(i)[`cuuid], data1.row(i)[`cipaddr], data1.row(i)[`cint128])\n" + + "\tappendEvent(inputSerializer, event_all_array_dateType1)\n" + + "\t}"; + conn.run(script2); + Thread.Sleep(5000); + for (int i = 0; i < bt.rows(); i++) + { + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = bt.getColumn(j).getEntity(i); + Console.Out.WriteLine(pt.getDataType()); + Console.Out.WriteLine(i + "У " + j + "У" + pt.getString()); + attributes.Add(pt); + } + sender.sendEvent("event_all_array_dateType", attributes); + } + Thread.Sleep(1000); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(10, bt1.rows()); + BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); + Assert.AreEqual(10, bt2.rows()); + checkData(bt1, bt2); + Thread.Sleep(10000); + BasicTable bt3 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(10, bt3.rows()); + checkData(bt, bt3); + } + + [TestMethod] + public void test_EventClient_all_dateType_vector_no_decimal_1() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "colNames=\"col\"+string(1..20);\n" + + "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[], DATEHOUR[],UUID[],IPADDR[],INT128[]];\n" + + "share table(1:0,colNames,colTypes) as outputTable;\n"; + conn.run(script); + String script1 = "class event_all_array_dateType{\n" + + "\tboolv :: BOOL VECTOR\n" + + "\tcharv :: CHAR VECTOR\n" + + "\tshortv :: SHORT VECTOR\n" + + "\tintv :: INT VECTOR\n" + + "\tlongv :: LONG VECTOR\n" + + "\tdoublev :: DOUBLE VECTOR\n" + + "\tfloatv :: FLOAT VECTOR\n" + + "\tdatev :: DATE VECTOR\n" + + "\tmonthv :: MONTH VECTOR\n" + + "\ttimev :: TIME VECTOR\n" + + "\tminutev :: MINUTE VECTOR\n" + + "\tsecondv :: SECOND VECTOR\n" + + "\tdatetimev :: DATETIME VECTOR \n" + + "\ttimestampv :: TIMESTAMP VECTOR\n" + + "\tnanotimev :: NANOTIME VECTOR\n" + + "\tnanotimestampv :: NANOTIMESTAMP VECTOR\n" + + "\t//stringv :: STRING VECTOR\n" + + "\tdatehourv :: DATEHOUR VECTOR\n" + + "\tuuidv :: UUID VECTOR\n" + + "\tippaddrv :: IPADDR VECTOR\n" + + "\tint128v :: INT128 VECTOR\n" + + //"\t//blobv :: BLOB VECTOR\n" + + //"\tpointv :: POINT VECTOR\n" + + //"\tcomplexv :: COMPLEX VECTOR\n" + + " def event_all_array_dateType(bool, char, short, int, long, double, float, date, month, time, minute, second, datetime, timestamp, nanotime, nanotimestamp, datehour, uuid, ippaddr, int128){\n" + + "\tboolv = bool\n" + + "\tcharv = char\n" + + "\tshortv = short\n" + + "\tintv = int\n" + + "\tlongv = long\n" + + "\tdoublev = double\n" + + "\tfloatv = float\n" + + "\tdatev = date\n" + + "\tmonthv = month\n" + + "\ttimev = time\n" + + "\tminutev = minute\n" + + "\tsecondv = second\n" + + "\tdatetimev = datetime\n" + + "\ttimestampv = timestamp\n" + + "\tnanotimev = nanotime\n" + + "\tnanotimestampv = nanotimestamp\n" + + "\t//stringv = string\n" + + "\tdatehourv = datehour\n" + + "\tuuidv = uuid\n" + + "\tippaddrv = ippaddr\n" + + "\tint128v = int128\n" + + //"\t//blobv = blob\n" + + //"\tpointv = point\n" + + //"\tcomplexv = complex\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_all_array_dateType'\n" + + "eventKeys = 'boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,datehourv,uuidv,ippaddrv,int128v';\n" + + //"typeV = [BOOL[], CHAR[], SHORT[], INT[], LONG[], DOUBLE[], FLOAT[], DATE[],MONTH[], TIME[], MINUTE[], SECOND[], DATETIME[], TIMESTAMP[], NANOTIME[], NANOTIMESTAMP[], DATEHOUR[], UUID[], IPADDR[], INT128[]];\n" + + "typeV = [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE,MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, DATEHOUR, UUID, IPADDR, INT128];\n" + + + "formV = [VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR ];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; + conn.run(script1); + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128 }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + + Handler_array handler_Array = new Handler_array(); + client.subscribe(SERVER, PORT, "intput1", "test1", handler_Array, -1, true, "admin", "123456"); + + Preparedata_array(5000, 500); + BasicTable bt = (BasicTable)conn.run("select * from data"); + String script2 = "data1=select * from data;\n" + + "for(i in 0..9){\n" + + "\tevent_all_array_dateType1=event_all_array_dateType(data1.row(i)[`cbool], data1.row(i)[`cchar], data1.row(i)[`cshort], data1.row(i)[`cint],data1.row(i)[`clong], data1.row(i)[`cdouble], data1.row(i)[`cfloat], data1.row(i)[`cdate], data1.row(i)[`cmonth], data1.row(i)[`ctime], data1.row(i)[`cminute], data1.row(i)[`csecond], data1.row(i)[`cdatetime], data1.row(i)[`ctimestamp], data1.row(i)[`cnanotime], data1.row(i)[`cnanotimestamp], data1.row(i)[`cdatehour], data1.row(i)[`cuuid], data1.row(i)[`cipaddr], data1.row(i)[`cint128])\n" + + "\tappendEvent(inputSerializer, event_all_array_dateType1)\n" + + "\t}"; + conn.run(script2); + Thread.Sleep(5000); + for (int i = 0; i < bt.rows(); i++) + { + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = bt.getColumn(j).getEntity(i); + Console.Out.WriteLine(pt.getDataType()); + Console.Out.WriteLine(i + "У " + j + "У" + pt.getString()); + attributes.Add(pt); + } + sender.sendEvent("event_all_array_dateType", attributes); + } + Thread.Sleep(1000); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(10, bt1.rows()); + BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); + Assert.AreEqual(10, bt2.rows()); + checkData(bt1, bt2); + Thread.Sleep(10000); + BasicTable bt3 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(10, bt3.rows()); + checkData(bt, bt3); + } + + + [TestMethod] + public void test_EventClient_all_dateType_vector_decimal() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "colNames=\"col\"+string(1..3);\n" + + "colTypes=[DECIMAL32(2)[],DECIMAL64(7)[],DECIMAL128(19)[]];\n" + + "share table(1:0,colNames,colTypes) as outputTable;\n"; + conn.run(script); + String script1 = "class event_all_array_dateType{\n" + + "\tdecimal32v :: DECIMAL32(2) VECTOR\n" + + "\tdecimal64v :: DECIMAL64(7) VECTOR\n" + + "\tdecimal128v :: DECIMAL128(19) VECTOR \n" + + " def event_all_array_dateType(decimal32, decimal64, decimal128){\n" + + "\tdecimal32v = decimal32\n" + + "\tdecimal64v = decimal64\n" + + "\tdecimal128v = decimal128\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_all_array_dateType'\n" + + "eventKeys = 'decimal32v,decimal64v,decimal128v';\n" + + "typeV = [ DECIMAL32(2)[], DECIMAL64(7)[], DECIMAL128(19)[]];\n" + + "formV = [ VECTOR, VECTOR, VECTOR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; + conn.run(script1); + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "decimal32v", "decimal64v", "decimal128v" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }, new List { 2, 7, 19 }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler_array_decimal handler_array_decimal = new Handler_array_decimal(); + client.subscribe(SERVER, PORT, "intput1", "test1", handler_array_decimal, -1, true, "admin", "123456"); + + Preparedata_array_decimal(100, 10); + BasicTable bt = (BasicTable)conn.run("select * from data"); + String script2 = "data1=select * from data;\n" + + "for(i in 0..9){\n" + + "\tevent_all_array_dateType1=event_all_array_dateType( data1.row(i)[`cdecimal32], data1.row(i)[`cdecimal64], data1.row(i)[`cdecimal128])\n" + + "\tappendEvent(inputSerializer, event_all_array_dateType1)\n" + + "\t}"; + conn.run(script2); + Thread.Sleep(5000); + for (int i = 0; i < bt.rows(); i++) + { + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = bt.getColumn(j).getEntity(i); + Console.Out.WriteLine(pt.getDataType()); + Console.Out.WriteLine(i + "У " + j + "У" + pt.getString()); + attributes.Add(pt); + } + sender.sendEvent("event_all_array_dateType", attributes); + } + Thread.Sleep(1000); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(10, bt1.rows()); + BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); + Assert.AreEqual(10, bt2.rows()); + checkData(bt1, bt2); + Thread.Sleep(10000); + BasicTable bt3 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(10, bt3.rows()); + checkData(bt, bt3); + } + + [TestMethod] + public void test_EventClient_vector_string() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "share table(1:0,[\"col1\"],[STRING]) as outputTable;\n"; + conn.run(script); + String script1 = "class event_string{\n" + + "\tstringv :: STRING VECTOR\n" + + " def event_string(string){\n" + + "\tstringv = string\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_string'\n" + + "eventKeys = 'stringv';\n" + + "typeV = [ STRING];\n" + + "formV = [ VECTOR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; + conn.run(script1); + EventSchema scheme = new EventSchema("event_string", new List { "stringv" }, new List { DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_VECTOR }, new List { 2 }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "intput1", "test1", handler, -1, true, "admin", "123456"); + + String script2 = "\tevent_string1=event_string( [\"111\",\"222\",\"\",NULL])\n" + + "\tappendEvent(inputSerializer, event_string1)\n"; + conn.run(script2); + List attributes = new List(); + attributes.Add(new BasicStringVector(new String[] { "111", "222", "", "" })); + sender.sendEvent("event_string", attributes); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + Thread.Sleep(2000); + BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); + Assert.AreEqual(1, bt2.rows()); + checkData(bt1, bt2); + client.unsubscribe(SERVER, PORT, "intput1", "test1"); + } + + [TestMethod] + public void test_EventClient_vector_symbol() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "share table(1:0,[\"col1\"],[STRING]) as outputTable;\n"; + conn.run(script); + String script1 = "class event_symbol{\n" + + "\tsymbolv :: SYMBOL VECTOR\n" + + " def event_symbol(symbol){\n" + + "\tsymbolv = symbol\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_symbol'\n" + + "eventKeys = 'symbolv';\n" + + "typeV = [ SYMBOL];\n" + + "formV = [ VECTOR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; + conn.run(script1); + EventSchema scheme = new EventSchema("event_symbol", new List { "symbolv" }, new List { DATA_TYPE.DT_SYMBOL }, new List { DATA_FORM.DF_VECTOR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "intput1", "test1", handler, -1, true, "admin", "123456"); + + String script2 = "\tevent_symbol1=event_symbol( symbol([\"111\",\"111\",\"111\",\"111\",\"222\",\"\",NULL]))\n" + + "\tappendEvent(inputSerializer, event_symbol1)\n"; + conn.run(script2); + List attributes = new List(); + attributes.Add(new BasicSymbolVector(new String[] { "111", "111", "111", "111", "222", "", "" })); + sender.sendEvent("event_symbol", attributes); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + Thread.Sleep(2000); + BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); + Assert.AreEqual(1, bt2.rows()); + checkData(bt1, bt2); + client.unsubscribe(SERVER, PORT, "intput1", "test1"); + } + + [TestMethod] + public void test_EventClient_all_dateType_array() + { + String script0 = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "colNames=\"col\"+string(1..20);\n" + + "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[], DATEHOUR[],UUID[],IPADDR[],INT128[]];\n" + + "share table(1:0,colNames,colTypes) as outputTable;\n"; + conn.run(script0); + + + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL_ARRAY, DATA_TYPE.DT_BYTE_ARRAY, DATA_TYPE.DT_SHORT_ARRAY, DATA_TYPE.DT_INT_ARRAY, DATA_TYPE.DT_LONG_ARRAY, DATA_TYPE.DT_DOUBLE_ARRAY, DATA_TYPE.DT_FLOAT_ARRAY, DATA_TYPE.DT_DATE_ARRAY, DATA_TYPE.DT_MONTH_ARRAY, DATA_TYPE.DT_TIME_ARRAY, DATA_TYPE.DT_MINUTE_ARRAY, DATA_TYPE.DT_SECOND_ARRAY, DATA_TYPE.DT_DATETIME_ARRAY, DATA_TYPE.DT_TIMESTAMP_ARRAY, DATA_TYPE.DT_NANOTIME_ARRAY, DATA_TYPE.DT_NANOTIMESTAMP_ARRAY, DATA_TYPE.DT_DATEHOUR_ARRAY, DATA_TYPE.DT_UUID_ARRAY, DATA_TYPE.DT_IPADDR_ARRAY, DATA_TYPE.DT_INT128_ARRAY }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n"; + conn.run(script); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler_array handler_array = new Handler_array(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler_array, -1, true, "admin", "123456"); + Preparedata_array(100, 10); + BasicTable bt = (BasicTable)conn.run("select * from data"); + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = (bt.getColumn(j)); + Console.Out.WriteLine(pt.getDataType()); + attributes.Add(pt); + } + sender.sendEvent("event_all_array_dateType", attributes); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + Assert.AreEqual(1, bt1.rows()); + Thread.Sleep(2000); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + + //[TestMethod] + public void test_EventClient_reconnect() + { + String script = "share streamTable(1:0, `timestamp`time`commonKey, [TIMESTAMP,TIME,TIMESTAMP]) as outputTable;\n" + + "share streamTable(1:0, `string`timestamp`commonKey, [STRING,TIMESTAMP,TIMESTAMP]) as outputTable1;\n" + + "class MarketData{\n" + + "timestamp :: TIMESTAMP\n" + + "time :: TIME\n" + + "def MarketData(t,t1){\n" + + "timestamp = t\n" + + "time = t1\n" + + "}\n" + + "}\n" + + "class MarketData1{\n" + + "string :: STRING\n" + + "timestamp :: TIMESTAMP\n" + + "def MarketData1(s,t){\n" + + "string = s\n" + + "timestamp = t\n" + + "}\n" + + "}\n" + + "share streamTable(array(TIMESTAMP, 0) as timestamp, array(STRING, 0) as eventType, array(BLOB, 0) as blobs,array(TIMESTAMP, 0) as commonKey) as intput\n" + + "schema = table(1:0, `eventType`eventKeys`eventValuesTypeString`eventValueTypeID`eventValuesFormID, [STRING, STRING, STRING, INT[], INT[]])\n" + + "insert into schema values(\"MarketData\", \"timestamp,time\", \"TIMESTAMP,TIME\", [12 8], [0 0])\n" + + "insert into schema values(\"MarketData1\", \"string,timestamp\", \"STRING,TIMESTAMP\", [18 12], [0 0])\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schema, outputTable=intput, eventTimeField = \"timestamp\", commonField = \"timestamp\")\n"; + conn.run(script); + EventSchema scheme = new EventSchema("MarketData", new List { "timestamp", "time" }, new List { DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("MarketData1", new List { "string", "timestamp" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + + List eventTimeFields = new List() { "time", "timestamp" }; + List commonFields = new List() { "timestamp" }; + + EventClient client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler1 handler1 = new Handler1(); + client.subscribe(SERVER, PORT, "intput", "test1", handler1, -1, true, "admin", "123456"); + conn.run("marketData1 = MarketData(now(),time(1));\n marketData2 = MarketData1(\"tesrtttt\",now());\n appendEvent(inputSerializer, [marketData1,marketData2])"); + Thread.Sleep(1000); + BasicTable re = (BasicTable)conn.run("select * from outputTable"); + BasicTable re1 = (BasicTable)conn.run("select * from outputTable1"); + BasicTable re2 = (BasicTable)conn.run("select timestamp from intput"); + + Assert.AreEqual(1, re.rows()); + Assert.AreEqual(1, re1.rows()); + Assert.AreEqual(re2.getColumn(0).get(0).getString(), re.getColumn(0).get(0).getString()); + Assert.AreEqual("00:00:00.001", re.getColumn(1).get(0).getString()); + Assert.AreEqual("tesrtttt", re1.getColumn(0).get(0).getString()); + Assert.AreEqual(re2.getColumn(0).get(0).getString(), re1.getColumn(1).get(0).getString()); + client.unsubscribe(SERVER, PORT, "intput", "test1"); + } + + + + + } +} diff --git a/test/streaming/cep_test/EventSenderTest.cs b/test/streaming/cep_test/EventSenderTest.cs index 725818b..fe23747 100644 --- a/test/streaming/cep_test/EventSenderTest.cs +++ b/test/streaming/cep_test/EventSenderTest.cs @@ -1,2331 +1,2280 @@ -//using Microsoft.VisualStudio.TestTools.UnitTesting; -//using System; -//using System.Collections.Generic; -//using dolphindb; -//using dolphindb.data; -//using dolphindb.streaming; -//using dolphindb_config; -//using dolphindb.streaming.cep; -//using System.Threading; -//using System.Text; - -//namespace dolphindb_csharp_api_test.cep_test -//{ -// [TestClass] -// public class EventSenderTest -// { - -// public static DBConnection streamConn; -// private string SERVER = MyConfigReader.SERVER; -// static private int PORT = MyConfigReader.PORT; -// private readonly string USER = MyConfigReader.USER; -// private readonly string PASSWORD = MyConfigReader.PASSWORD; -// private string LOCALHOST = MyConfigReader.LOCALHOST; -// private readonly int LOCALPORT = MyConfigReader.LOCALPORT; -// static private int SUB_FLAG = MyConfigReader.SUB_FLAG; -// private string NODE1_HOST = MyConfigReader.NODE1_HOST; -// private readonly int NODE1_PORT = MyConfigReader.NODE1_PORT; -// public static string[] HASTREAM_GROUP = MyConfigReader.HASTREAM_GROUP; -// private readonly int HASTREAM_GROUPID = MyConfigReader.HASTREAM_GROUPID; -// private readonly int TIMEOUT = 10000; -// public static DBConnection conn; -// static EventSender sender; -// static EventSchema scheme; -// static EventClient client; - -// public void clear_env() -// { -// try -// { -// DBConnection conn = new DBConnection(); -// conn.connect(SERVER, PORT, "admin", "123456"); -// conn.run("a = getStreamingStat().pubTables\n" + -// "for(i in a){\n" + -// "\tstopPublishTable(i.subscriber.split(\":\")[0],int(i.subscriber.split(\":\")[1]),i.tableName,i.actions)\n" + -// "}"); -// conn.run("def getAllShare(){\n" + -// "\treturn select name from objs(true) where shared=1\n" + -// "\t}\n" + -// "\n" + -// "def clearShare(){\n" + -// "\tlogin(`admin,`123456)\n" + -// "\tallShare=exec name from pnodeRun(getAllShare)\n" + -// "\tfor(i in allShare){\n" + -// "\t\ttry{\n" + -// "\t\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],clearTablePersistence,objByName(i))\n" + -// "\t\t\t}catch(ex1){}\n" + -// "\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],undef,i,SHARED)\n" + -// "\t}\n" + -// "\ttry{\n" + -// "\t\tPST_DIR=rpc(getControllerAlias(),getDataNodeConfig{getNodeAlias()})['persistenceDir']\n" + -// "\t}catch(ex1){}\n" + -// "}\n" + -// "clearShare()"); -// } -// catch (Exception ex) -// { -// Console.WriteLine(ex.ToString()); -// } -// } - -// [TestInitialize] -// public void TestInitialize() -// { -// conn = new DBConnection(); -// conn.connect(SERVER, PORT, "admin", "123456"); -// clear_env(); -// conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); -// } - -// [TestCleanup] -// public void TestCleanup() -// { -// conn.close(); -// try { client.unsubscribe(SERVER, PORT, "inputTable", "test1"); } catch (Exception ex) { } -// try { client.unsubscribe(SERVER, PORT, "intput", "test1"); } catch (Exception ex) { } -// try { client.unsubscribe(SERVER, PORT, "inputTable", "javaStreamingApi"); } catch (Exception ex) { } -// try { client.unsubscribe(SERVER, PORT, "intput", "javaStreamingApi"); } catch (Exception ex) { } -// clear_env(); - -// } -// public void PrepareInputSerializer(String type, DATA_TYPE data_type) -// { -// String script = "login(`admin, `123456); \n" + -// "class event_dateType{\n" + -// "\tt_type :: " + type + "\n" + -// " def event_dateType(type){\n" + -// "\tt_type = type\n" + -// " }\n" + -// "\t} \n" + -// "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// "eventType = 'event_dateType'\n" + -// "eventKeys = 't_type';\n" + -// "typeV = [" + type + "];\n" + -// "formV = [SCALAR];\n" + -// "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// "share streamTable(array(STRING, 0) as eventType, array(BLOB, 0) as blobs, array(" + type + ", 0) as commonField) as intput;\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput, commonField=\"t_type\");\n" + -// "share streamTable(1000000:0, `eventType`blobs`commonField, [STRING,BLOB," + type + "]) as inputTable;"; -// conn.run(script); -// scheme = new EventSchema("event_dateType", new List { "t_type" }, new List { data_type }, new List { DATA_FORM.DF_SCALAR }); - -// List eventSchemas = new List { scheme }; -// List eventTimeFields = new List(); -// List commonFields = new List { "t_type" }; -// sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } - -// public static void Preparedata(long count) -// { -// String script = "login(`admin, `123456); \n" + -// "n=" + count + ";\n" + -// "boolv = bool(rand([true, false, NULL], n));\n" + -// "charv = char(rand(rand(-100..100, 1000) join take(char(), 4), n));\n" + -// "shortv = short(rand(rand(-100..100, 1000) join take(short(), 4), n));\n" + -// "intv = int(rand(rand(-100..100, 1000) join take(int(), 4), n));\n" + -// "longv = long(rand(rand(-100..100, 1000) join take(long(), 4), n));\n" + -// "doublev = double(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n));\n" + -// "floatv = float(rand(rand(-100..100, 1000)*0.23 join take(float(), 4), n));\n" + -// "datev = date(rand(rand(-100..100, 1000) join take(date(), 4), n));\n" + -// "monthv = month(rand(1967.12M+rand(-100..100, 1000) join take(month(), 4), n));\n" + -// "timev = time(rand(rand(0..100, 1000) join take(time(), 4), n));\n" + -// "minutev = minute(rand(12:13m+rand(-100..100, 1000) join take(minute(), 4), n));\n" + -// "secondv = second(rand(12:13:12+rand(-100..100, 1000) join take(second(), 4), n));\n" + -// "datetimev = datetime(rand(1969.12.23+rand(-100..100, 1000) join take(datetime(), 4), n));\n" + -// "timestampv = timestamp(rand(1970.01.01T00:00:00.023+rand(-100..100, 1000) join take(timestamp(), 4), n));\n" + -// "nanotimev = nanotime(rand(12:23:45.452623154+rand(-100..100, 1000) join take(nanotime(), 4), n));\n" + -// "nanotimestampv = nanotimestamp(rand(rand(-100..100, 1000) join take(nanotimestamp(), 4), n));\n" + -// "symbolv = rand((\"syms\"+string(rand(100, 1000))) join take(string(), 4), n);\n" + -// "stringv = rand((\"stringv\"+string(rand(100, 1000))) join take(string(), 4), n);\n" + -// "uuidv = rand(rand(uuid(), 1000) join take(uuid(), 4), n);\n" + -// "datehourv = datehour(rand(datehour(1969.12.31T12:45:12)+rand(-100..100, 1000) join take(datehour(), 4), n));\n" + -// "ippaddrv = rand(rand(ipaddr(), 1000) join take(ipaddr(), 4), n);\n" + -// "int128v = rand(rand(int128(), 1000) join take(int128(), 4), n);\n" + -// "blobv = blob(string(rand((\"blob\"+string(rand(100, 1000))) join take(\"\", 4), n)));\n" + -// "complexv = rand(complex(rand(100, 1000), rand(100, 1000)) join NULL, n);\n" + -// "pointv = rand(point(rand(100, 1000), rand(100, 1000)) join NULL, n);\n" + -// "decimal32v = decimal32(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 3);\n" + -// "decimal64v = decimal64(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 8);\n" + -// "decimal128v = decimal128(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 10);\n" + -// "share table(boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, stringv, datehourv, uuidv, ippaddrv, int128v, blobv) as data;\n"; -// conn.run(script); -// } - -// public static void Preparedata_array(long count1, long count2) -// { -// String script1 = "login(`admin, `123456); \n" + -// "n=" + count1 + ";\n" + -// "m=" + count2 + ";\n" + -// "cbool = array(BOOL[]).append!(cut(take([true, false, NULL], n), m))\n" + -// "cchar = array(CHAR[]).append!(cut(take(char(-100..100 join NULL), n), m))\n" + -// "cshort = array(SHORT[]).append!(cut(take(short(-100..100 join NULL), n), m))\n" + -// "cint = array(INT[]).append!(cut(take(-100..100 join NULL, n), m))\n" + -// "clong = array(LONG[]).append!(cut(take(long(-100..100 join NULL), n), m))\n" + -// "cdouble = array(DOUBLE[]).append!(cut(take(-100..100 join NULL, n) + 0.254, m))\n" + -// "cfloat = array(FLOAT[]).append!(cut(take(-100..100 join NULL, n) + 0.254f, m))\n" + -// "cdate = array(DATE[]).append!(cut(take(2012.01.01..2012.02.29, n), m))\n" + -// "cmonth = array(MONTH[]).append!(cut(take(2012.01M..2013.12M, n), m))\n" + -// "ctime = array(TIME[]).append!(cut(take(09:00:00.000 + 0..99 * 1000, n), m))\n" + -// "cminute = array(MINUTE[]).append!(cut(take(09:00m..15:59m, n), m))\n" + -// "csecond = array(SECOND[]).append!(cut(take(09:00:00 + 0..999, n), m))\n" + -// "cdatetime = array(DATETIME[]).append!(cut(take(2012.01.01T09:00:00 + 0..999, n), m))\n" + -// "ctimestamp = array(TIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000 + 0..999 * 1000, n), m))\n" + -// "cnanotime =array(NANOTIME[]).append!(cut(take(09:00:00.000000000 + 0..999 * 1000000000, n), m))\n" + -// "cnanotimestamp = array(NANOTIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000000000 + 0..999 * 1000000000, n), m))\n" + -// "cuuid = array(UUID[]).append!(cut(take(uuid([\"5d212a78-cc48-e3b1-4235-b4d91473ee87\", \"5d212a78-cc48-e3b1-4235-b4d91473ee88\", \"5d212a78-cc48-e3b1-4235-b4d91473ee89\", \"\"]), n), m))\n" + -// "cdatehour = array(DATEHOUR[]).append!(cut(take(datehour(1..10 join NULL), n), m))\n" + -// "cipaddr = array(IPADDR[]).append!(cut(take(ipaddr([\"192.168.100.10\", \"192.168.100.11\", \"192.168.100.14\", \"\"]), n), m))\n" + -// "cint128 = array(INT128[]).append!(cut(take(int128([\"e1671797c52e15f763380b45e841ec32\", \"e1671797c52e15f763380b45e841ec33\", \"e1671797c52e15f763380b45e841ec35\", \"\"]), n), m))\n" + -// "ccomplex = array( COMPLEX[]).append!(cut(rand(complex(rand(100, 1000), rand(100, 1000)) join NULL, n), m))\n" + -// "cpoint = array(POINT[]).append!(cut(rand(point(rand(100, 1000), rand(100, 1000)) join NULL, n), m))\n" + -// "cdecimal32 = array(DECIMAL32(2)[]).append!(cut(decimal32(take(-100..100 join NULL, n) + 0.254, 3), m))\n" + -// "cdecimal64 = array(DECIMAL64(7)[]).append!(cut(decimal64(take(-100..100 join NULL, n) + 0.25467, 4), m))\n" + -// "cdecimal128 = array(DECIMAL128(19)[]).append!(cut(decimal128(take(-100..100 join NULL, n) + 0.25467, 5), m))\n" + -// "share table(cbool, cchar, cshort, cint, clong, cdouble, cfloat, cdate, cmonth, ctime, cminute, csecond, cdatetime, ctimestamp, cnanotime, cnanotimestamp, cdatehour, cuuid, cipaddr, cint128) as data;\n"; -// conn.run(script1); -// } - -// public void checkData(BasicTable exception, BasicTable resTable) -// { -// Assert.AreEqual(exception.rows(), resTable.rows()); -// for (int i = 0; i < exception.columns(); i++) -// { -// Console.Out.WriteLine("col" + resTable.getColumnName(i)); -// Assert.AreEqual(exception.getColumn(i).getString(), resTable.getColumn(i).getString()); -// } -// } - - -// class Handler : EventMessageHandler -// { - -// public void doEvent(String eventType, List attribute) -// { -// Console.Out.WriteLine("eventType: " + eventType); -// for (int i = 0; i < attribute.Count; i++) { -// Console.Out.WriteLine(attribute[i].ToString()); -// } - -// try -// { -// conn.run("tableInsert{outputTable}", attribute); -// } -// catch (Exception e) -// { -// System.Console.Out.WriteLine(e.ToString()); -// } -// } -// }; - -// class Handler_array : EventMessageHandler -// { - -// public void doEvent(String eventType, List attributes) -// { -// Console.WriteLine("eventType: " + eventType); -// String boolv = attributes[0].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String charv = attributes[1].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String shortv = attributes[2].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String intv = attributes[3].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String longv = attributes[4].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String doublev = attributes[5].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String floatv = attributes[6].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String datev = attributes[7].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String monthv = attributes[8].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String timev = attributes[9].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String minutev = attributes[10].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String secondv = attributes[11].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String datetimev = attributes[12].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String timestampv = attributes[13].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String nanotimev = attributes[14].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String nanotimestampv = attributes[15].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String datehourv = attributes[16].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); -// String uuidv = attributes[17].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); -// String ippaddrv = attributes[18].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); -// String int128v = attributes[19].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); -// String pointv = attributes[20].getString().Replace("(,)", "(NULL,NULL)"); -// pointv = pointv.Substring(1, pointv.Length - 1); -// String[] separators = { "),(" }; -// String[] point1 = pointv.Split(separators, StringSplitOptions.None); -// String point2 = null; -// StringBuilder re1 = new StringBuilder(); -// StringBuilder re2 = new StringBuilder(); -// for (int i = 0; i < point1.Length; i++) -// { -// point2 = point1[i]; -// String[] dataType3 = point2.Split(','); -// re1.Append(dataType3[0]); -// re1.Append(' '); -// re2.Append(dataType3[1]); -// re2.Append(' '); -// } -// pointv = re1 + "," + re2; -// pointv = pointv.Replace("(", "").Replace(")", ""); - -// String complex1 = attributes[21].getString().Replace(",,", ",NULL+NULL,").Replace("[,", "[NULL+NULL,").Replace(",]", ",NULL+NULL]"); -// complex1 = complex1.Substring(1, complex1.Length - 1); -// String[] complex2 = complex1.Split(','); -// String complex3 = null; -// StringBuilder re11 = new StringBuilder(); -// StringBuilder re21 = new StringBuilder(); -// for (int i = 0; i < complex2.Length; i++) -// { -// complex3 = complex2[i]; -// String[] complex4 = complex3.Split('+'); -// re11.Append(complex4[0]); -// re11.Append(' '); -// re21.Append(complex4[1]); -// re21.Append(' '); -// } -// complex1 = re11 + "," + re21; -// String complexv = complex1.Replace("i", ""); - -// String decimal32v = attributes[22].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String decimal64v = attributes[23].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); -// String decimal128v = attributes[24].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); - -// for (int i = 0; i < attributes.Count; i++) -// { -// //attributes[i].getString(); -// Console.WriteLine(attributes[i].getString()); -// } -// String script = null; -// //script = String.Format("insert into outputTable values( {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},[datehour({0})],[uuid({0})],[ipaddr({0})],[int128({0})],[point({0})],[complex({0})],{0},{0},{0})", boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, datehourv, uuidv, ippaddrv, int128v, pointv, complexv, decimal32v, decimal64v, decimal128v); -// script = String.Format("insert into outputTable values( {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},[datehour({16})],[uuid({17})],[ipaddr({18})],[int128({19})])", boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, datehourv, uuidv, ippaddrv, int128v); -// conn.run(script); -// } -// }; - - -// public void PrepareUser(String userName, String password) -// { -// DBConnection conn = new DBConnection(); -// conn.connect(SERVER, PORT, "admin", "123456"); -// conn.run("def create_user(){try{deleteUser(`" + userName + ")}catch(ex){};createUser(`" + userName + ", '" + password + "');};" + -// "rpc(getControllerAlias(),create_user);"); -// } - -// [TestMethod] -// public void test_EventSender_EventScheme_null() -// { -// List eventSchemas = new List(); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("eventSchemas must not be empty.", re); -// } - -// [TestMethod] -// public void test_EventSender_EventScheme_null_1() -// { -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", null, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("eventSchema must be non-null and non-empty.", re); -// } - -// [TestMethod] -// public void test_EventSender_EventType_null() -// { -// EventSchema scheme = new EventSchema(null, new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("eventSchema must be non-null and non-empty.", re); -// } - -// [TestMethod] -// public void test_EventSender_EventType_null_1() -// { -// EventSchema scheme = new EventSchema("", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("eventType must not be empty.", re); -// } - -// [TestMethod] -// public void test_EventSender_EventType_special_character() -// { -// String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n"; -// conn.run(script); -// EventSchema scheme = new EventSchema("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ", new List { "market" }, new List { DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR}); -// List eventSchemas = new List { scheme }; -// List eventTimeFields = new List(); -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// List attributes1 = new List(); -// attributes1.Add(new BasicString("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ")); -// List attributes2 = new List(); -// BasicString bb = new BasicString(""); -// bb.setNull(); -// attributes2.Add(bb); -// sender.sendEvent("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ", attributes1); -// sender.sendEvent("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ", attributes2); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(2, bt1.rows()); -// } - -// [TestMethod] -// public void test_EventSender_EventType_repetition() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "time", "time1", "time2", "time3" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR , DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR}); -// EventSchema scheme1 = new EventSchema("market", new List { "market", "time0", "time1", "time2", "time3" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); - -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// eventSchemas.Add(scheme1); -// List eventTimeFields = new List() { "market" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("EventType must be unique", re); -// } - -// [TestMethod] -// public void test_EventSender_fieldNames_null() -// { -// String re = null; -// try -// { -// EventSchema scheme = new EventSchema("market", null, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("eventKey in eventSchema must be non-empty.", re); -// } - -// [TestMethod] -// public void test_EventSender_fieldNames_null_1() -// { -// EventSchema scheme = new EventSchema("market", new List { "", "market", "time3", "time2", "time3" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "market" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("fieldName must be non-null and non-empty.", re); -// } - -// [TestMethod] -// public void test_EventSender_fieldName_repetition() -// { -// conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "time", "time" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "time" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("EventSchema cannot has duplicated fieldName in fieldNames.", re); -// } - -// [TestMethod] -// public void test_EventSender_fieldName_one_colume() -// { -// conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "time" }, new List { DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "time" }; -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// List attributes = new List(); -// attributes.Add(new BasicTime(1)); -// sender.sendEvent("market", attributes); -// BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// Assert.AreEqual(1, re.rows()); -// Assert.AreEqual("00:00:00.001", re.getColumn(0).get(0).getString()); -// } - -// [TestMethod] -// public void test_EventSender_FieldTypes_null() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, null, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR}); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("the number of eventKey, eventTypes, eventForms and eventExtraParams (if set) must have the same length.", re); -// } - -// [TestMethod] -// public void test_EventSender_FieldTypes_not_support() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_VOID, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Compression Failed: only support integral and temporal data, not support DT_VOID.", re); -// } - -// [TestMethod] -// public void test_EventSender_FieldForms_null() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_VOID, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, null); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("the number of eventKey, eventTypes, eventForms and eventExtraParams (if set) must have the same length.", re); -// } - -// [TestMethod] -// public void test_EventSender_FieldForms_null_1() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_VOID, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List ()); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("the number of eventKey, eventTypes, eventForms and eventExtraParams (if set) must have the same length.", re); -// } - -// [TestMethod] -// public void test_EventSender_FieldForms_not_support() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("attrForm only can be DF_SCALAR or DF_VECTOR.", re); -// } - -// //[TestMethod] -// //public void test_EventSender_fieldExtraParams_null() -// //{ -// // conn.run("share streamTable(1000000:0, `eventType`event`market`code`decimal32`decimal64`decimal128, [STRING,BLOB,STRING,STRING,DECIMAL32(0),DECIMAL64(1),DECIMAL128(2)]) as inputTable;"); -// // EventSchema scheme = new EventSchema("market", new List { "market", "code", "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 0, 0, 0, 1, 2 }); -// // List eventSchemas = new List(); -// // eventSchemas.Add(scheme); -// // List eventTimeFields = new List(); -// // List commonFields = new List() { "market", "code", "decimal32", "decimal64", "decimal128" }; - -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// // List attributes = new List(); -// // attributes.Add(new BasicString("1")); -// // attributes.Add(new BasicString("2")); -// // attributes.Add(new BasicDecimal32("2", 0)); -// // attributes.Add(new BasicDecimal64("2.88", 1)); -// // attributes.Add(new BasicDecimal128("-2.1", 2)); -// // String re = null; -// // try -// // { -// // sender.sendEvent("market", attributes); - -// // } -// // catch (Exception ex) -// // { -// // re = ex.Message; -// // } -// // Assert.AreEqual("The decimal attribute' scale doesn't match to schema fieldExtraParams scale.", re); -// //} - -// //[TestMethod] -// //public void test_EventSender_fieldExtraParams_null_1() -// //{ -// // conn.run("share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;"); -// // EventSchema scheme = new EventSchema("market", new List { "market", "code" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR }); -// // List eventSchemas = new List(); -// // eventSchemas.Add(scheme); -// // List eventTimeFields = new List(); -// // List commonFields = new List(); - -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// // List attributes = new List(); -// // attributes.Add(new BasicString("1")); -// // attributes.Add(new BasicString("2")); -// // sender.sendEvent("market", attributes); -// // BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// // Assert.AreEqual(1, re.rows()); -// //} -// //[TestMethod] -// //public void test_EventSender_fieldExtraParams_not_match() -// //{ -// // conn.run("share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;"); -// // EventSchema scheme = new EventSchema("market", new List { "market", "code" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR }, new List { 1 }); -// // List eventSchemas = new List(); -// // eventSchemas.Add(scheme); -// // List eventTimeFields = new List(); -// // List commonFields = new List(); - -// // String re = null; -// // try -// // { -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// // } -// // catch (Exception ex) -// // { -// // re = ex.Message; -// // } -// // Assert.AreEqual("the number of eventKey, eventTypes, eventForms and eventExtraParams (if set) must have the same length.", re); -// //} -// //[TestMethod] -// //public void test_EventSender_fieldExtraParams_set_not_true() -// //{ -// // EventSchema scheme = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 10, 19, 39 }); -// // List eventSchemas = new List(); -// // eventSchemas.Add(scheme); -// // List eventTimeFields = new List(); -// // List commonFields = new List() { "market", "code", "decimal32", "decimal64", "decimal128" }; - -// // String re = null; -// // try -// // { -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL32 scale 10 is out of bounds, it must be in [0,9].", re); - -// // EventSchema scheme1 = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 1, 19, 39 }); -// // List eventSchemas1 = new List(); -// // eventSchemas1.Add(scheme1); -// // String re1 = null; -// // try -// // { -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas1, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re1 = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL64 scale 19 is out of bounds, it must be in [0,18].", re1); - - -// // EventSchema scheme2 = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 1, 18, 39 }); -// // List eventSchemas2 = new List(); -// // eventSchemas2.Add(scheme2); -// // String re2 = null; -// // try -// // { -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas2, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re2 = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL128 scale 39 is out of bounds, it must be in [0,38].", re2); - -// // EventSchema scheme3 = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { -1, 10, 10 }); -// // List eventSchemas3 = new List(); -// // eventSchemas3.Add(scheme3); -// // String re3 = null; -// // try -// // { -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas3, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re3 = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL32 scale -1 is out of bounds, it must be in [0,9].", re3); - -// // EventSchema scheme4 = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 1, -1, 0 }); -// // List eventSchemas4 = new List(); -// // eventSchemas4.Add(scheme4); -// // String re4 = null; -// // try -// // { -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas4, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re4 = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL64 scale -1 is out of bounds, it must be in [0,18].", re4); - -// // EventSchema scheme5 = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 0, 0, -1 }); -// // List eventSchemas5 = new List(); -// // eventSchemas5.Add(scheme5); -// // String re5 = null; -// // try -// // { -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas5, eventTimeFields, commonFields); - -// // } -// // catch (Exception ex) -// // { -// // re5 = ex.Message; -// // } -// // Assert.AreEqual("DT_DECIMAL128 scale -1 is out of bounds, it must be in [0,38].", re5); -// //} -// //[TestMethod] -// //public void test_EventSender_fieldExtraParams_set_true() -// //{ -// // conn.run("share streamTable(1000000:0, `eventType`event`market`code`decimal32`decimal64`decimal128, [STRING,BLOB,STRING,STRING,DECIMAL32(0),DECIMAL64(1),DECIMAL128(2)]) as inputTable;"); -// // conn.run("share streamTable(1000000:0, `eventType`event`market`code`decimal32`decimal64`decimal128, [STRING,BLOB,STRING,STRING,DECIMAL32(0),DECIMAL64(1),DECIMAL128(2)]) as inputTable;"); -// // EventSchema scheme = new EventSchema("market", new List { "market", "code", "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 0, 0, 0, 1, 2 }); -// // List eventSchemas = new List(); -// // eventSchemas.Add(scheme); -// // List eventTimeFields = new List(); -// // List commonFields = new List() { "market", "code", "decimal32", "decimal64", "decimal128" }; -// // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// // List attributes = new List(); -// // attributes.Add(new BasicString("1")); -// // attributes.Add(new BasicString("2")); -// // attributes.Add(new BasicDecimal32("2", 0)); -// // attributes.Add(new BasicDecimal64("2.88", 1)); -// // attributes.Add(new BasicDecimal128("-2.1", 2)); -// // sender.sendEvent("market", attributes); -// // BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// // Assert.AreEqual(1, re.rows()); -// // Assert.AreEqual("1", re.getColumn(2).get(0).getString()); -// // Assert.AreEqual("2", re.getColumn(3).get(0).getString()); -// // Assert.AreEqual("2", re.getColumn(4).get(0).getString()); -// // Assert.AreEqual("2.9", re.getColumn(5).get(0).getString()); -// // Assert.AreEqual("-2.10", re.getColumn(6).get(0).getString()); -// //} - -// [TestMethod] -// public void test_EventSender_eventTimeFields_not_exist() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "datetimev" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Event market doesn't contain eventTimeKey datetimev.", re); -// } -// [TestMethod] -// public void test_EventSender_eventTimeFields_not_time_column() -// { -// conn.run("share streamTable(1000000:0, `string`eventType`event, [STRING,STRING,BLOB]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "code"}, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "market" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("The first column of the output table must be temporal if eventTimeKey is specified.", re); -// } - -// [TestMethod] -// public void test_EventSender_eventTimeFields_one_column() -// { -// conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("market1", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); - - -// List eventTimeFields = new List() { "time" }; -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// List attributes = new List(); -// attributes.Add(new BasicString("123456")); -// attributes.Add(new BasicTime(12)); -// sender.sendEvent("market", attributes); - -// List attributes1 = new List(); -// attributes1.Add(new BasicTime(10000)); -// attributes1.Add(new BasicTime(123456)); -// sender.sendEvent("market1", attributes1); - -// BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// Assert.AreEqual(2, re.rows()); -// Assert.AreEqual("00:00:00.012", re.getColumn(0).get(0).getString()); -// Assert.AreEqual("00:00:10.000", re.getColumn(0).get(1).getString()); -// } - -// [TestMethod] -// public void test_EventSender_eventTimeFields_one_column_1() -// { -// conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("market", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); -// List eventTimeFields = new List() { "time1" }; -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Event market doesn't contain eventTimeKey time1.", re); -// } - -// [TestMethod] -// public void test_EventSender_eventTimeFields_two_column() -// { -// conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("market1", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); - -// List eventTimeFields = new List() { "time", "time1" }; -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// List attributes = new List(); -// attributes.Add(new BasicString("123456")); -// attributes.Add(new BasicTime(12)); -// sender.sendEvent("market", attributes); - -// List attributes1 = new List(); -// attributes1.Add(new BasicTime(10000)); -// attributes1.Add(new BasicTime(123456)); -// sender.sendEvent("market1", attributes1); - -// BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// Assert.AreEqual(2, re.rows()); -// Assert.AreEqual("00:00:00.012", re.getColumn(0).get(0).getString()); -// Assert.AreEqual("00:02:03.456", re.getColumn(0).get(1).getString()); -// } - -// [TestMethod] -// public void test_EventSender_commonFields_not_exist() -// { -// conn.run("share streamTable(1000000:0, `time`eventType`event`comment, [TIME,STRING,BLOB,TIME]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("market1", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); - -// List eventTimeFields = new List() { "time", "time1" }; -// List commonFields = new List() { "time123" }; -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Event market doesn't contain commonField time123", re); -// } - -// [TestMethod] -// public void test_EventSender_commonFields_one_column() -// { -// conn.run("share streamTable(1000000:0, `time`eventType`event`comment, [TIME,STRING,BLOB,TIME]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("market1", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); - -// List eventTimeFields = new List() { "time", "time1" }; -// List commonFields = new List() { "time" }; -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// List attributes = new List(); -// attributes.Add(new BasicString("123456")); -// attributes.Add(new BasicTime(12)); -// sender.sendEvent("market", attributes); - -// List attributes1 = new List(); -// attributes1.Add(new BasicTime(10000)); -// attributes1.Add(new BasicTime(123456)); -// sender.sendEvent("market1", attributes1); - -// BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// Assert.AreEqual(2, re.rows()); -// Assert.AreEqual("00:00:00.012", re.getColumn(0).get(0).getString()); -// Assert.AreEqual("00:02:03.456", re.getColumn(0).get(1).getString()); -// Assert.AreEqual("00:00:00.012", re.getColumn(3).get(0).getString()); -// Assert.AreEqual("00:00:10.000", re.getColumn(3).get(1).getString()); -// } - -// [TestMethod] -// public void test_EventSender_commonFields_one_column_1() -// { -// conn.run("share streamTable(1000000:0, `time`eventType`event`comment, [TIME,STRING,BLOB,TIME]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("market1", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); - -// List eventTimeFields = new List() { "time", "time1" }; -// List commonFields = new List() { "time1" }; -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Event market doesn't contain commonField time1", re); -// } - -// [TestMethod] -// public void test_EventSender_commonFields_two_column() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// EventSchema scheme1 = new EventSchema("market1", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// eventSchemas.Add(scheme1); - -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// List attributes = new List(); -// attributes.Add(new BasicString("1234567")); -// attributes.Add(new BasicTime(12)); -// sender.sendEvent("market", attributes); - -// List attributes1 = new List(); -// attributes1.Add(new BasicString("tesrtrrr")); -// attributes1.Add(new BasicTime(123456)); -// sender.sendEvent("market1", attributes1); ; - -// BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// Assert.AreEqual(2, re.rows()); -// Assert.AreEqual("00:00:00.012", re.getColumn(2).get(0).getString()); -// Assert.AreEqual("00:02:03.456", re.getColumn(2).get(1).getString()); -// Assert.AreEqual("1234567", re.getColumn(3).get(0).getString()); -// Assert.AreEqual("tesrtrrr", re.getColumn(3).get(1).getString()); -// } - -// [TestMethod] -// public void test_EventSender_connect_not_connect() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// DBConnection conn1 = new DBConnection(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn1, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Database connection is not established yet.", re); -// } - -// [TestMethod] -// public void test_EventSender_connect_duplicated() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// EventSender sender1 = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// } - -// [TestMethod] -// public void test_EventSender_conn_ssl_true() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// DBConnection conn1 = new DBConnection(false, true); -// conn1.connect(SERVER, PORT); -// EventSender sender = new EventSender(conn1, "inputTable", eventSchemas, eventTimeFields, commonFields); -// List attributes1 = new List(); -// attributes1.Add(new BasicString("tesrtrrr")); -// attributes1.Add(new BasicTime(1)); -// sender.sendEvent("market", attributes1); - -// BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// Assert.AreEqual(1, re.rows()); -// Assert.AreEqual("00:00:00.001", re.getColumn(2).get(0).getString()); -// Assert.AreEqual("tesrtrrr", re.getColumn(3).get(0).getString()); -// } -// [TestMethod] -// public void test_EventSender_conn_compress_true() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// DBConnection conn1 = new DBConnection(false, true, true); -// conn1.connect(SERVER, PORT); -// EventSender sender = new EventSender(conn1, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// List attributes1 = new List(); -// attributes1.Add(new BasicString("tesrtrrr")); -// attributes1.Add(new BasicTime(1)); -// sender.sendEvent("market", attributes1); - -// BasicTable re = (BasicTable)conn.run("select * from inputTable"); -// Assert.AreEqual(1, re.rows()); -// Assert.AreEqual("00:00:00.001", re.getColumn(2).get(0).getString()); -// Assert.AreEqual("tesrtrrr", re.getColumn(3).get(0).getString()); -// } -// [TestMethod] -// public void test_EventSender_conn_not_admin() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// PrepareUser("user1", "123456"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// DBConnection conn1 = new DBConnection(false, true, true); -// conn1.connect(SERVER, PORT, "user1", "123456"); -// EventSender sender = new EventSender(conn1, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// List attributes1 = new List(); -// attributes1.Add(new BasicString("tesrtrrr")); -// attributes1.Add(new BasicTime(1)); -// sender.sendEvent("market", attributes1); - -// BasicTable re = (BasicTable)conn1.run("select * from inputTable"); -// Assert.AreEqual(1, re.rows()); -// Assert.AreEqual("00:00:00.001", re.getColumn(2).get(0).getString()); -// Assert.AreEqual("tesrtrrr", re.getColumn(3).get(0).getString()); -// } - -// [TestMethod] -// public void test_EventSender_connect_tableName_not_exist() -// { -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable11", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual(true, re.Contains("Can't find the object with name inputTable11")); -// } - -// [TestMethod] -// public void test_EventSender_connect_tableName_null() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// String re = null; -// EventSender sender1 = new EventSender(conn, null, eventSchemas, eventTimeFields, commonFields); - -// try -// { -// EventSender sender = new EventSender(conn, null, eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual(true, re.Contains("FROM clause must return a table.")); -// String re1 = null; -// try -// { -// EventSender sender = new EventSender(conn, "", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re1 = ex.Message; -// } -// Assert.AreEqual(true, re1.Contains("select top 0 * from ")); -// } - -// [TestMethod] -// public void test_EventSender_connect_table_cloumn_not_match() -// { -// String script = "share streamTable(1000000:0, `time`eventType`event, [TIMESTAMP,STRING,BLOB]) as inputTable1;\n"; -// conn.run(script); -// EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippaddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// String re = null; -// try -// { -// EventSender sender = new EventSender(conn, "inputTable1", eventSchemas, eventTimeFields, commonFields); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Incompatible inputTable1 columns, expected: 2, got: 3", re); -// } - -// [TestMethod] -// public void test_EventSender_sendEvent_eventType_not_exist() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// List attributes1 = new List(); -// attributes1.Add(new BasicString("tesrtrrr")); -// attributes1.Add(new BasicTime(1)); -// String re = null; -// try -// { -// sender.sendEvent("market111", attributes1); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("unknown eventType market111", re); -// } -// [TestMethod] -// public void test_EventSender_sendEvent_eventType_null() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// List attributes1 = new List(); -// attributes1.Add(new BasicString("tesrtrrr")); -// attributes1.Add(new BasicTime(1)); -// String re = null; -// try -// { -// sender.sendEvent(null, attributes1); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Value cannot be null. (Parameter 'eventType')", re); -// String re1 = null; -// try -// { -// sender.sendEvent("", attributes1); -// } -// catch (Exception ex) -// { -// re1 = ex.Message; -// } -// Assert.AreEqual("unknown eventType ", re1); -// } - -// [TestMethod] -// public void test_EventSender_sendEvent_attributes_column_not_match() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// List attributes1 = new List(); -// attributes1.Add(new BasicString("tesrtrrr")); -// // attributes1.Add(new BasicTime(1)); -// String re = null; -// try -// { -// sender.sendEvent("market", attributes1); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("the number of event values does not match", re); -// } -// [TestMethod] -// public void test_EventSender_sendEvent_attributes_type_not_match() -// { -// conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); -// EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List() { "time", "market" }; -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// List attributes1 = new List(); -// attributes1.Add(new BasicString("tesrtrrr")); -// attributes1.Add(new BasicInt(1)); -// String re = null; -// try -// { -// sender.sendEvent("market", attributes1); -// } -// catch (Exception ex) -// { -// re = ex.Message; -// } -// Assert.AreEqual("Expected type for the field time of market : TIME, but now it is INT", re); -// } - -// [TestMethod] -// public void test_EventSender_sendEvent_attributes_null() -// { -// String script = "share streamTable(1000000:0, `time`eventType`event, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + -// "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`symbolv`stringv`datehourv`uuidv`ippAddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, SYMBOL,STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; -// conn.run(script); -// EventSchema scheme = new EventSchema("event_all_dateType_null", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "symbolv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_SYMBOL, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128 , DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "datetimev" }; -// List commonFields = new List() ; -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); -// List attributes = new List(); -// BasicBoolean boolv = new BasicBoolean(true); -// //boolv.setNull(); -// BasicByte charv = new BasicByte((byte)1); -// charv.setNull(); -// BasicShort shortv = new BasicShort((short)1); -// shortv.setNull(); -// BasicInt intv = new BasicInt(0); -// intv.setNull(); -// BasicLong longv = new BasicLong(0); -// longv.setNull(); -// BasicDouble doublev = new BasicDouble(0); -// doublev.setNull(); -// BasicFloat floatv = new BasicFloat(0); -// floatv.setNull(); -// BasicDate datev = new BasicDate(0); -// datev.setNull(); -// BasicMonth monthv = new BasicMonth(0); -// monthv.setNull(); -// BasicTime timev = new BasicTime(0); -// timev.setNull(); -// BasicMinute minutev = new BasicMinute(0); -// minutev.setNull(); -// BasicSecond secondv = new BasicSecond(0); -// secondv.setNull(); -// BasicDateTime datetimev = new BasicDateTime(0); -// datetimev.setNull(); -// BasicTimestamp timestampv = new BasicTimestamp(0); -// timestampv.setNull(); -// BasicNanoTime nanotimev = new BasicNanoTime(0); -// nanotimev.setNull(); -// BasicNanoTimestamp nanotimestampv = new BasicNanoTimestamp(0); -// nanotimestampv.setNull(); -// BasicString symbolv = new BasicString("0"); -// symbolv.setNull(); -// BasicString stringv = new BasicString("0"); -// stringv.setNull(); -// BasicUuid uuidv = new BasicUuid(1, 1); -// uuidv.setNull(); -// BasicDateHour datehourv = new BasicDateHour(0); -// datehourv.setNull(); -// BasicIPAddr ippAddrv = new BasicIPAddr(1, 1); -// ippAddrv.setNull(); -// BasicInt128 int128v = new BasicInt128(1, 1); -// int128v.setNull(); -// BasicString blobv = new BasicString("= new String[0],true", true); -// blobv.setNull(); -// attributes.Add(boolv); -// attributes.Add(charv); -// attributes.Add(shortv); -// attributes.Add(intv); -// attributes.Add(longv); -// attributes.Add(doublev); -// attributes.Add(floatv); -// attributes.Add(datev); -// attributes.Add(monthv); -// attributes.Add(timev); -// attributes.Add(minutev); -// attributes.Add(secondv); -// attributes.Add(datetimev); -// attributes.Add(timestampv); -// attributes.Add(nanotimev); -// attributes.Add(nanotimestampv); -// attributes.Add(symbolv); -// attributes.Add(stringv); -// attributes.Add(datehourv); -// attributes.Add(uuidv); -// attributes.Add(ippAddrv); -// attributes.Add(int128v); -// attributes.Add(blobv); -// sender.sendEvent("event_all_dateType_null", attributes); -// //conn.run("tableInsert{outputTable}", attributes); -// Thread.Sleep(2000); -// BasicTable re = (BasicTable)conn.run("select * from outputTable;"); -// Assert.AreEqual(1, re.rows()); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_subscribe_attributes_vector_null() -// { -// String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + -// "colNames=\"col\"+string(1..25);\n" + -// "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[],DATEHOUR[],UUID[],IPAddR[],INT128[],POINT[],COMPLEX[],DECIMAL32(2)[],DECIMAL64(7)[],DECIMAL128(10)[]];\n" + -// "share table(1:0,colNames,colTypes) as outputTable;\n"; -// conn.run(script); -// EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128 }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); - -// List attributes = new List(); ; -// attributes.Add(new BasicBooleanVector(0)); -// attributes.Add(new BasicByteVector(0)); -// attributes.Add(new BasicShortVector(0)); -// attributes.Add(new BasicIntVector(0)); -// attributes.Add(new BasicLongVector(0)); -// attributes.Add(new BasicDoubleVector(0)); -// attributes.Add(new BasicFloatVector(0)); -// attributes.Add(new BasicDateVector(0)); -// attributes.Add(new BasicMonthVector(0)); -// attributes.Add(new BasicTimeVector(0)); -// attributes.Add(new BasicMinuteVector(0)); -// attributes.Add(new BasicSecondVector(0)); -// attributes.Add(new BasicDateTimeVector(0)); -// attributes.Add(new BasicTimestampVector(0)); -// attributes.Add(new BasicNanoTimeVector(0)); -// attributes.Add(new BasicNanoTimestampVector(0)); -// attributes.Add(new BasicDateHourVector(0)); -// attributes.Add(new BasicUuidVector(0)); -// attributes.Add(new BasicIPAddrVector(0)); -// attributes.Add(new BasicInt128Vector(0)); -// sender.sendEvent("event_all_array_dateType", attributes); -// //conn.run("tableInsert{outputTable}", attributes); -// Thread.Sleep(2000); -// BasicTable re = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(1, re.rows()); -// BasicTable re1 = (BasicTable)conn.run("select * from outputTable;"); -// Assert.AreEqual(1, re1.rows()); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } -// [TestMethod] -// public void test_EventClient_subscribe_attributes_array_null() -// { -// String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + -// "colNames=\"col\"+string(1..24);\n" + -// "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[],DATEHOUR[],UUID[],IPAddR[],INT128[],POINT[],COMPLEX[],DECIMAL32(2)[],DECIMAL64(7)[]];\n" + -// "share table(1:0,colNames,colTypes) as outputTable;\n"; -// conn.run(script); - -// EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL_ARRAY, DATA_TYPE.DT_BYTE_ARRAY, DATA_TYPE.DT_SHORT_ARRAY, DATA_TYPE.DT_INT_ARRAY, DATA_TYPE.DT_LONG_ARRAY, DATA_TYPE.DT_DOUBLE_ARRAY, DATA_TYPE.DT_FLOAT_ARRAY, DATA_TYPE.DT_DATE_ARRAY, DATA_TYPE.DT_MONTH_ARRAY, DATA_TYPE.DT_TIME_ARRAY, DATA_TYPE.DT_MINUTE_ARRAY, DATA_TYPE.DT_SECOND_ARRAY, DATA_TYPE.DT_DATETIME_ARRAY, DATA_TYPE.DT_TIMESTAMP_ARRAY, DATA_TYPE.DT_NANOTIME_ARRAY, DATA_TYPE.DT_NANOTIMESTAMP_ARRAY, DATA_TYPE.DT_DATEHOUR_ARRAY, DATA_TYPE.DT_UUID_ARRAY, DATA_TYPE.DT_IPADDR_ARRAY, DATA_TYPE.DT_INT128_ARRAY }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); - -// List attributes = new List(); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_BOOL_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_BYTE_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_SHORT_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_INT_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_LONG_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_DOUBLE_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_FLOAT_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_DATE_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_MONTH_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_TIME_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_MINUTE_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_SECOND_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_DATETIME_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_TIMESTAMP_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_NANOTIME_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_NANOTIMESTAMP_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_DATEHOUR_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_UUID_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_IPADDR_ARRAY)); -// attributes.Add(new BasicArrayVector(DATA_TYPE.DT_INT128_ARRAY)); - -// sender.sendEvent("event_all_array_dateType", attributes); -// //conn.run("tableInsert{outputTable}", attributes); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); - -// } -// [TestMethod] -// public void test_EventSender_all_dateType_scalar() -// { -// String script = "share streamTable(1:0, `eventTime`eventType`blobs, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + -// "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippAddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; -// conn.run(script); -// String script1 = "class event_all_dateType{\n" + -// "\tboolv :: BOOL\n" + -// "\tcharv :: CHAR\n" + -// "\tshortv :: SHORT\n" + -// "\tintv :: INT\n" + -// "\tlongv :: LONG\n" + -// "\tdoublev :: DOUBLE \n" + -// "\tfloatv :: FLOAT\n" + -// "\tdatev :: DATE\n" + -// "\tmonthv :: MONTH\n" + -// "\ttimev :: TIME\n" + -// "\tminutev :: MINUTE\n" + -// "\tsecondv :: SECOND\n" + -// "\tdatetimev :: DATETIME \n" + -// "\ttimestampv :: TIMESTAMP\n" + -// "\tnanotimev :: NANOTIME\n" + -// "\tnanotimestampv :: NANOTIMESTAMP\n" + -// // "\tsymbolv :: SYMBOL\n" + -// "\tstringv :: STRING\n" + -// "\tdatehourv :: DATEHOUR\n" + -// "\tuuidv :: UUID\n" + -// "\tippAddrv :: IPAddR \n" + -// "\tint128v :: INT128\n" + -// "\tblobv :: BLOB\n" + -// " def event_all_dateType(bool, char, short, int, long, double, float, date, month, time, minute, second, datetime, timestamp, nanotime, nanotimestamp, string, datehour, uuid, ippAddr, int128, blob){\n" + -// "\tboolv = bool\n" + -// "\tcharv = char\n" + -// "\tshortv = short\n" + -// "\tintv = int\n" + -// "\tlongv = long\n" + -// "\tdoublev = double\n" + -// "\tfloatv = float\n" + -// "\tdatev = date\n" + -// "\tmonthv = month\n" + -// "\ttimev = time\n" + -// "\tminutev = minute\n" + -// "\tsecondv = second\n" + -// "\tdatetimev = datetime\n" + -// "\ttimestampv = timestamp\n" + -// "\tnanotimev = nanotime\n" + -// "\tnanotimestampv = nanotimestamp\n" + -// // "\tsymbolv = symbol\n" + -// "\tstringv = string\n" + -// "\tdatehourv = datehour\n" + -// "\tuuidv = uuid\n" + -// "\tippAddrv = ippAddr\n" + -// "\tint128v = int128\n" + -// "\tblobv = blob\n" + -// " \t}\n" + -// "} \n" + -// "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// "eventType = 'event_all_dateType'\n" + -// "eventKeys = 'boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,stringv,datehourv,uuidv,ippAddrv,int128v,blobv';\n" + -// "typeV = [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE,MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB];\n" + -// "formV = [SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR];\n" + -// "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// "share streamTable(array(TIMESTAMP, 0) as eventTime, array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput;\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput, eventTimeField = \"timestampv\");" + -// "all_data_type1=event_all_dateType(true, 'a', 2h, 2, 22l, 2.1, 2.1f, 2012.12.06, 2012.06M, 12:30:00.008, 12:30m, 12:30:00, 2012.06.12 12:30:00, 2012.06.12 12:30:00.008, 13:30:10.008007006, 2012.06.13 13:30:10.008007006, \"world\", datehour(2012.06.13 13:30:10), uuid(\"9d457e79-1bed-d6c2-3612-b0d31c1881f6\"), ipaddr(\"192.168.1.253\"), int128(\"e1671797c52e15f763380b45e841ec32\"), blob(\"123\"))\n" + -// "appendEvent(inputSerializer, all_data_type1)"; -// conn.run(script1); -// String script2 = "colNames=\"col\"+string(1..22)\n" + -// "colTypes=[BOOL,CHAR,SHORT,INT,LONG,DOUBLE,FLOAT,DATE,MONTH,TIME,MINUTE,SECOND,DATETIME,TIMESTAMP,NANOTIME,NANOTIMESTAMP,STRING,DATEHOUR,UUID,IPADDR,INT128,BLOB]\n" + -// "t=table(1:0,colNames,colTypes)\n" + -// "insert into t values(true, 'a', 2h, 2, 22l, 2.1, 2.1f, 2012.12.06, 2012.06M, 12:30:00.008, 12:30m, 12:30:00, 2012.06.12 12:30:00, 2012.06.12 12:30:00.008, 13:30:10.008007006, 2012.06.13 13:30:10.008007006, \"world\", datehour(2012.06.13 13:30:10), uuid(\"9d457e79-1bed-d6c2-3612-b0d31c1881f6\"), ipaddr(\"192.168.1.253\"), int128(\"e1671797c52e15f763380b45e841ec32\"), blob(\"123\")) ;"; -// conn.run(script2); - -// EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP ,DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "timestampv" }; -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// BasicTable bt = (BasicTable)conn.run("select * from t"); -// for (int i = 0; i < bt.rows(); i++) -// { -// List attributes = new List(); -// for (int j = 0; j < bt.columns(); j++) -// { -// IEntity pt = bt.getColumn(j).get(i); -// attributes.Add(pt); -// } -// sender.sendEvent("event_all_dateType", attributes); - -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(1, bt1.rows()); -// Thread.Sleep(2000); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// Assert.AreEqual(1, bt2.rows()); -// checkData(bt1, bt2); -// } -// } - - -// [TestMethod] -// public void test_EventSender_scaler_BOOL() -// { -// PrepareInputSerializer("BOOL", DATA_TYPE.DT_BOOL); -// String script = "event_dateType1 = event_dateType(true);\n" + -// "event_dateType2 = event_dateType(false);\n" + -// "event_dateType3 = event_dateType(NULL);\n" + -// "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3]);"; -// conn.run(script); -// List attributes1 = new List(); -// attributes1.Add(new BasicBoolean(true)); -// List attributes2 = new List(); -// attributes2.Add(new BasicBoolean(false)); -// List attributes3 = new List(); -// BasicBoolean bb = new BasicBoolean(true); -// bb.setNull(); -// attributes3.Add(bb); -// sender.sendEvent("event_dateType", attributes1); -// sender.sendEvent("event_dateType", attributes2); -// sender.sendEvent("event_dateType", attributes3); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(3, bt1.rows()); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// Assert.AreEqual(3, bt2.rows()); -// checkData(bt1, bt2); - -// } - -// [TestMethod] -// public void test_EventSender_scaler_CHAR() -// { -// PrepareInputSerializer("CHAR", DATA_TYPE.DT_BYTE); -// String script = "event_dateType1 = event_dateType('1');\n" + -// "event_dateType2 = event_dateType('2');\n" + -// "event_dateType3 = event_dateType(NULL);\n" + -// "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3]);"; -// conn.run(script); -// List attributes1 = new List(); -// attributes1.Add(new BasicByte((byte)49)); -// List attributes2 = new List(); -// attributes2.Add(new BasicByte((byte)50)); -// List attributes3 = new List(); -// BasicByte bb = new BasicByte((byte)1); -// bb.setNull(); -// attributes3.Add(bb); -// sender.sendEvent("event_dateType", attributes1); -// sender.sendEvent("event_dateType", attributes2); -// sender.sendEvent("event_dateType", attributes3); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(3, bt1.rows()); -// Thread.Sleep(2000); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// Assert.AreEqual(3, bt2.rows()); -// checkData(bt1, bt2); -// } - -// [TestMethod] -// public void test_EventSender_scaler_INT() -// { -// PrepareInputSerializer("INT", DATA_TYPE.DT_INT); -// String script = "event_dateType1 = event_dateType(-2147483648);\n" + -// "event_dateType2 = event_dateType(2147483647);\n" + -// "event_dateType3 = event_dateType(0);\n" + -// "event_dateType4 = event_dateType(NULL);\n" + -// "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; -// conn.run(script); -// List attributes1 = new List(); -// attributes1.Add(new BasicInt(-2147483648)); -// List attributes2 = new List(); -// attributes2.Add(new BasicInt(2147483647)); -// List attributes3 = new List(); -// attributes3.Add(new BasicInt(0)); -// List attributes4 = new List(); -// BasicInt bb = new BasicInt(1); -// bb.setNull(); -// attributes4.Add(bb); -// sender.sendEvent("event_dateType", attributes1); -// sender.sendEvent("event_dateType", attributes2); -// sender.sendEvent("event_dateType", attributes3); -// sender.sendEvent("event_dateType", attributes4); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(4, bt1.rows()); -// Thread.Sleep(2000); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// Assert.AreEqual(4, bt2.rows()); -// checkData(bt1, bt2); -// } - -// [TestMethod] -// public void test_EventSender_scaler_LONG() -// { -// PrepareInputSerializer("LONG", DATA_TYPE.DT_LONG); -// String script = "event_dateType1 = event_dateType(-9223372036854775808);\n" + -// "event_dateType2 = event_dateType(9223372036854775807);\n" + -// "event_dateType3 = event_dateType(0);\n" + -// "event_dateType4 = event_dateType(NULL);\n" + -// "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; -// conn.run(script); -// List attributes1 = new List(); -// attributes1.Add(new BasicLong(-9223372036854775808l)); -// List attributes2 = new List(); -// attributes2.Add(new BasicLong(9223372036854775807l)); -// List attributes3 = new List(); -// attributes3.Add(new BasicLong(0)); -// List attributes4 = new List(); -// BasicLong bb = new BasicLong(1); -// bb.setNull(); -// attributes4.Add(bb); -// sender.sendEvent("event_dateType", attributes1); -// sender.sendEvent("event_dateType", attributes2); -// sender.sendEvent("event_dateType", attributes3); -// sender.sendEvent("event_dateType", attributes4); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(4, bt1.rows()); -// Thread.Sleep(2000); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// Assert.AreEqual(4, bt2.rows()); -// checkData(bt1, bt2); -// } -// [TestMethod] -// public void test_EventSender_scaler_DOUBLE() -// { -// PrepareInputSerializer("DOUBLE", DATA_TYPE.DT_DOUBLE); -// String script = "event_dateType1 = event_dateType(-922337.2036854775808);\n" + -// "event_dateType2 = event_dateType(92233.72036854775807);\n" + -// "event_dateType3 = event_dateType(0);\n" + -// "event_dateType4 = event_dateType(NULL);\n" + -// "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; -// conn.run(script); -// List attributes1 = new List(); -// attributes1.Add(new BasicDouble(-922337.2036854775808)); -// List attributes2 = new List(); -// attributes2.Add(new BasicDouble(92233.72036854775807)); -// List attributes3 = new List(); -// attributes3.Add(new BasicDouble(0)); -// List attributes4 = new List(); -// BasicDouble bb = new BasicDouble(1); -// bb.setNull(); -// attributes4.Add(bb); -// sender.sendEvent("event_dateType", attributes1); -// sender.sendEvent("event_dateType", attributes2); -// sender.sendEvent("event_dateType", attributes3); -// sender.sendEvent("event_dateType", attributes4); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(4, bt1.rows()); -// Thread.Sleep(2000); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// Assert.AreEqual(4, bt2.rows()); -// checkData(bt1, bt2); -// } - -// [TestMethod] -// public void test_EventSender_scaler_FLOAT() -// { -// PrepareInputSerializer("FLOAT", DATA_TYPE.DT_FLOAT); -// String script = "event_dateType1 = event_dateType(-922337.2036854775808f);\n" + -// "event_dateType2 = event_dateType(92233.72036854775807f);\n" + -// "event_dateType3 = event_dateType(0);\n" + -// "event_dateType4 = event_dateType(NULL);\n" + -// "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; -// conn.run(script); -// List attributes1 = new List(); -// attributes1.Add(new BasicFloat(-922337.2036854775808f)); -// List attributes2 = new List(); -// attributes2.Add(new BasicFloat(92233.72036854775807f)); -// List attributes3 = new List(); -// attributes3.Add(new BasicFloat(0)); -// List attributes4 = new List(); -// BasicFloat bb = new BasicFloat(1); -// bb.setNull(); -// attributes4.Add(bb); -// sender.sendEvent("event_dateType", attributes1); -// sender.sendEvent("event_dateType", attributes2); -// sender.sendEvent("event_dateType", attributes3); -// sender.sendEvent("event_dateType", attributes4); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(4, bt1.rows()); -// Thread.Sleep(2000); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// Assert.AreEqual(4, bt2.rows()); -// checkData(bt1, bt2); -// } -// [TestMethod] -// public void test_EventSender_scaler_UUID() -// { -// PrepareInputSerializer("UUID", DATA_TYPE.DT_UUID); -// String script = "event_dateType1 = event_dateType(uuid(\"00000000-0000-006f-0000-000000000001\"));\n" + -// "event_dateType2 = event_dateType(NULL);\n" + -// "appendEvent(inputSerializer, [event_dateType1, event_dateType2]);"; -// conn.run(script); -// List attributes1 = new List(); -// attributes1.Add(new BasicUuid(111, 1)); -// List attributes2 = new List(); -// BasicUuid bb = new BasicUuid(0, 0); -// bb.setNull(); -// attributes2.Add(bb); -// sender.sendEvent("event_dateType", attributes1); -// sender.sendEvent("event_dateType", attributes2); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(2, bt1.rows()); -// Thread.Sleep(2000); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// Assert.AreEqual(2, bt2.rows()); -// checkData(bt1, bt2); -// } - -// //[TestMethod] -// //public void test_EventSender_scaler_COMPLEX() -// //{ -// // PrepareInputSerializer("COMPLEX", DATA_TYPE.DT_COMPLEX); -// // String script = "event_dateType1 = event_dateType(complex(111, 1));\n" + -// // "event_dateType2 = event_dateType( complex(0, 0));\n" + -// // "event_dateType3 = event_dateType(complex(-0.99, -0.11));\n" + -// // "event_dateType4 = event_dateType(NULL);\n" + -// // "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; -// // conn.run(script); -// // List attributes1 = new List(); -// // attributes1.Add(new BasicComplex(111, 1)); -// // List attributes2 = new List(); -// // attributes2.Add(new BasicComplex(0, 0)); -// // List attributes3 = new List(); -// // attributes3.Add(new BasicComplex(-0.99, -0.11)); -// // List attributes4 = new List(); -// // BasicComplex bb = new BasicComplex(0, 0); -// // bb.setNull(); -// // System.out.println(bb.getString()); -// // attributes4.Add(bb); -// // sender.sendEvent("event_dateType", attributes1); -// // sender.sendEvent("event_dateType", attributes2); -// // sender.sendEvent("event_dateType", attributes3); -// // sender.sendEvent("event_dateType", attributes4); -// // BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// // Assert.AreEqual(4, bt1.rows()); -// // Thread.Sleep(2000); -// // BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// // Assert.AreEqual(4, bt2.rows()); -// // checkData(bt1, bt2); -// //} -// //[TestMethod] -// //public void test_EventSender_scaler_POINT() -// //{ -// // PrepareInputSerializer("POINT", DATA_TYPE.DT_POINT); -// // String script = "event_dateType1 = event_dateType(point(111, 1));\n" + -// // "event_dateType2 = event_dateType( point(0, 0));\n" + -// // "event_dateType3 = event_dateType(point(-0.99, -0.11));\n" + -// // "event_dateType4 = event_dateType(NULL);\n" + -// // "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; -// // conn.run(script); -// // List attributes1 = new List(); -// // attributes1.Add(new BasicPoint(111, 1)); -// // List attributes2 = new List(); -// // attributes2.Add(new BasicPoint(0, 0)); -// // List attributes3 = new List(); -// // attributes3.Add(new BasicPoint(-0.99, -0.11)); -// // List attributes4 = new List(); -// // BasicPoint bb = new BasicPoint(0, 0); -// // bb.setNull(); -// // attributes4.Add(bb); -// // sender.sendEvent("event_dateType", attributes1); -// // sender.sendEvent("event_dateType", attributes2); -// // sender.sendEvent("event_dateType", attributes3); -// // sender.sendEvent("event_dateType", attributes4); -// // BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// // Assert.AreEqual(4, bt1.rows()); -// // Thread.Sleep(2000); -// // BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// // Assert.AreEqual(4, bt2.rows()); -// // checkData(bt1, bt2); -// //} - - - -// [TestMethod] -// public void test_EventSender_all_dateType_scalar_DECIMAL() -// { -// String script = "share streamTable(1:0, `eventType`blobs, [STRING,BLOB]) as inputTable;\n" + -// "share table(100:0, `decimal32v`decimal64v`decimal128v, [DECIMAL32(3), DECIMAL64(8), DECIMAL128(10)]) as outputTable;\n"; -// conn.run(script); -// String script1 = "class event_all_dateType{\n" + -// "\tdecimal32v :: DECIMAL32(3)\n" + -// "\tdecimal64v :: DECIMAL64(8)\n" + -// "\tdecimal128v :: DECIMAL128(10) \n" + -// " def event_all_dateType(decimal32, decimal64, decimal128){\n" + -// "\tdecimal32v = decimal32\n" + -// "\tdecimal64v = decimal64\n" + -// "\tdecimal128v = decimal128\n" + -// " \t}\n" + -// "} \n" + -// "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// "eventType = 'event_all_dateType'\n" + -// "eventKeys = 'decimal32v,decimal64v,decimal128v';\n" + -// "typeV = [ DECIMAL32(3), DECIMAL64(8), DECIMAL128(10)];\n" + -// "formV = [ SCALAR, SCALAR, SCALAR];\n" + -// "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput;\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput);" + -// "all_data_type1=event_all_dateType(decimal32(1.1, 3),decimal64(1.1, 8),decimal128(1.1, 10))\n" + -// "appendEvent(inputSerializer, all_data_type1)"; -// conn.run(script1); -// String script2 = "colNames=\"col\"+string(1..3)\n" + -// "colTypes=[DECIMAL32(3),DECIMAL64(8),DECIMAL128(10)]\n" + -// "t=table(1:0,colNames,colTypes)\n" + -// "insert into t values(decimal32(1.1, 3), decimal64(1.1, 8), decimal128(1.1, 10)) ;"; -// conn.run(script2); - -// EventSchema scheme = new EventSchema("event_all_dateType", new List { "decimal32v", "decimal64v", "decimal128v" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 3, 8, 10 }); - -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); - -// BasicTable bt = (BasicTable)conn.run("select * from t"); -// for (int i = 0; i < bt.rows(); i++) -// { -// List attributes = new List(); -// for (int j = 0; j < bt.columns(); j++) -// { -// IEntity pt = bt.getColumn(j).get(i); -// attributes.Add(pt); -// } -// sender.sendEvent("event_all_dateType", attributes); - -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(1, bt1.rows()); -// Thread.Sleep(2000); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); -// Assert.AreEqual(1, bt2.rows()); -// checkData(bt1, bt2); -// BasicTable bt3 = (BasicTable)conn.run("select * from outputTable;"); -// Assert.AreEqual(1, bt3.rows()); -// Console.WriteLine(bt3.getString()); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } -// } - -// [TestMethod] -// public void test_EventSender_subscribe_all_dateType_scalar_1() -// { -// String script = "share streamTable(1000000:0, `time`eventType`event, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + -// "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippaddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; -// conn.run(script); - -// EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "datetimev" }; -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); - -// Preparedata(1); -// BasicTable bt = (BasicTable)conn.run("select * from data"); -// for (int i = 0; i < bt.rows(); i++) -// { -// List attributes = new List(); -// for (int j = 0; j < bt.columns(); j++) -// { -// IEntity pt = bt.getColumn(j).getEntity(i); -// attributes.Add(pt); -// } -// sender.sendEvent("event_all_dateType", attributes); -// } -// Console.WriteLine(bt.columns()); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(1, bt1.rows()); -// Thread.Sleep(20000); -// BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); -// Assert.AreEqual(1, bt2.rows()); -// checkData(bt, bt2); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } - -// [TestMethod] -// public void test_EventSender_subscribe_all_dateType_scalar_100() -// { -// String script = "share streamTable(1000000:0, `time`eventType`event, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + -// "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippaddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; -// conn.run(script); - -// EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "datetimev" }; -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); - -// Preparedata(100); -// BasicTable bt = (BasicTable)conn.run("select * from data"); -// for (int i = 0; i < bt.rows(); i++) -// { -// List attributes = new List(); -// for (int j = 0; j < bt.columns(); j++) -// { -// IEntity pt = bt.getColumn(j).getEntity(i); -// attributes.Add(pt); -// } -// sender.sendEvent("event_all_dateType", attributes); -// } -// Console.WriteLine(bt.columns()); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(100, bt1.rows()); -// Thread.Sleep(20000); -// BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); -// Assert.AreEqual(100, bt2.rows()); -// checkData(bt, bt2); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } - -// [TestMethod] -// public void test_EventSender_subscribe_all_dateType_scalar_100000() -// { -// String script = "share streamTable(1000000:0, `time`eventType`event, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + -// "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippaddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; -// conn.run(script); - -// EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List() { "datetimev" }; -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); - -// Preparedata(100000); -// BasicTable bt = (BasicTable)conn.run("select * from data"); -// for (int i = 0; i < bt.rows(); i++) -// { -// List attributes = new List(); -// for (int j = 0; j < bt.columns(); j++) -// { -// IEntity pt = bt.getColumn(j).getEntity(i); -// attributes.Add(pt); -// } -// sender.sendEvent("event_all_dateType", attributes); -// } -// Console.WriteLine(bt.columns()); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(100000, bt1.rows()); -// Thread.Sleep(20000); -// BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); -// Assert.AreEqual(100000, bt2.rows()); -// checkData(bt, bt2); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } - -// [TestMethod] -// public void test_EventSender_all_dateType_vector() -// { -// String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + -// "colNames=\"col\"+string(1..20);\n" + -// "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[],DATEHOUR[],UUID[],IPADDR[],INT128[]];\n" + -// "share table(1:0,colNames,colTypes) as outputTable;\n"; -// conn.run(script); -// EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128 }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// Preparedata_array(100, 10); -// BasicTable bt = (BasicTable)conn.run("select * from data"); - -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler_array handler_array = new Handler_array(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler_array, -1, true, "admin", "123456"); - -// for (int i = 0; i < bt.rows(); i++) -// { -// List attributes = new List(); -// for (int j = 0; j < bt.columns(); j++) -// { -// IEntity pt = bt.getColumn(j).getEntity(i); -// Console.WriteLine(pt.getDataType()); -// Console.WriteLine(i + "У " + j + "У" + pt.getString()); -// attributes.Add(pt); -// } -// sender.sendEvent("event_all_array_dateType", attributes); -// } -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(10, bt1.rows()); -// Thread.Sleep(10000); -// BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); -// Assert.AreEqual(10, bt2.rows()); -// checkData(bt, bt2); -// client.unsubscribe(SERVER, PORT, "inputTable", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_decimal_1() -// { -// String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + -// "share table(1:0,[\"col1\"],[DECIMAL32(2)]) as outputTable;\n"; -// conn.run(script); -// String script1 = "class event_decimal{\n" + -// "\tdecimal32v :: DECIMAL32(3) \n" + -// " def event_decimal(decimal32){\n" + -// "\tdecimal32v = decimal32\n" + -// " \t}\n" + -// "} \n" + -// "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// "eventType = 'event_decimal'\n" + -// "eventKeys = 'decimal32v';\n" + -// "typeV = [ DECIMAL32(3)];\n" + -// "formV = [ SCALAR];\n" + -// "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; -// conn.run(script1); - -// EventSchema scheme = new EventSchema("event_decimal", new List { "decimal32v" }, new List { DATA_TYPE.DT_DECIMAL32 }, new List { DATA_FORM.DF_SCALAR }, new List {3 }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// String script2 = "\t event_decimal1=event_decimal( decimal32(2.001,2))\n" + -// "\tappendEvent(inputSerializer, event_decimal1)\n"; -// conn.run(script2); -// List attributes = new List(); -// attributes.Add(new BasicDecimal32( "2.001" , 2)); -// sender.sendEvent("event_decimal", attributes); - -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(1, bt1.rows()); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); -// Assert.AreEqual(1, bt2.rows()); -// checkData(bt1, bt2); -// } - -// [TestMethod] -// public void test_EventClient_vector_decimal_1() -// { -// String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + -// "share table(1:0,[\"col1\"],[DECIMAL32(2)[]]) as outputTable;\n"; -// conn.run(script); -// String script1 = "class event_all_array_dateType{\n" + -// "\tdecimal32v :: DECIMAL32(3) VECTOR\n" + -// " def event_all_array_dateType(decimal32){\n" + -// "\tdecimal32v = decimal32\n" + -// " \t}\n" + -// "} \n" + -// "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// "eventType = 'event_all_array_dateType'\n" + -// "eventKeys = 'decimal32v';\n" + -// "typeV = [ DECIMAL32(2)[]];\n" + -// "formV = [ VECTOR];\n" + -// "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; -// conn.run(script1); - -// EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "decimal32v" }, new List { DATA_TYPE.DT_DECIMAL32 }, new List { DATA_FORM.DF_VECTOR }, new List { 2 }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// String script2 = "\tevent_all_array_dateType1=event_all_array_dateType( decimal32(1 2.001,2))\n" + -// "\tappendEvent(inputSerializer, event_all_array_dateType1)\n"; -// conn.run(script2); -// List attributes = new List(); -// attributes.Add(new BasicDecimal32Vector(new String[] { "1", "2.001" }, 2)); -// sender.sendEvent("event_all_array_dateType", attributes); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(1, bt1.rows()); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); -// Assert.AreEqual(1, bt2.rows()); -// checkData(bt1, bt2); -// } - - -// [TestMethod] -// public void test_EventClient_vector_string() -// { -// String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + -// "share table(1:0,[\"col1\"],[STRING]) as outputTable;\n"; -// conn.run(script); -// String script1 = "class event_string{\n" + -// "\tstringv :: STRING VECTOR\n" + -// " def event_string(string){\n" + -// "\tstringv = string\n" + -// " \t}\n" + -// "} \n" + -// "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// "eventType = 'event_string'\n" + -// "eventKeys = 'stringv';\n" + -// "typeV = [ STRING];\n" + -// "formV = [ VECTOR];\n" + -// "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; -// conn.run(script1); -// EventSchema scheme = new EventSchema("event_string", new List { "stringv" }, new List { DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_VECTOR }, new List { 2 }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "intput1", "test1", handler, -1, true, "admin", "123456"); - -// String script2 = "\tevent_string1=event_string( [\"111\",\"222\",\"\",NULL])\n" + -// "\tappendEvent(inputSerializer, event_string1)\n"; -// conn.run(script2); -// List attributes = new List(); -// attributes.Add(new BasicStringVector(new String[] { "111", "222", "", "" })); -// sender.sendEvent("event_string", attributes); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(1, bt1.rows()); -// Thread.Sleep(2000); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); -// Assert.AreEqual(1, bt2.rows()); -// checkData(bt1, bt2); -// client.unsubscribe(SERVER, PORT, "intput1", "test1"); -// } - -// [TestMethod] -// public void test_EventClient_vector_symbol() -// { -// String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + -// "share table(1:0,[\"col1\"],[STRING]) as outputTable;\n"; -// conn.run(script); -// String script1 = "class event_symbol{\n" + -// "\tsymbolv :: SYMBOL VECTOR\n" + -// " def event_symbol(symbol){\n" + -// "\tsymbolv = symbol\n" + -// " \t}\n" + -// "} \n" + -// "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + -// "eventType = 'event_symbol'\n" + -// "eventKeys = 'symbolv';\n" + -// "typeV = [ SYMBOL];\n" + -// "formV = [ VECTOR];\n" + -// "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + -// "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + -// "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + -// "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; -// conn.run(script1); -// EventSchema scheme = new EventSchema("event_symbol", new List { "symbolv" }, new List { DATA_TYPE.DT_SYMBOL }, new List { DATA_FORM.DF_VECTOR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "intput1", "test1", handler, -1, true, "admin", "123456"); - -// String script2 = "\tevent_symbol1=event_symbol( symbol([\"111\",\"222\",\"\",NULL]))\n" + -// "\tappendEvent(inputSerializer, event_symbol1)\n"; -// conn.run(script2); -// List attributes = new List(); -// attributes.Add(new BasicSymbolVector(new String[] { "111", "222", "", "" })); -// sender.sendEvent("event_symbol", attributes); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(1, bt1.rows()); -// Thread.Sleep(2000); -// BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); -// Assert.AreEqual(1, bt2.rows()); -// checkData(bt1, bt2); -// client.unsubscribe(SERVER, PORT, "intput1", "test1"); -// } - -// [TestMethod] -// public void test_EventSender_all_dateType_array() -// { -// String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n"; -// conn.run(script); -// EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL_ARRAY, DATA_TYPE.DT_BYTE_ARRAY, DATA_TYPE.DT_SHORT_ARRAY, DATA_TYPE.DT_INT_ARRAY, DATA_TYPE.DT_LONG_ARRAY, DATA_TYPE.DT_DOUBLE_ARRAY, DATA_TYPE.DT_FLOAT_ARRAY, DATA_TYPE.DT_DATE_ARRAY, DATA_TYPE.DT_MONTH_ARRAY, DATA_TYPE.DT_TIME_ARRAY, DATA_TYPE.DT_MINUTE_ARRAY, DATA_TYPE.DT_SECOND_ARRAY, DATA_TYPE.DT_DATETIME_ARRAY, DATA_TYPE.DT_TIMESTAMP_ARRAY, DATA_TYPE.DT_NANOTIME_ARRAY, DATA_TYPE.DT_NANOTIMESTAMP_ARRAY, DATA_TYPE.DT_DATEHOUR_ARRAY, DATA_TYPE.DT_UUID_ARRAY, DATA_TYPE.DT_IPADDR_ARRAY, DATA_TYPE.DT_INT128_ARRAY }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); -// List eventSchemas = new List(); -// eventSchemas.Add(scheme); -// List eventTimeFields = new List(); -// List commonFields = new List(); -// EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); - -// client = new EventClient(eventSchemas, eventTimeFields, commonFields); -// Handler handler = new Handler(); -// client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); - -// Preparedata_array(100, 10); -// BasicTable bt = (BasicTable)conn.run("select * from data"); -// List attributes = new List(); -// for (int j = 0; j < bt.columns(); j++) -// { -// IEntity pt = (bt.getColumn(j)); -// Console.WriteLine(pt.getDataType()); -//// Console.WriteLine(j + "У" + pt.getObject().ToString()); -// attributes.Add(pt); -// } -// sender.sendEvent("event_all_array_dateType", attributes); -// BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); -// Assert.AreEqual(1, bt1.rows()); -// } - - -// } -//} +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using dolphindb; +using dolphindb.data; +using dolphindb.streaming; +using dolphindb_config; +using dolphindb.streaming.cep; +using System.Threading; +using System.Text; + +namespace dolphindb_csharp_api_test.cep_test +{ + [TestClass] + public class EventSenderTest + { + + public static DBConnection streamConn; + private string SERVER = MyConfigReader.SERVER; + static private int PORT = MyConfigReader.PORT; + private readonly string USER = MyConfigReader.USER; + private readonly string PASSWORD = MyConfigReader.PASSWORD; + private string LOCALHOST = MyConfigReader.LOCALHOST; + private readonly int LOCALPORT = MyConfigReader.LOCALPORT; + static private int SUB_FLAG = MyConfigReader.SUB_FLAG; + private string NODE1_HOST = MyConfigReader.NODE1_HOST; + private readonly int NODE1_PORT = MyConfigReader.NODE1_PORT; + public static string[] HASTREAM_GROUP = MyConfigReader.HASTREAM_GROUP; + private readonly int HASTREAM_GROUPID = MyConfigReader.HASTREAM_GROUPID; + private readonly int TIMEOUT = 10000; + public static DBConnection conn; + static EventSender sender; + static EventSchema scheme; + static EventClient client; + + public void clear_env() + { + try + { + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT, "admin", "123456"); + conn.run("a = getStreamingStat().pubTables\n" + + "for(i in a){\n" + + "\tstopPublishTable(i.subscriber.split(\":\")[0],int(i.subscriber.split(\":\")[1]),i.tableName,i.actions)\n" + + "}"); + conn.run("def getAllShare(){\n" + + "\treturn select name from objs(true) where shared=1\n" + + "\t}\n" + + "\n" + + "def clearShare(){\n" + + "\tlogin(`admin,`123456)\n" + + "\tallShare=exec name from pnodeRun(getAllShare)\n" + + "\tfor(i in allShare){\n" + + "\t\ttry{\n" + + "\t\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],clearTablePersistence,objByName(i))\n" + + "\t\t\t}catch(ex1){}\n" + + "\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],undef,i,SHARED)\n" + + "\t}\n" + + "\ttry{\n" + + "\t\tPST_DIR=rpc(getControllerAlias(),getDataNodeConfig{getNodeAlias()})['persistenceDir']\n" + + "\t}catch(ex1){}\n" + + "}\n" + + "clearShare()"); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + + [TestInitialize] + public void TestInitialize() + { + conn = new DBConnection(); + conn.connect(SERVER, PORT, "admin", "123456"); + clear_env(); + conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); + } + + [TestCleanup] + public void TestCleanup() + { + conn.close(); + try { client.unsubscribe(SERVER, PORT, "inputTable", "test1"); } catch (Exception ) { } + try { client.unsubscribe(SERVER, PORT, "intput", "test1"); } catch (Exception ) { } + try { client.unsubscribe(SERVER, PORT, "inputTable", "javaStreamingApi"); } catch (Exception ) { } + try { client.unsubscribe(SERVER, PORT, "intput", "javaStreamingApi"); } catch (Exception ) { } + clear_env(); + + } + public void PrepareInputSerializer(String type, DATA_TYPE data_type) + { + String script = "login(`admin, `123456); \n" + + "class event_dateType{\n" + + "\tt_type :: " + type + "\n" + + " def event_dateType(type){\n" + + "\tt_type = type\n" + + " }\n" + + "\t} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_dateType'\n" + + "eventKeys = 't_type';\n" + + "typeV = [" + type + "];\n" + + "formV = [SCALAR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable(array(STRING, 0) as eventType, array(BLOB, 0) as blobs, array(" + type + ", 0) as commonField) as intput;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput, commonField=\"t_type\");\n" + + "share streamTable(1000000:0, `eventType`blobs`commonField, [STRING,BLOB," + type + "]) as inputTable;"; + conn.run(script); + scheme = new EventSchema("event_dateType", new List { "t_type" }, new List { data_type }, new List { DATA_FORM.DF_SCALAR }); + + List eventSchemas = new List { scheme }; + List eventTimeFields = new List(); + List commonFields = new List { "t_type" }; + sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + + public static void Preparedata(long count) + { + String script = "login(`admin, `123456); \n" + + "n=" + count + ";\n" + + "boolv = bool(rand([true, false, NULL], n));\n" + + "charv = char(rand(rand(-100..100, 1000) join take(char(), 4), n));\n" + + "shortv = short(rand(rand(-100..100, 1000) join take(short(), 4), n));\n" + + "intv = int(rand(rand(-100..100, 1000) join take(int(), 4), n));\n" + + "longv = long(rand(rand(-100..100, 1000) join take(long(), 4), n));\n" + + "doublev = double(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n));\n" + + "floatv = float(rand(rand(-100..100, 1000)*0.23 join take(float(), 4), n));\n" + + "datev = date(rand(rand(-100..100, 1000) join take(date(), 4), n));\n" + + "monthv = month(rand(1967.12M+rand(-100..100, 1000) join take(month(), 4), n));\n" + + "timev = time(rand(rand(0..100, 1000) join take(time(), 4), n));\n" + + "minutev = minute(rand(12:13m+rand(-100..100, 1000) join take(minute(), 4), n));\n" + + "secondv = second(rand(12:13:12+rand(-100..100, 1000) join take(second(), 4), n));\n" + + "datetimev = datetime(rand(1969.12.23+rand(-100..100, 1000) join take(datetime(), 4), n));\n" + + "timestampv = timestamp(rand(1970.01.01T00:00:00.023+rand(-100..100, 1000) join take(timestamp(), 4), n));\n" + + "nanotimev = nanotime(rand(12:23:45.452623154+rand(-100..100, 1000) join take(nanotime(), 4), n));\n" + + "nanotimestampv = nanotimestamp(rand(rand(-100..100, 1000) join take(nanotimestamp(), 4), n));\n" + + "symbolv = rand((\"syms\"+string(rand(100, 1000))) join take(string(), 4), n);\n" + + "stringv = rand((\"stringv\"+string(rand(100, 1000))) join take(string(), 4), n);\n" + + "uuidv = rand(rand(uuid(), 1000) join take(uuid(), 4), n);\n" + + "datehourv = datehour(rand(datehour(1969.12.31T12:45:12)+rand(-100..100, 1000) join take(datehour(), 4), n));\n" + + "ippaddrv = rand(rand(ipaddr(), 1000) join take(ipaddr(), 4), n);\n" + + "int128v = rand(rand(int128(), 1000) join take(int128(), 4), n);\n" + + "blobv = blob(string(rand((\"blob\"+string(rand(100, 1000))) join take(\"\", 4), n)));\n" + + "complexv = rand(complex(rand(100, 1000), rand(100, 1000)) join NULL, n);\n" + + "pointv = rand(point(rand(100, 1000), rand(100, 1000)) join NULL, n);\n" + + "decimal32v = decimal32(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 3);\n" + + "decimal64v = decimal64(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 8);\n" + + "decimal128v = decimal128(rand(rand(-100..100, 1000)*0.23 join take(double(), 4), n), 10);\n" + + "share table(boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, stringv, datehourv, uuidv, ippaddrv, int128v, blobv) as data;\n"; + conn.run(script); + } + + public static void Preparedata_array(long count1, long count2) + { + String script1 = "login(`admin, `123456); \n" + + "n=" + count1 + ";\n" + + "m=" + count2 + ";\n" + + "cbool = array(BOOL[]).append!(cut(take([true, false, NULL], n), m))\n" + + "cchar = array(CHAR[]).append!(cut(take(char(-100..100 join NULL), n), m))\n" + + "cshort = array(SHORT[]).append!(cut(take(short(-100..100 join NULL), n), m))\n" + + "cint = array(INT[]).append!(cut(take(-100..100 join NULL, n), m))\n" + + "clong = array(LONG[]).append!(cut(take(long(-100..100 join NULL), n), m))\n" + + "cdouble = array(DOUBLE[]).append!(cut(take(-100..100 join NULL, n) + 0.254, m))\n" + + "cfloat = array(FLOAT[]).append!(cut(take(-100..100 join NULL, n) + 0.254f, m))\n" + + "cdate = array(DATE[]).append!(cut(take(2012.01.01..2012.02.29, n), m))\n" + + "cmonth = array(MONTH[]).append!(cut(take(2012.01M..2013.12M, n), m))\n" + + "ctime = array(TIME[]).append!(cut(take(09:00:00.000 + 0..99 * 1000, n), m))\n" + + "cminute = array(MINUTE[]).append!(cut(take(09:00m..15:59m, n), m))\n" + + "csecond = array(SECOND[]).append!(cut(take(09:00:00 + 0..999, n), m))\n" + + "cdatetime = array(DATETIME[]).append!(cut(take(2012.01.01T09:00:00 + 0..999, n), m))\n" + + "ctimestamp = array(TIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000 + 0..999 * 1000, n), m))\n" + + "cnanotime =array(NANOTIME[]).append!(cut(take(09:00:00.000000000 + 0..999 * 1000000000, n), m))\n" + + "cnanotimestamp = array(NANOTIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000000000 + 0..999 * 1000000000, n), m))\n" + + "cuuid = array(UUID[]).append!(cut(take(uuid([\"5d212a78-cc48-e3b1-4235-b4d91473ee87\", \"5d212a78-cc48-e3b1-4235-b4d91473ee88\", \"5d212a78-cc48-e3b1-4235-b4d91473ee89\", \"\"]), n), m))\n" + + "cdatehour = array(DATEHOUR[]).append!(cut(take(datehour(1..10 join NULL), n), m))\n" + + "cipaddr = array(IPADDR[]).append!(cut(take(ipaddr([\"192.168.100.10\", \"192.168.100.11\", \"192.168.100.14\", \"\"]), n), m))\n" + + "cint128 = array(INT128[]).append!(cut(take(int128([\"e1671797c52e15f763380b45e841ec32\", \"e1671797c52e15f763380b45e841ec33\", \"e1671797c52e15f763380b45e841ec35\", \"\"]), n), m))\n" + + "ccomplex = array( COMPLEX[]).append!(cut(rand(complex(rand(100, 1000), rand(100, 1000)) join NULL, n), m))\n" + + "cpoint = array(POINT[]).append!(cut(rand(point(rand(100, 1000), rand(100, 1000)) join NULL, n), m))\n" + + "cdecimal32 = array(DECIMAL32(2)[]).append!(cut(decimal32(take(-100..100 join NULL, n) + 0.254, 3), m))\n" + + "cdecimal64 = array(DECIMAL64(7)[]).append!(cut(decimal64(take(-100..100 join NULL, n) + 0.25467, 4), m))\n" + + "cdecimal128 = array(DECIMAL128(19)[]).append!(cut(decimal128(take(-100..100 join NULL, n) + 0.25467, 5), m))\n" + + "share table(cbool, cchar, cshort, cint, clong, cdouble, cfloat, cdate, cmonth, ctime, cminute, csecond, cdatetime, ctimestamp, cnanotime, cnanotimestamp, cdatehour, cuuid, cipaddr, cint128) as data;\n"; + conn.run(script1); + } + + public void checkData(BasicTable exception, BasicTable resTable) + { + Assert.AreEqual(exception.rows(), resTable.rows()); + for (int i = 0; i < exception.columns(); i++) + { + Console.Out.WriteLine("col" + resTable.getColumnName(i)); + Assert.AreEqual(exception.getColumn(i).getString(), resTable.getColumn(i).getString()); + } + } + + + class Handler : EventMessageHandler + { + + public void doEvent(String eventType, List attribute) + { + Console.Out.WriteLine("eventType: " + eventType); + for (int i = 0; i < attribute.Count; i++) + { + Console.Out.WriteLine(attribute[i].ToString()); + } + + try + { + conn.run("tableInsert{outputTable}", attribute); + } + catch (Exception e) + { + System.Console.Out.WriteLine(e.ToString()); + } + } + }; + + class Handler_array : EventMessageHandler + { + + public void doEvent(String eventType, List attributes) + { + Console.WriteLine("eventType: " + eventType); + String boolv = attributes[0].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String charv = attributes[1].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String shortv = attributes[2].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String intv = attributes[3].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String longv = attributes[4].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String doublev = attributes[5].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String floatv = attributes[6].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String datev = attributes[7].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String monthv = attributes[8].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String timev = attributes[9].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String minutev = attributes[10].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String secondv = attributes[11].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String datetimev = attributes[12].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String timestampv = attributes[13].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String nanotimev = attributes[14].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String nanotimestampv = attributes[15].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + String datehourv = attributes[16].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); + String uuidv = attributes[17].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); + String ippaddrv = attributes[18].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); + String int128v = attributes[19].getString().Replace("[", "[\"").Replace("]", "\"]").Replace(",", "\",\"").Replace("\"\"", "NULL"); + //String pointv = attributes[20].getString().Replace("(,)", "(NULL,NULL)"); + //pointv = pointv.Substring(1, pointv.Length - 1); + //String[] separators = { "),(" }; + //String[] point1 = pointv.Split(separators, StringSplitOptions.None); + //String point2 = null; + //StringBuilder re1 = new StringBuilder(); + //StringBuilder re2 = new StringBuilder(); + //for (int i = 0; i < point1.Length; i++) + //{ + // point2 = point1[i]; + // String[] dataType3 = point2.Split(','); + // re1.Append(dataType3[0]); + // re1.Append(' '); + // re2.Append(dataType3[1]); + // re2.Append(' '); + //} + //pointv = re1 + "," + re2; + //pointv = pointv.Replace("(", "").Replace(")", ""); + + //String complex1 = attributes[21].getString().Replace(",,", ",NULL+NULL,").Replace("[,", "[NULL+NULL,").Replace(",]", ",NULL+NULL]"); + //complex1 = complex1.Substring(1, complex1.Length - 1); + //String[] complex2 = complex1.Split(','); + //String complex3 = null; + //StringBuilder re11 = new StringBuilder(); + //StringBuilder re21 = new StringBuilder(); + //for (int i = 0; i < complex2.Length; i++) + //{ + // complex3 = complex2[i]; + // String[] complex4 = complex3.Split('+'); + // re11.Append(complex4[0]); + // re11.Append(' '); + // re21.Append(complex4[1]); + // re21.Append(' '); + //} + //complex1 = re11 + "," + re21; + //String complexv = complex1.Replace("i", ""); + + //String decimal32v = attributes[20].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + // String decimal64v = attributes[21].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + //String decimal128v = attributes[22].getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' '); + + for (int i = 0; i < attributes.Count; i++) + { + //attributes[i].getString(); + Console.WriteLine(attributes[i].getString()); + } + String script = null; + //script = String.Format("insert into outputTable values( {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},[datehour({0})],[uuid({0})],[ipaddr({0})],[int128({0})],[point({0})],[complex({0})],{0},{0},{0})", boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, datehourv, uuidv, ippaddrv, int128v, pointv, complexv, decimal32v, decimal64v, decimal128v); + script = String.Format("insert into outputTable values( {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},[datehour({16})],[uuid({17})],[ipaddr({18})],[int128({19})])", boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, datehourv, uuidv, ippaddrv, int128v); + Console.WriteLine(script); + conn.run(script); + } + }; + + class Handler_array_null : EventMessageHandler + { + + public void doEvent(String eventType, List attributes) + { + Console.WriteLine("eventType: " + eventType); + String boolv = attributes[0].getString().Replace("[]", " "); + String charv = attributes[1].getString().Replace("[]", " "); + String shortv = attributes[2].getString().Replace("[]", " "); + String intv = attributes[3].getString().Replace("[]", " "); + String longv = attributes[4].getString().Replace("[]", " "); + String doublev = attributes[5].getString().Replace("[]", " "); + String floatv = attributes[6].getString().Replace("[]", " "); + String datev = attributes[7].getString().Replace("[]", " "); + String monthv = attributes[8].getString().Replace("[]", " "); + String timev = attributes[9].getString().Replace("[]", " "); + String minutev = attributes[10].getString().Replace("[]", " "); + String secondv = attributes[11].getString().Replace("[]", " "); + String datetimev = attributes[12].getString().Replace("[]", " "); + String timestampv = attributes[13].getString().Replace("[]", " "); + String nanotimev = attributes[14].getString().Replace("[]", " "); + String nanotimestampv = attributes[15].getString().Replace("[]", " "); + String datehourv = attributes[16].getString().Replace("[]", " "); + String uuidv = attributes[17].getString().Replace("[]", " "); + String ippaddrv = attributes[18].getString().Replace("[]", " "); + String int128v = attributes[19].getString().Replace("[]", " "); + String decimal32v = attributes[20].getString().Replace("[]", " "); + String decimal64v = attributes[21].getString().Replace("[]", " "); + String decimal128v = attributes[22].getString().Replace("[]", " "); + for (int i = 0; i < attributes.Count; i++) + { + Console.WriteLine(attributes[i].getString()); + } + String script = null; + //script = String.Format("insert into outputTable values( {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},[datehour({0})],[uuid({0})],[ipaddr({0})],[int128({0})],[point({0})],[complex({0})],{0},{0},{0})", boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, datehourv, uuidv, ippaddrv, int128v, pointv, complexv, decimal32v, decimal64v, decimal128v); + script = String.Format("insert into outputTable values( {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22})", boolv, charv, shortv, intv, longv, doublev, floatv, datev, monthv, timev, minutev, secondv, datetimev, timestampv, nanotimev, nanotimestampv, datehourv, uuidv, ippaddrv, int128v, decimal32v, decimal64v, decimal128v); + Console.WriteLine(script); + + conn.run(script); + } + }; + + public void PrepareUser(String userName, String password) + { + DBConnection conn = new DBConnection(); + conn.connect(SERVER, PORT, "admin", "123456"); + conn.run("def create_user(){try{deleteUser(`" + userName + ")}catch(ex){};createUser(`" + userName + ", '" + password + "');};" + + "rpc(getControllerAlias(),create_user);"); + } + + [TestMethod] + public void test_EventSender_EventScheme_null() + { + List eventSchemas = new List(); + List eventTimeFields = new List(); + List commonFields = new List(); + String re = null; + try + { + new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("eventSchemas must not be empty.", re); + } + + [TestMethod] + public void test_EventSender_EventScheme_null_1() + { + List eventTimeFields = new List(); + List commonFields = new List(); + String re = null; + try + { + EventSender sender = new EventSender(conn, "inputTable", null, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("eventSchema must be non-null.", re); + } + + [TestMethod] + public void test_EventSender_EventType_null() + { + String re = null; + try + { + EventSchema scheme = new EventSchema("", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("eventType must be non-empty.", re); + } + + [TestMethod] + public void test_EventSender_EventType_null_1() + { + String re = null; + try + { + EventSchema scheme = new EventSchema(null, new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("eventType must be non-null.", re); + } + + [TestMethod] + public void test_EventSender_EventType_special_character() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n"; + conn.run(script); + EventSchema scheme = new EventSchema("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ", new List { "market" }, new List { DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR }); + List eventSchemas = new List { scheme }; + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + List attributes1 = new List(); + attributes1.Add(new BasicString("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ")); + List attributes2 = new List(); + BasicString bb = new BasicString(""); + bb.setNull(); + attributes2.Add(bb); + sender.sendEvent("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ", attributes1); + sender.sendEvent("!@#$%&*()_+QWERTYUIOP{}[]-=';./,~`1^; ", attributes2); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(2, bt1.rows()); + } + + [TestMethod] + public void test_EventSender_EventType_repetition() + { + EventSchema scheme = new EventSchema("market", new List { "market", "time", "time1", "time2", "time3" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + EventSchema scheme1 = new EventSchema("market", new List { "market", "time0", "time1", "time2", "time3" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + + List eventSchemas = new List(); + eventSchemas.Add(scheme); + eventSchemas.Add(scheme1); + List eventTimeFields = new List() { "market" }; + List commonFields = new List(); + String re = null; + try + { + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("EventType must be unique.", re); + } + + [TestMethod] + public void test_EventSender_fieldNames_null() + { + String re = null; + try + { + EventSchema scheme = new EventSchema("market", null, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("fieldNames must be non-null.", re); + } + + [TestMethod] + public void test_EventSender_fieldNames_null_1() + { + String re = null; + try + { + EventSchema scheme = new EventSchema("market", new List { "", "market", "time3", "time2", "time4" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("the element of fieldNames must be non-empty.", re); + } + + [TestMethod] + public void test_EventSender_fieldName_repetition() + { + conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "time", "time" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "time" }; + List commonFields = new List(); + String re = null; + try + { + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("fieldNames must be unique.", re); + } + + [TestMethod] + public void test_EventSender_fieldName_one_colume() + { + conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "time" }, new List { DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "time" }; + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + List attributes = new List(); + attributes.Add(new BasicTime(1)); + sender.sendEvent("market", attributes); + BasicTable re = (BasicTable)conn.run("select * from inputTable"); + Assert.AreEqual(1, re.rows()); + Assert.AreEqual("00:00:00.001", re.getColumn(0).get(0).getString()); + } + + [TestMethod] + public void test_EventSender_FieldTypes_null() + { + String re = null; + try + { + EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, null, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("fieldTypes must be non-null.", re); + } + + [TestMethod] + public void test_EventSender_FieldForms_null() + { + String re = null; + try + { + EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_VOID, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, null); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("fieldForms must be non-null.", re); + } + + //[TestMethod] + //public void test_EventSender_fieldExtraParams_null() + //{ + // conn.run("share streamTable(1000000:0, `eventType`event`market`code`decimal32`decimal64`decimal128, [STRING,BLOB,STRING,STRING,DECIMAL32(0),DECIMAL64(1),DECIMAL128(2)]) as inputTable;"); + // EventSchema scheme = new EventSchema("market", new List { "market", "code", "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 0, 0, 0, 1, 2 }); + // List eventSchemas = new List(); + // eventSchemas.Add(scheme); + // List eventTimeFields = new List(); + // List commonFields = new List() { "market", "code", "decimal32", "decimal64", "decimal128" }; + + // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + // List attributes = new List(); + // attributes.Add(new BasicString("1")); + // attributes.Add(new BasicString("2")); + // attributes.Add(new BasicDecimal32("2", 0)); + // attributes.Add(new BasicDecimal64("2.88", 1)); + // attributes.Add(new BasicDecimal128("-2.1", 2)); + // String re = null; + // try + // { + // sender.sendEvent("market", attributes); + + // } + // catch (Exception ex) + // { + // re = ex.Message; + // } + // Assert.AreEqual("The decimal attribute' scale doesn't match to schema fieldExtraParams scale.", re); + //} + + //[TestMethod] + //public void test_EventSender_fieldExtraParams_null_1() + //{ + // conn.run("share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;"); + // EventSchema scheme = new EventSchema("market", new List { "market", "code" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR }); + // List eventSchemas = new List(); + // eventSchemas.Add(scheme); + // List eventTimeFields = new List(); + // List commonFields = new List(); + + // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + // List attributes = new List(); + // attributes.Add(new BasicString("1")); + // attributes.Add(new BasicString("2")); + // sender.sendEvent("market", attributes); + // BasicTable re = (BasicTable)conn.run("select * from inputTable"); + // Assert.AreEqual(1, re.rows()); + //} + //[TestMethod] + //public void test_EventSender_fieldExtraParams_not_match() + //{ + // conn.run("share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;"); + // EventSchema scheme = new EventSchema("market", new List { "market", "code" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR }, new List { 1 }); + // List eventSchemas = new List(); + // eventSchemas.Add(scheme); + // List eventTimeFields = new List(); + // List commonFields = new List(); + + // String re = null; + // try + // { + // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + // } + // catch (Exception ex) + // { + // re = ex.Message; + // } + // Assert.AreEqual("the number of eventKey, eventTypes, eventForms and eventExtraParams (if set) must have the same length.", re); + //} + //[TestMethod] + //public void test_EventSender_fieldExtraParams_set_not_true() + //{ + // EventSchema scheme = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 10, 19, 39 }); + // List eventSchemas = new List(); + // eventSchemas.Add(scheme); + // List eventTimeFields = new List(); + // List commonFields = new List() { "market", "code", "decimal32", "decimal64", "decimal128" }; + + // String re = null; + // try + // { + // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL32 scale 10 is out of bounds, it must be in [0,9].", re); + + // EventSchema scheme1 = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 1, 19, 39 }); + // List eventSchemas1 = new List(); + // eventSchemas1.Add(scheme1); + // String re1 = null; + // try + // { + // EventSender sender = new EventSender(conn, "inputTable", eventSchemas1, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re1 = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL64 scale 19 is out of bounds, it must be in [0,18].", re1); + + + // EventSchema scheme2 = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 1, 18, 39 }); + // List eventSchemas2 = new List(); + // eventSchemas2.Add(scheme2); + // String re2 = null; + // try + // { + // EventSender sender = new EventSender(conn, "inputTable", eventSchemas2, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re2 = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL128 scale 39 is out of bounds, it must be in [0,38].", re2); + + // EventSchema scheme3 = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { -1, 10, 10 }); + // List eventSchemas3 = new List(); + // eventSchemas3.Add(scheme3); + // String re3 = null; + // try + // { + // EventSender sender = new EventSender(conn, "inputTable", eventSchemas3, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re3 = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL32 scale -1 is out of bounds, it must be in [0,9].", re3); + + // EventSchema scheme4 = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 1, -1, 0 }); + // List eventSchemas4 = new List(); + // eventSchemas4.Add(scheme4); + // String re4 = null; + // try + // { + // EventSender sender = new EventSender(conn, "inputTable", eventSchemas4, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re4 = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL64 scale -1 is out of bounds, it must be in [0,18].", re4); + + // EventSchema scheme5 = new EventSchema("market", new List { "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 0, 0, -1 }); + // List eventSchemas5 = new List(); + // eventSchemas5.Add(scheme5); + // String re5 = null; + // try + // { + // EventSender sender = new EventSender(conn, "inputTable", eventSchemas5, eventTimeFields, commonFields); + + // } + // catch (Exception ex) + // { + // re5 = ex.Message; + // } + // Assert.AreEqual("DT_DECIMAL128 scale -1 is out of bounds, it must be in [0,38].", re5); + //} + //[TestMethod] + //public void test_EventSender_fieldExtraParams_set_true() + //{ + // conn.run("share streamTable(1000000:0, `eventType`event`market`code`decimal32`decimal64`decimal128, [STRING,BLOB,STRING,STRING,DECIMAL32(0),DECIMAL64(1),DECIMAL128(2)]) as inputTable;"); + // conn.run("share streamTable(1000000:0, `eventType`event`market`code`decimal32`decimal64`decimal128, [STRING,BLOB,STRING,STRING,DECIMAL32(0),DECIMAL64(1),DECIMAL128(2)]) as inputTable;"); + // EventSchema scheme = new EventSchema("market", new List { "market", "code", "decimal32", "decimal64", "decimal128" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_PAIR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 0, 0, 0, 1, 2 }); + // List eventSchemas = new List(); + // eventSchemas.Add(scheme); + // List eventTimeFields = new List(); + // List commonFields = new List() { "market", "code", "decimal32", "decimal64", "decimal128" }; + // EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + // List attributes = new List(); + // attributes.Add(new BasicString("1")); + // attributes.Add(new BasicString("2")); + // attributes.Add(new BasicDecimal32("2", 0)); + // attributes.Add(new BasicDecimal64("2.88", 1)); + // attributes.Add(new BasicDecimal128("-2.1", 2)); + // sender.sendEvent("market", attributes); + // BasicTable re = (BasicTable)conn.run("select * from inputTable"); + // Assert.AreEqual(1, re.rows()); + // Assert.AreEqual("1", re.getColumn(2).get(0).getString()); + // Assert.AreEqual("2", re.getColumn(3).get(0).getString()); + // Assert.AreEqual("2", re.getColumn(4).get(0).getString()); + // Assert.AreEqual("2.9", re.getColumn(5).get(0).getString()); + // Assert.AreEqual("-2.10", re.getColumn(6).get(0).getString()); + //} + + [TestMethod] + public void test_EventSender_eventTimeFields_not_exist() + { + EventSchema scheme = new EventSchema("market", new List { "market", "code", "price", "qty", "eventTime" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_INT, DATA_TYPE.DT_TIMESTAMP }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "datetimev" }; + List commonFields = new List(); + String re = null; + try + { + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Event market doesn't contain eventTimeKey datetimev.", re); + } + [TestMethod] + public void test_EventSender_eventTimeFields_not_time_column() + { + conn.run("share streamTable(1000000:0, `string`eventType`event, [STRING,STRING,BLOB]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "code" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_STRING }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "market" }; + List commonFields = new List(); + String re = null; + try + { + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("The first column of the output table must be temporal if eventTimeKey is specified.", re); + } + + [TestMethod] + public void test_EventSender_eventTimeFields_one_column() + { + conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("market1", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + + + List eventTimeFields = new List() { "time" }; + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + List attributes = new List(); + attributes.Add(new BasicString("123456")); + attributes.Add(new BasicTime(12)); + sender.sendEvent("market", attributes); + + List attributes1 = new List(); + attributes1.Add(new BasicTime(10000)); + attributes1.Add(new BasicTime(123456)); + sender.sendEvent("market1", attributes1); + + BasicTable re = (BasicTable)conn.run("select * from inputTable"); + Assert.AreEqual(2, re.rows()); + Assert.AreEqual("00:00:00.012", re.getColumn(0).get(0).getString()); + Assert.AreEqual("00:00:10.000", re.getColumn(0).get(1).getString()); + } + + [TestMethod] + public void test_EventSender_eventTimeFields_one_column_1() + { + conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("market", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + List eventTimeFields = new List() { "time1" }; + List commonFields = new List(); + String re = null; + try + { + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Event market doesn't contain eventTimeKey time1.", re); + } + + [TestMethod] + public void test_EventSender_eventTimeFields_two_column() + { + conn.run("share streamTable(1000000:0, `time`eventType`event, [TIME,STRING,BLOB]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("market1", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + + List eventTimeFields = new List() { "time", "time1" }; + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + List attributes = new List(); + attributes.Add(new BasicString("123456")); + attributes.Add(new BasicTime(12)); + sender.sendEvent("market", attributes); + + List attributes1 = new List(); + attributes1.Add(new BasicTime(10000)); + attributes1.Add(new BasicTime(123456)); + sender.sendEvent("market1", attributes1); + + BasicTable re = (BasicTable)conn.run("select * from inputTable"); + Assert.AreEqual(2, re.rows()); + Assert.AreEqual("00:00:00.012", re.getColumn(0).get(0).getString()); + Assert.AreEqual("00:02:03.456", re.getColumn(0).get(1).getString()); + } + + [TestMethod] + public void test_EventSender_commonFields_not_exist() + { + conn.run("share streamTable(1000000:0, `time`eventType`event`comment, [TIME,STRING,BLOB,TIME]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("market1", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + + List eventTimeFields = new List() { "time", "time1" }; + List commonFields = new List() { "time123" }; + String re = null; + try + { + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Event market doesn't contain commonField time123.", re); + } + + [TestMethod] + public void test_EventSender_commonFields_one_column() + { + conn.run("share streamTable(1000000:0, `time`eventType`event`comment, [TIME,STRING,BLOB,TIME]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("market1", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + + List eventTimeFields = new List() { "time", "time1" }; + List commonFields = new List() { "time" }; + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + List attributes = new List(); + attributes.Add(new BasicString("123456")); + attributes.Add(new BasicTime(12)); + sender.sendEvent("market", attributes); + + List attributes1 = new List(); + attributes1.Add(new BasicTime(10000)); + attributes1.Add(new BasicTime(123456)); + sender.sendEvent("market1", attributes1); + + BasicTable re = (BasicTable)conn.run("select * from inputTable"); + Assert.AreEqual(2, re.rows()); + Assert.AreEqual("00:00:00.012", re.getColumn(0).get(0).getString()); + Assert.AreEqual("00:02:03.456", re.getColumn(0).get(1).getString()); + Assert.AreEqual("00:00:00.012", re.getColumn(3).get(0).getString()); + Assert.AreEqual("00:00:10.000", re.getColumn(3).get(1).getString()); + } + + [TestMethod] + public void test_EventSender_commonFields_one_column_1() + { + conn.run("share streamTable(1000000:0, `time`eventType`event`comment, [TIME,STRING,BLOB,TIME]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("market1", new List { "time", "time1" }, new List { DATA_TYPE.DT_TIME, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + + List eventTimeFields = new List() { "time", "time1" }; + List commonFields = new List() { "time1" }; + String re = null; + try + { + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Event market doesn't contain commonField time1.", re); + } + + [TestMethod] + public void test_EventSender_commonFields_two_column() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + EventSchema scheme1 = new EventSchema("market1", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + eventSchemas.Add(scheme1); + + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + List attributes = new List(); + attributes.Add(new BasicString("1234567")); + attributes.Add(new BasicTime(12)); + sender.sendEvent("market", attributes); + + List attributes1 = new List(); + attributes1.Add(new BasicString("tesrtrrr")); + attributes1.Add(new BasicTime(123456)); + sender.sendEvent("market1", attributes1); ; + + BasicTable re = (BasicTable)conn.run("select * from inputTable"); + Assert.AreEqual(2, re.rows()); + Assert.AreEqual("00:00:00.012", re.getColumn(2).get(0).getString()); + Assert.AreEqual("00:02:03.456", re.getColumn(2).get(1).getString()); + Assert.AreEqual("1234567", re.getColumn(3).get(0).getString()); + Assert.AreEqual("tesrtrrr", re.getColumn(3).get(1).getString()); + } + + [TestMethod] + public void test_EventSender_connect_not_connect() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + DBConnection conn1 = new DBConnection(); + String re = null; + try + { + EventSender sender = new EventSender(conn1, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Database connection is not established yet.", re); + } + + [TestMethod] + public void test_EventSender_connect_duplicated() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + EventSender sender1 = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + } + + [TestMethod] + public void test_EventSender_conn_ssl_true() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + DBConnection conn1 = new DBConnection(false, true); + conn1.connect(SERVER, PORT); + EventSender sender = new EventSender(conn1, "inputTable", eventSchemas, eventTimeFields, commonFields); + List attributes1 = new List(); + attributes1.Add(new BasicString("tesrtrrr")); + attributes1.Add(new BasicTime(1)); + sender.sendEvent("market", attributes1); + + BasicTable re = (BasicTable)conn.run("select * from inputTable"); + Assert.AreEqual(1, re.rows()); + Assert.AreEqual("00:00:00.001", re.getColumn(2).get(0).getString()); + Assert.AreEqual("tesrtrrr", re.getColumn(3).get(0).getString()); + } + [TestMethod] + public void test_EventSender_conn_compress_true() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + DBConnection conn1 = new DBConnection(false, true, true); + conn1.connect(SERVER, PORT); + EventSender sender = new EventSender(conn1, "inputTable", eventSchemas, eventTimeFields, commonFields); + + List attributes1 = new List(); + attributes1.Add(new BasicString("tesrtrrr")); + attributes1.Add(new BasicTime(1)); + sender.sendEvent("market", attributes1); + + BasicTable re = (BasicTable)conn.run("select * from inputTable"); + Assert.AreEqual(1, re.rows()); + Assert.AreEqual("00:00:00.001", re.getColumn(2).get(0).getString()); + Assert.AreEqual("tesrtrrr", re.getColumn(3).get(0).getString()); + } + [TestMethod] + public void test_EventSender_conn_not_admin() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + PrepareUser("user1", "123456"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + DBConnection conn1 = new DBConnection(false, true, true); + conn1.connect(SERVER, PORT, "user1", "123456"); + EventSender sender = new EventSender(conn1, "inputTable", eventSchemas, eventTimeFields, commonFields); + + List attributes1 = new List(); + attributes1.Add(new BasicString("tesrtrrr")); + attributes1.Add(new BasicTime(1)); + sender.sendEvent("market", attributes1); + + BasicTable re = (BasicTable)conn1.run("select * from inputTable"); + Assert.AreEqual(1, re.rows()); + Assert.AreEqual("00:00:00.001", re.getColumn(2).get(0).getString()); + Assert.AreEqual("tesrtrrr", re.getColumn(3).get(0).getString()); + } + + [TestMethod] + public void test_EventSender_connect_tableName_not_exist() + { + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + String re = null; + try + { + EventSender sender = new EventSender(conn, "inputTable11", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual(true, re.Contains("Can't find the object with name inputTable11")); + } + + [TestMethod] + public void test_EventSender_connect_tableName_null() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + String re = null; + try + { + EventSender sender = new EventSender(conn, null, eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual(true, re.Contains("tableName must be non-null.")); + String re1 = null; + try + { + EventSender sender1 = new EventSender(conn, "", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re1 = ex.Message; + } + Assert.AreEqual(true, re1.Contains("tableName must not be empty.")); + } + + [TestMethod] + public void test_EventSender_connect_table_cloumn_not_match() + { + String script = "share streamTable(1000000:0, `time`eventType`event, [TIMESTAMP,STRING,BLOB]) as inputTable1;\n"; + conn.run(script); + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippaddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + String re = null; + try + { + EventSender sender = new EventSender(conn, "inputTable1", eventSchemas, eventTimeFields, commonFields); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Incompatible table columnns for table inputTable1, expected: 2, got: 3.", re); + } + + [TestMethod] + public void test_EventSender_sendEvent_eventType_not_exist() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + List attributes1 = new List(); + attributes1.Add(new BasicString("tesrtrrr")); + attributes1.Add(new BasicTime(1)); + String re = null; + try + { + sender.sendEvent("market111", attributes1); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("unknown eventType market111.", re); + } + [TestMethod] + public void test_EventSender_sendEvent_eventType_null() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + List attributes1 = new List(); + attributes1.Add(new BasicString("tesrtrrr")); + attributes1.Add(new BasicTime(1)); + String re = null; + try + { + sender.sendEvent(null, attributes1); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("eventType must be non-null.", re); + String re1 = null; + try + { + sender.sendEvent("", attributes1); + } + catch (Exception ex) + { + re1 = ex.Message; + } + Assert.AreEqual("unknown eventType .", re1); + } + + [TestMethod] + public void test_EventSender_sendEvent_attributes_column_not_match() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + List attributes1 = new List(); + attributes1.Add(new BasicString("tesrtrrr")); + // attributes1.Add(new BasicTime(1)); + String re = null; + try + { + sender.sendEvent("market", attributes1); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("the number of event values does not match.", re); + } + [TestMethod] + public void test_EventSender_sendEvent_attributes_type_not_match() + { + conn.run("share streamTable(1000000:0, `eventType`event`comment1`comment2, [STRING,BLOB,TIME,STRING]) as inputTable;"); + EventSchema scheme = new EventSchema("market", new List { "market", "time" }, new List { DATA_TYPE.DT_STRING, DATA_TYPE.DT_TIME }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List() { "time", "market" }; + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + List attributes1 = new List(); + attributes1.Add(new BasicString("tesrtrrr")); + attributes1.Add(new BasicInt(1)); + String re = null; + try + { + sender.sendEvent("market", attributes1); + } + catch (Exception ex) + { + re = ex.Message; + } + Assert.AreEqual("Expected type for the field time of market : TIME, but now it is INT.", re); + } + + [TestMethod] + public void test_EventSender_sendEvent_attributes_null() + { + String script = "share streamTable(1000000:0, `time`eventType`event, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + + "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`symbolv`stringv`datehourv`uuidv`ippAddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, SYMBOL,STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; + conn.run(script); + EventSchema scheme = new EventSchema("event_all_dateType_null", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "symbolv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_SYMBOL, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "datetimev" }; + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + List attributes = new List(); + BasicBoolean boolv = new BasicBoolean(true); + //boolv.setNull(); + BasicByte charv = new BasicByte((byte)1); + charv.setNull(); + BasicShort shortv = new BasicShort((short)1); + shortv.setNull(); + BasicInt intv = new BasicInt(0); + intv.setNull(); + BasicLong longv = new BasicLong(0); + longv.setNull(); + BasicDouble doublev = new BasicDouble(0); + doublev.setNull(); + BasicFloat floatv = new BasicFloat(0); + floatv.setNull(); + BasicDate datev = new BasicDate(0); + datev.setNull(); + BasicMonth monthv = new BasicMonth(0); + monthv.setNull(); + BasicTime timev = new BasicTime(0); + timev.setNull(); + BasicMinute minutev = new BasicMinute(0); + minutev.setNull(); + BasicSecond secondv = new BasicSecond(0); + secondv.setNull(); + BasicDateTime datetimev = new BasicDateTime(0); + datetimev.setNull(); + BasicTimestamp timestampv = new BasicTimestamp(0); + timestampv.setNull(); + BasicNanoTime nanotimev = new BasicNanoTime(0); + nanotimev.setNull(); + BasicNanoTimestamp nanotimestampv = new BasicNanoTimestamp(0); + nanotimestampv.setNull(); + BasicString symbolv = new BasicString("0"); + symbolv.setNull(); + BasicString stringv = new BasicString("0"); + stringv.setNull(); + BasicUuid uuidv = new BasicUuid(1, 1); + uuidv.setNull(); + BasicDateHour datehourv = new BasicDateHour(0); + datehourv.setNull(); + BasicIPAddr ippAddrv = new BasicIPAddr(1, 1); + ippAddrv.setNull(); + BasicInt128 int128v = new BasicInt128(1, 1); + int128v.setNull(); + BasicString blobv = new BasicString("= new String[0],true", true); + blobv.setNull(); + attributes.Add(boolv); + attributes.Add(charv); + attributes.Add(shortv); + attributes.Add(intv); + attributes.Add(longv); + attributes.Add(doublev); + attributes.Add(floatv); + attributes.Add(datev); + attributes.Add(monthv); + attributes.Add(timev); + attributes.Add(minutev); + attributes.Add(secondv); + attributes.Add(datetimev); + attributes.Add(timestampv); + attributes.Add(nanotimev); + attributes.Add(nanotimestampv); + attributes.Add(symbolv); + attributes.Add(stringv); + attributes.Add(datehourv); + attributes.Add(uuidv); + attributes.Add(ippAddrv); + attributes.Add(int128v); + attributes.Add(blobv); + sender.sendEvent("event_all_dateType_null", attributes); + //conn.run("tableInsert{outputTable}", attributes); + Thread.Sleep(2000); + BasicTable re = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(1, re.rows()); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + + [TestMethod] + public void test_EventClient_subscribe_attributes_vector_null() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "colNames=\"col\"+string(1..23);\n" + + "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[],DATEHOUR[],UUID[],IPADDR[],INT128[],DECIMAL32(2)[],DECIMAL64(7)[],DECIMAL128(10)[]];\n" + + "share table(1:0,colNames,colTypes) as outputTable;\n"; + conn.run(script); + BasicTable re1111 = (BasicTable)conn.run("select * from outputTable;"); + + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v", "decimal32v", "decimal64v", "decimal128v" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR },new List { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 7, 10}); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler_array_null handler_array_null = new Handler_array_null(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler_array_null, -1, true, "admin", "123456"); + + List attributes = new List(); ; + attributes.Add(new BasicBooleanVector(0)); + attributes.Add(new BasicByteVector(0)); + attributes.Add(new BasicShortVector(0)); + attributes.Add(new BasicIntVector(0)); + attributes.Add(new BasicLongVector(0)); + attributes.Add(new BasicDoubleVector(0)); + attributes.Add(new BasicFloatVector(0)); + attributes.Add(new BasicDateVector(0)); + attributes.Add(new BasicMonthVector(0)); + attributes.Add(new BasicTimeVector(0)); + attributes.Add(new BasicMinuteVector(0)); + attributes.Add(new BasicSecondVector(0)); + attributes.Add(new BasicDateTimeVector(0)); + attributes.Add(new BasicTimestampVector(0)); + attributes.Add(new BasicNanoTimeVector(0)); + attributes.Add(new BasicNanoTimestampVector(0)); + attributes.Add(new BasicDateHourVector(0)); + attributes.Add(new BasicUuidVector(0)); + attributes.Add(new BasicIPAddrVector(0)); + attributes.Add(new BasicInt128Vector(0)); + attributes.Add(new BasicDecimal32Vector(0,2)); + attributes.Add(new BasicDecimal64Vector(0,7)); + attributes.Add(new BasicDecimal128Vector(0,10)); + sender.sendEvent("event_all_array_dateType", attributes); + //conn.run("tableInsert{outputTable}", attributes); + Thread.Sleep(2000); + BasicTable re = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, re.rows()); + BasicTable re1 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(1, re1.rows()); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + [TestMethod] + public void test_EventClient_subscribe_attributes_array_null() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "colNames=\"col\"+string(1..24);\n" + + "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[],DATEHOUR[],UUID[],IPADDR[],INT128[],POINT[],COMPLEX[],DECIMAL32(2)[],DECIMAL64(7)[]];\n" + + "share table(1:0,colNames,colTypes) as outputTable;\n"; + conn.run(script); + + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL_ARRAY, DATA_TYPE.DT_BYTE_ARRAY, DATA_TYPE.DT_SHORT_ARRAY, DATA_TYPE.DT_INT_ARRAY, DATA_TYPE.DT_LONG_ARRAY, DATA_TYPE.DT_DOUBLE_ARRAY, DATA_TYPE.DT_FLOAT_ARRAY, DATA_TYPE.DT_DATE_ARRAY, DATA_TYPE.DT_MONTH_ARRAY, DATA_TYPE.DT_TIME_ARRAY, DATA_TYPE.DT_MINUTE_ARRAY, DATA_TYPE.DT_SECOND_ARRAY, DATA_TYPE.DT_DATETIME_ARRAY, DATA_TYPE.DT_TIMESTAMP_ARRAY, DATA_TYPE.DT_NANOTIME_ARRAY, DATA_TYPE.DT_NANOTIMESTAMP_ARRAY, DATA_TYPE.DT_DATEHOUR_ARRAY, DATA_TYPE.DT_UUID_ARRAY, DATA_TYPE.DT_IPADDR_ARRAY, DATA_TYPE.DT_INT128_ARRAY }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + + List attributes = new List(); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_BOOL_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_BYTE_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_SHORT_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_INT_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_LONG_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_DOUBLE_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_FLOAT_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_DATE_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_MONTH_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_TIME_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_MINUTE_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_SECOND_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_DATETIME_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_TIMESTAMP_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_NANOTIME_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_NANOTIMESTAMP_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_DATEHOUR_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_UUID_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_IPADDR_ARRAY)); + attributes.Add(new BasicArrayVector(DATA_TYPE.DT_INT128_ARRAY)); + + sender.sendEvent("event_all_array_dateType", attributes); + //conn.run("tableInsert{outputTable}", attributes); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + + } + [TestMethod] + public void test_EventSender_all_dateType_scalar() + { + String script = "share streamTable(1:0, `eventTime`eventType`blobs, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + + "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippAddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; + conn.run(script); + String script1 = "class event_all_dateType{\n" + + "\tboolv :: BOOL\n" + + "\tcharv :: CHAR\n" + + "\tshortv :: SHORT\n" + + "\tintv :: INT\n" + + "\tlongv :: LONG\n" + + "\tdoublev :: DOUBLE \n" + + "\tfloatv :: FLOAT\n" + + "\tdatev :: DATE\n" + + "\tmonthv :: MONTH\n" + + "\ttimev :: TIME\n" + + "\tminutev :: MINUTE\n" + + "\tsecondv :: SECOND\n" + + "\tdatetimev :: DATETIME \n" + + "\ttimestampv :: TIMESTAMP\n" + + "\tnanotimev :: NANOTIME\n" + + "\tnanotimestampv :: NANOTIMESTAMP\n" + + // "\tsymbolv :: SYMBOL\n" + + "\tstringv :: STRING\n" + + "\tdatehourv :: DATEHOUR\n" + + "\tuuidv :: UUID\n" + + "\tippAddrv :: IPAddR \n" + + "\tint128v :: INT128\n" + + "\tblobv :: BLOB\n" + + " def event_all_dateType(bool, char, short, int, long, double, float, date, month, time, minute, second, datetime, timestamp, nanotime, nanotimestamp, string, datehour, uuid, ippAddr, int128, blob){\n" + + "\tboolv = bool\n" + + "\tcharv = char\n" + + "\tshortv = short\n" + + "\tintv = int\n" + + "\tlongv = long\n" + + "\tdoublev = double\n" + + "\tfloatv = float\n" + + "\tdatev = date\n" + + "\tmonthv = month\n" + + "\ttimev = time\n" + + "\tminutev = minute\n" + + "\tsecondv = second\n" + + "\tdatetimev = datetime\n" + + "\ttimestampv = timestamp\n" + + "\tnanotimev = nanotime\n" + + "\tnanotimestampv = nanotimestamp\n" + + // "\tsymbolv = symbol\n" + + "\tstringv = string\n" + + "\tdatehourv = datehour\n" + + "\tuuidv = uuid\n" + + "\tippAddrv = ippAddr\n" + + "\tint128v = int128\n" + + "\tblobv = blob\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_all_dateType'\n" + + "eventKeys = 'boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,stringv,datehourv,uuidv,ippAddrv,int128v,blobv';\n" + + "typeV = [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE,MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB];\n" + + "formV = [SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR, SCALAR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable(array(TIMESTAMP, 0) as eventTime, array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput, eventTimeField = \"timestampv\");" + + "all_data_type1=event_all_dateType(true, 'a', 2h, 2, 22l, 2.1, 2.1f, 2012.12.06, 2012.06M, 12:30:00.008, 12:30m, 12:30:00, 2012.06.12 12:30:00, 2012.06.12 12:30:00.008, 13:30:10.008007006, 2012.06.13 13:30:10.008007006, \"world\", datehour(2012.06.13 13:30:10), uuid(\"9d457e79-1bed-d6c2-3612-b0d31c1881f6\"), ipaddr(\"192.168.1.253\"), int128(\"e1671797c52e15f763380b45e841ec32\"), blob(\"123\"))\n" + + "appendEvent(inputSerializer, all_data_type1)"; + conn.run(script1); + String script2 = "colNames=\"col\"+string(1..22)\n" + + "colTypes=[BOOL,CHAR,SHORT,INT,LONG,DOUBLE,FLOAT,DATE,MONTH,TIME,MINUTE,SECOND,DATETIME,TIMESTAMP,NANOTIME,NANOTIMESTAMP,STRING,DATEHOUR,UUID,IPADDR,INT128,BLOB]\n" + + "t=table(1:0,colNames,colTypes)\n" + + "insert into t values(true, 'a', 2h, 2, 22l, 2.1, 2.1f, 2012.12.06, 2012.06M, 12:30:00.008, 12:30m, 12:30:00, 2012.06.12 12:30:00, 2012.06.12 12:30:00.008, 13:30:10.008007006, 2012.06.13 13:30:10.008007006, \"world\", datehour(2012.06.13 13:30:10), uuid(\"9d457e79-1bed-d6c2-3612-b0d31c1881f6\"), ipaddr(\"192.168.1.253\"), int128(\"e1671797c52e15f763380b45e841ec32\"), blob(\"123\")) ;"; + conn.run(script2); + + EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "timestampv" }; + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + BasicTable bt = (BasicTable)conn.run("select * from t"); + for (int i = 0; i < bt.rows(); i++) + { + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = bt.getColumn(j).get(i); + attributes.Add(pt); + } + sender.sendEvent("event_all_dateType", attributes); + + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + Thread.Sleep(2000); + BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + Assert.AreEqual(1, bt2.rows()); + checkData(bt1, bt2); + } + } + + + [TestMethod] + public void test_EventSender_scaler_BOOL() + { + PrepareInputSerializer("BOOL", DATA_TYPE.DT_BOOL); + String script = "event_dateType1 = event_dateType(true);\n" + + "event_dateType2 = event_dateType(false);\n" + + "event_dateType3 = event_dateType(NULL);\n" + + "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3]);"; + conn.run(script); + List attributes1 = new List(); + attributes1.Add(new BasicBoolean(true)); + List attributes2 = new List(); + attributes2.Add(new BasicBoolean(false)); + List attributes3 = new List(); + BasicBoolean bb = new BasicBoolean(true); + bb.setNull(); + attributes3.Add(bb); + sender.sendEvent("event_dateType", attributes1); + sender.sendEvent("event_dateType", attributes2); + sender.sendEvent("event_dateType", attributes3); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(3, bt1.rows()); + BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + Assert.AreEqual(3, bt2.rows()); + checkData(bt1, bt2); + + } + + [TestMethod] + public void test_EventSender_scaler_CHAR() + { + PrepareInputSerializer("CHAR", DATA_TYPE.DT_BYTE); + String script = "event_dateType1 = event_dateType('1');\n" + + "event_dateType2 = event_dateType('2');\n" + + "event_dateType3 = event_dateType(NULL);\n" + + "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3]);"; + conn.run(script); + List attributes1 = new List(); + attributes1.Add(new BasicByte((byte)49)); + List attributes2 = new List(); + attributes2.Add(new BasicByte((byte)50)); + List attributes3 = new List(); + BasicByte bb = new BasicByte((byte)1); + bb.setNull(); + attributes3.Add(bb); + sender.sendEvent("event_dateType", attributes1); + sender.sendEvent("event_dateType", attributes2); + sender.sendEvent("event_dateType", attributes3); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(3, bt1.rows()); + Thread.Sleep(2000); + BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + Assert.AreEqual(3, bt2.rows()); + checkData(bt1, bt2); + } + + [TestMethod] + public void test_EventSender_scaler_INT() + { + PrepareInputSerializer("INT", DATA_TYPE.DT_INT); + String script = "event_dateType1 = event_dateType(-2147483648);\n" + + "event_dateType2 = event_dateType(2147483647);\n" + + "event_dateType3 = event_dateType(0);\n" + + "event_dateType4 = event_dateType(NULL);\n" + + "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; + conn.run(script); + List attributes1 = new List(); + attributes1.Add(new BasicInt(-2147483648)); + List attributes2 = new List(); + attributes2.Add(new BasicInt(2147483647)); + List attributes3 = new List(); + attributes3.Add(new BasicInt(0)); + List attributes4 = new List(); + BasicInt bb = new BasicInt(1); + bb.setNull(); + attributes4.Add(bb); + sender.sendEvent("event_dateType", attributes1); + sender.sendEvent("event_dateType", attributes2); + sender.sendEvent("event_dateType", attributes3); + sender.sendEvent("event_dateType", attributes4); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(4, bt1.rows()); + Thread.Sleep(2000); + BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + Assert.AreEqual(4, bt2.rows()); + checkData(bt1, bt2); + } + + [TestMethod] + public void test_EventSender_scaler_LONG() + { + PrepareInputSerializer("LONG", DATA_TYPE.DT_LONG); + String script = "event_dateType1 = event_dateType(-9223372036854775808);\n" + + "event_dateType2 = event_dateType(9223372036854775807);\n" + + "event_dateType3 = event_dateType(0);\n" + + "event_dateType4 = event_dateType(NULL);\n" + + "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; + conn.run(script); + List attributes1 = new List(); + attributes1.Add(new BasicLong(-9223372036854775808L)); + List attributes2 = new List(); + attributes2.Add(new BasicLong(9223372036854775807L)); + List attributes3 = new List(); + attributes3.Add(new BasicLong(0)); + List attributes4 = new List(); + BasicLong bb = new BasicLong(1); + bb.setNull(); + attributes4.Add(bb); + sender.sendEvent("event_dateType", attributes1); + sender.sendEvent("event_dateType", attributes2); + sender.sendEvent("event_dateType", attributes3); + sender.sendEvent("event_dateType", attributes4); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(4, bt1.rows()); + Thread.Sleep(2000); + BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + Assert.AreEqual(4, bt2.rows()); + checkData(bt1, bt2); + } + [TestMethod] + public void test_EventSender_scaler_DOUBLE() + { + PrepareInputSerializer("DOUBLE", DATA_TYPE.DT_DOUBLE); + String script = "event_dateType1 = event_dateType(-922337.2036854775808);\n" + + "event_dateType2 = event_dateType(92233.72036854775807);\n" + + "event_dateType3 = event_dateType(0);\n" + + "event_dateType4 = event_dateType(NULL);\n" + + "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; + conn.run(script); + List attributes1 = new List(); + attributes1.Add(new BasicDouble(-922337.2036854775808)); + List attributes2 = new List(); + attributes2.Add(new BasicDouble(92233.72036854775807)); + List attributes3 = new List(); + attributes3.Add(new BasicDouble(0)); + List attributes4 = new List(); + BasicDouble bb = new BasicDouble(1); + bb.setNull(); + attributes4.Add(bb); + sender.sendEvent("event_dateType", attributes1); + sender.sendEvent("event_dateType", attributes2); + sender.sendEvent("event_dateType", attributes3); + sender.sendEvent("event_dateType", attributes4); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(4, bt1.rows()); + Thread.Sleep(2000); + BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + Assert.AreEqual(4, bt2.rows()); + checkData(bt1, bt2); + } + + [TestMethod] + public void test_EventSender_scaler_FLOAT() + { + PrepareInputSerializer("FLOAT", DATA_TYPE.DT_FLOAT); + String script = "event_dateType1 = event_dateType(-922337.2036854775808f);\n" + + "event_dateType2 = event_dateType(92233.72036854775807f);\n" + + "event_dateType3 = event_dateType(0);\n" + + "event_dateType4 = event_dateType(NULL);\n" + + "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; + conn.run(script); + List attributes1 = new List(); + attributes1.Add(new BasicFloat(-922337.2036854775808f)); + List attributes2 = new List(); + attributes2.Add(new BasicFloat(92233.72036854775807f)); + List attributes3 = new List(); + attributes3.Add(new BasicFloat(0)); + List attributes4 = new List(); + BasicFloat bb = new BasicFloat(1); + bb.setNull(); + attributes4.Add(bb); + sender.sendEvent("event_dateType", attributes1); + sender.sendEvent("event_dateType", attributes2); + sender.sendEvent("event_dateType", attributes3); + sender.sendEvent("event_dateType", attributes4); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(4, bt1.rows()); + Thread.Sleep(2000); + BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + Assert.AreEqual(4, bt2.rows()); + checkData(bt1, bt2); + } + [TestMethod] + public void test_EventSender_scaler_UUID() + { + PrepareInputSerializer("UUID", DATA_TYPE.DT_UUID); + String script = "event_dateType1 = event_dateType(uuid(\"00000000-0000-006f-0000-000000000001\"));\n" + + "event_dateType2 = event_dateType(NULL);\n" + + "appendEvent(inputSerializer, [event_dateType1, event_dateType2]);"; + conn.run(script); + List attributes1 = new List(); + attributes1.Add(new BasicUuid(111, 1)); + List attributes2 = new List(); + BasicUuid bb = new BasicUuid(0, 0); + bb.setNull(); + attributes2.Add(bb); + sender.sendEvent("event_dateType", attributes1); + sender.sendEvent("event_dateType", attributes2); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(2, bt1.rows()); + Thread.Sleep(2000); + BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + Assert.AreEqual(2, bt2.rows()); + checkData(bt1, bt2); + } + + //[TestMethod] + //public void test_EventSender_scaler_COMPLEX() + //{ + // PrepareInputSerializer("COMPLEX", DATA_TYPE.DT_COMPLEX); + // String script = "event_dateType1 = event_dateType(complex(111, 1));\n" + + // "event_dateType2 = event_dateType( complex(0, 0));\n" + + // "event_dateType3 = event_dateType(complex(-0.99, -0.11));\n" + + // "event_dateType4 = event_dateType(NULL);\n" + + // "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; + // conn.run(script); + // List attributes1 = new List(); + // attributes1.Add(new BasicComplex(111, 1)); + // List attributes2 = new List(); + // attributes2.Add(new BasicComplex(0, 0)); + // List attributes3 = new List(); + // attributes3.Add(new BasicComplex(-0.99, -0.11)); + // List attributes4 = new List(); + // BasicComplex bb = new BasicComplex(0, 0); + // bb.setNull(); + // System.out.println(bb.getString()); + // attributes4.Add(bb); + // sender.sendEvent("event_dateType", attributes1); + // sender.sendEvent("event_dateType", attributes2); + // sender.sendEvent("event_dateType", attributes3); + // sender.sendEvent("event_dateType", attributes4); + // BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + // Assert.AreEqual(4, bt1.rows()); + // Thread.Sleep(2000); + // BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + // Assert.AreEqual(4, bt2.rows()); + // checkData(bt1, bt2); + //} + //[TestMethod] + //public void test_EventSender_scaler_POINT() + //{ + // PrepareInputSerializer("POINT", DATA_TYPE.DT_POINT); + // String script = "event_dateType1 = event_dateType(point(111, 1));\n" + + // "event_dateType2 = event_dateType( point(0, 0));\n" + + // "event_dateType3 = event_dateType(point(-0.99, -0.11));\n" + + // "event_dateType4 = event_dateType(NULL);\n" + + // "appendEvent(inputSerializer, [event_dateType1, event_dateType2, event_dateType3, event_dateType4]);"; + // conn.run(script); + // List attributes1 = new List(); + // attributes1.Add(new BasicPoint(111, 1)); + // List attributes2 = new List(); + // attributes2.Add(new BasicPoint(0, 0)); + // List attributes3 = new List(); + // attributes3.Add(new BasicPoint(-0.99, -0.11)); + // List attributes4 = new List(); + // BasicPoint bb = new BasicPoint(0, 0); + // bb.setNull(); + // attributes4.Add(bb); + // sender.sendEvent("event_dateType", attributes1); + // sender.sendEvent("event_dateType", attributes2); + // sender.sendEvent("event_dateType", attributes3); + // sender.sendEvent("event_dateType", attributes4); + // BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + // Assert.AreEqual(4, bt1.rows()); + // Thread.Sleep(2000); + // BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + // Assert.AreEqual(4, bt2.rows()); + // checkData(bt1, bt2); + //} + + + + [TestMethod] + public void test_EventSender_all_dateType_scalar_DECIMAL() + { + String script = "share streamTable(1:0, `eventType`blobs, [STRING,BLOB]) as inputTable;\n" + + "share table(100:0, `decimal32v`decimal64v`decimal128v, [DECIMAL32(3), DECIMAL64(8), DECIMAL128(10)]) as outputTable;\n"; + conn.run(script); + String script1 = "class event_all_dateType{\n" + + "\tdecimal32v :: DECIMAL32(3)\n" + + "\tdecimal64v :: DECIMAL64(8)\n" + + "\tdecimal128v :: DECIMAL128(10) \n" + + " def event_all_dateType(decimal32, decimal64, decimal128){\n" + + "\tdecimal32v = decimal32\n" + + "\tdecimal64v = decimal64\n" + + "\tdecimal128v = decimal128\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_all_dateType'\n" + + "eventKeys = 'decimal32v,decimal64v,decimal128v';\n" + + "typeV = [ DECIMAL32(3), DECIMAL64(8), DECIMAL128(10)];\n" + + "formV = [ SCALAR, SCALAR, SCALAR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput);" + + "all_data_type1=event_all_dateType(decimal32(1.1, 3),decimal64(1.1, 8),decimal128(1.1, 10))\n" + + "appendEvent(inputSerializer, all_data_type1)"; + conn.run(script1); + String script2 = "colNames=\"col\"+string(1..3)\n" + + "colTypes=[DECIMAL32(3),DECIMAL64(8),DECIMAL128(10)]\n" + + "t=table(1:0,colNames,colTypes)\n" + + "insert into t values(decimal32(1.1, 3), decimal64(1.1, 8), decimal128(1.1, 10)) ;"; + conn.run(script2); + + EventSchema scheme = new EventSchema("event_all_dateType", new List { "decimal32v", "decimal64v", "decimal128v" }, new List { DATA_TYPE.DT_DECIMAL32, DATA_TYPE.DT_DECIMAL64, DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }, new List { 3, 8, 10 }); + + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + + BasicTable bt = (BasicTable)conn.run("select * from t"); + for (int i = 0; i < bt.rows(); i++) + { + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = bt.getColumn(j).get(i); + attributes.Add(pt); + } + sender.sendEvent("event_all_dateType", attributes); + + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + Thread.Sleep(2000); + BasicTable bt2 = (BasicTable)conn.run("select * from intput;"); + Assert.AreEqual(1, bt2.rows()); + checkData(bt1, bt2); + BasicTable bt3 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(1, bt3.rows()); + Console.WriteLine(bt3.getString()); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + } + + [TestMethod] + public void test_EventSender_subscribe_all_dateType_scalar_1() + { + String script = "share streamTable(1000000:0, `time`eventType`event, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + + "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippaddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; + conn.run(script); + + EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "datetimev" }; + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + + Preparedata(1); + BasicTable bt = (BasicTable)conn.run("select * from data"); + for (int i = 0; i < bt.rows(); i++) + { + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = bt.getColumn(j).getEntity(i); + attributes.Add(pt); + } + sender.sendEvent("event_all_dateType", attributes); + } + Console.WriteLine(bt.columns()); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + Thread.Sleep(20000); + BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(1, bt2.rows()); + checkData(bt, bt2); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + + [TestMethod] + public void test_EventSender_subscribe_all_dateType_scalar_100() + { + String script = "share streamTable(1000000:0, `time`eventType`event, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + + "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippaddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; + conn.run(script); + + EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "datetimev" }; + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + + Preparedata(100); + BasicTable bt = (BasicTable)conn.run("select * from data"); + for (int i = 0; i < bt.rows(); i++) + { + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = bt.getColumn(j).getEntity(i); + attributes.Add(pt); + } + sender.sendEvent("event_all_dateType", attributes); + } + Console.WriteLine(bt.columns()); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(100, bt1.rows()); + Thread.Sleep(20000); + BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(100, bt2.rows()); + checkData(bt, bt2); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + + [TestMethod] + public void test_EventSender_subscribe_all_dateType_scalar_100000() + { + String script = "share streamTable(1000000:0, `time`eventType`event, [TIMESTAMP,STRING,BLOB]) as inputTable;\n" + + "share table(100:0, `boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`stringv`datehourv`uuidv`ippaddrv`int128v`blobv, [BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, STRING, DATEHOUR, UUID, IPADDR, INT128, BLOB]) as outputTable;\n"; + conn.run(script); + + EventSchema scheme = new EventSchema("event_all_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "stringv", "datehourv", "uuidv", "ippaddrv", "int128v", "blobv" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_STRING, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128, DATA_TYPE.DT_BLOB }, new List { DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR, DATA_FORM.DF_SCALAR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List() { "datetimev" }; + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + + Preparedata(100000); + BasicTable bt = (BasicTable)conn.run("select * from data"); + for (int i = 0; i < bt.rows(); i++) + { + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = bt.getColumn(j).getEntity(i); + attributes.Add(pt); + } + sender.sendEvent("event_all_dateType", attributes); + } + Console.WriteLine(bt.columns()); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(100000, bt1.rows()); + Thread.Sleep(20000); + BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(100000, bt2.rows()); + checkData(bt, bt2); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + + [TestMethod] + public void test_EventSender_all_dateType_vector() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "colNames=\"col\"+string(1..20);\n" + + "colTypes=[BOOL[],CHAR[],SHORT[],INT[],LONG[],DOUBLE[],FLOAT[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[],DATEHOUR[],UUID[],IPADDR[],INT128[]];\n" + + "share table(1:0,colNames,colTypes) as outputTable;\n"; + conn.run(script); + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL, DATA_TYPE.DT_BYTE, DATA_TYPE.DT_SHORT, DATA_TYPE.DT_INT, DATA_TYPE.DT_LONG, DATA_TYPE.DT_DOUBLE, DATA_TYPE.DT_FLOAT, DATA_TYPE.DT_DATE, DATA_TYPE.DT_MONTH, DATA_TYPE.DT_TIME, DATA_TYPE.DT_MINUTE, DATA_TYPE.DT_SECOND, DATA_TYPE.DT_DATETIME, DATA_TYPE.DT_TIMESTAMP, DATA_TYPE.DT_NANOTIME, DATA_TYPE.DT_NANOTIMESTAMP, DATA_TYPE.DT_DATEHOUR, DATA_TYPE.DT_UUID, DATA_TYPE.DT_IPADDR, DATA_TYPE.DT_INT128 }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + Preparedata_array(100, 10); + BasicTable bt = (BasicTable)conn.run("select * from data"); + + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler_array handler_array = new Handler_array(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler_array, -1, true, "admin", "123456"); + + for (int i = 0; i < bt.rows(); i++) + { + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = bt.getColumn(j).getEntity(i); + Console.WriteLine(pt.getDataType()); + Console.WriteLine(i + "У " + j + "У" + pt.getString()); + attributes.Add(pt); + } + sender.sendEvent("event_all_array_dateType", attributes); + } + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(10, bt1.rows()); + Thread.Sleep(10000); + BasicTable bt2 = (BasicTable)conn.run("select * from outputTable;"); + Assert.AreEqual(10, bt2.rows()); + checkData(bt, bt2); + client.unsubscribe(SERVER, PORT, "inputTable", "test1"); + } + + [TestMethod] + public void test_EventSender_decimal_1() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "share table(1:0,[\"col1\"],[DECIMAL32(3)]) as outputTable;\n"; + conn.run(script); + String script1 = "class event_decimal{\n" + + "\tdecimal32v :: DECIMAL32(3) \n" + + " def event_decimal(decimal32){\n" + + "\tdecimal32v = decimal32\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_decimal'\n" + + "eventKeys = 'decimal32v';\n" + + "typeV = [ DECIMAL32(3)];\n" + + "formV = [ SCALAR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; + conn.run(script1); + + EventSchema scheme = new EventSchema("event_decimal", new List { "decimal32v" }, new List { DATA_TYPE.DT_DECIMAL32 }, new List { DATA_FORM.DF_SCALAR }, new List { 3 }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + String script2 = "\t event_decimal1=event_decimal( decimal32(2.001,2))\n" + + "\tappendEvent(inputSerializer, event_decimal1)\n"; + conn.run(script2); + List attributes = new List(); + attributes.Add(new BasicDecimal32("2.001", 2)); + sender.sendEvent("event_decimal", attributes); + + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); + Assert.AreEqual(1, bt2.rows()); + checkData(bt1, bt2); + } + + [TestMethod] + public void test_EventSender_vector_decimal32() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "share table(1:0,[\"col1\"],[DECIMAL32(3)[]]) as outputTable;\n"; + conn.run(script); + String script1 = "class event_all_array_dateType{\n" + + "\tdecimal32v :: DECIMAL32(3) VECTOR\n" + + " def event_all_array_dateType(decimal32){\n" + + "\tdecimal32v = decimal32\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_all_array_dateType'\n" + + "eventKeys = 'decimal32v';\n" + + "typeV = [ DECIMAL32(3)[]];\n" + + "formV = [ VECTOR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; + conn.run(script1); + + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "decimal32v" }, new List { DATA_TYPE.DT_DECIMAL32 }, new List { DATA_FORM.DF_VECTOR }, new List { 3 }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + String script2 = "\tevent_all_array_dateType1=event_all_array_dateType( decimal32(1 2.001,2))\n" + + "\tappendEvent(inputSerializer, event_all_array_dateType1)\n"; + conn.run(script2); + List attributes = new List(); + attributes.Add(new BasicDecimal32Vector(new String[] { "1", "2.001" }, 2)); + sender.sendEvent("event_all_array_dateType", attributes); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); + Assert.AreEqual(1, bt2.rows()); + checkData(bt1, bt2); + } + + [TestMethod] + public void test_EventSender_vector_decimal64() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "share table(1:0,[\"col1\"],[DECIMAL64(3)[]]) as outputTable;\n"; + conn.run(script); + String script1 = "class event_all_array_dateType{\n" + + "\tdecimal64v :: DECIMAL64(3) VECTOR\n" + + " def event_all_array_dateType(decimal64){\n" + + "\tdecimal64v = decimal64\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_all_array_dateType'\n" + + "eventKeys = 'decimal64v';\n" + + "typeV = [ DECIMAL64(3)[]];\n" + + "formV = [ VECTOR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; + conn.run(script1); + + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "decimal64v" }, new List { DATA_TYPE.DT_DECIMAL64 }, new List { DATA_FORM.DF_VECTOR }, new List { 3 }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + String script2 = "\tevent_all_array_dateType1=event_all_array_dateType( decimal64(1 2.001,2))\n" + + "\tappendEvent(inputSerializer, event_all_array_dateType1)\n"; + conn.run(script2); + List attributes = new List(); + attributes.Add(new BasicDecimal64Vector(new String[] { "1", "2.001" }, 2)); + sender.sendEvent("event_all_array_dateType", attributes); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); + Assert.AreEqual(1, bt2.rows()); + checkData(bt1, bt2); + } + + [TestMethod] + public void test_EventSender_vector_decimal128() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n" + + "share table(1:0,[\"col1\"],[DECIMAL128(3)[]]) as outputTable;\n"; + conn.run(script); + String script1 = "class event_all_array_dateType{\n" + + "\tdecimal128v :: DECIMAL128(3) VECTOR\n" + + " def event_all_array_dateType(decimal128){\n" + + "\tdecimal128v = decimal128\n" + + " \t}\n" + + "} \n" + + "schemaTable = table(array(STRING, 0) as eventType, array(STRING, 0) as eventKeys, array(INT[], ) as type, array(INT[], 0) as form)\n" + + "eventType = 'event_all_array_dateType'\n" + + "eventKeys = 'decimal128v';\n" + + "typeV = [ DECIMAL128(3)[]];\n" + + "formV = [ VECTOR];\n" + + "insert into schemaTable values([eventType], [eventKeys], [typeV],[formV]);\n" + + "share streamTable( array(STRING, 0) as eventType, array(BLOB, 0) as blobs) as intput1;\n" + + "try{\ndropStreamEngine(`serInput)\n}catch(ex){\n}\n" + + "inputSerializer = streamEventSerializer(name=`serInput, eventSchema=schemaTable, outputTable=intput1);"; + conn.run(script1); + + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "decimal128v" }, new List { DATA_TYPE.DT_DECIMAL128 }, new List { DATA_FORM.DF_VECTOR }, new List { 3 }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + String script2 = "\tevent_all_array_dateType1=event_all_array_dateType( decimal128(1 2.001,2))\n" + + "\tappendEvent(inputSerializer, event_all_array_dateType1)\n"; + conn.run(script2); + List attributes = new List(); + attributes.Add(new BasicDecimal128Vector(new String[] { "1", "2.001" }, 2)); + sender.sendEvent("event_all_array_dateType", attributes); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + BasicTable bt2 = (BasicTable)conn.run("select * from intput1;"); + Assert.AreEqual(1, bt2.rows()); + checkData(bt1, bt2); + } + + [TestMethod] + public void test_EventSender_all_dateType_array() + { + String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n"; + conn.run(script); + EventSchema scheme = new EventSchema("event_all_array_dateType", new List { "boolv", "charv", "shortv", "intv", "longv", "doublev", "floatv", "datev", "monthv", "timev", "minutev", "secondv", "datetimev", "timestampv", "nanotimev", "nanotimestampv", "datehourv", "uuidv", "ippAddrv", "int128v" }, new List { DATA_TYPE.DT_BOOL_ARRAY, DATA_TYPE.DT_BYTE_ARRAY, DATA_TYPE.DT_SHORT_ARRAY, DATA_TYPE.DT_INT_ARRAY, DATA_TYPE.DT_LONG_ARRAY, DATA_TYPE.DT_DOUBLE_ARRAY, DATA_TYPE.DT_FLOAT_ARRAY, DATA_TYPE.DT_DATE_ARRAY, DATA_TYPE.DT_MONTH_ARRAY, DATA_TYPE.DT_TIME_ARRAY, DATA_TYPE.DT_MINUTE_ARRAY, DATA_TYPE.DT_SECOND_ARRAY, DATA_TYPE.DT_DATETIME_ARRAY, DATA_TYPE.DT_TIMESTAMP_ARRAY, DATA_TYPE.DT_NANOTIME_ARRAY, DATA_TYPE.DT_NANOTIMESTAMP_ARRAY, DATA_TYPE.DT_DATEHOUR_ARRAY, DATA_TYPE.DT_UUID_ARRAY, DATA_TYPE.DT_IPADDR_ARRAY, DATA_TYPE.DT_INT128_ARRAY }, new List { DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR, DATA_FORM.DF_VECTOR }); + List eventSchemas = new List(); + eventSchemas.Add(scheme); + List eventTimeFields = new List(); + List commonFields = new List(); + EventSender sender = new EventSender(conn, "inputTable", eventSchemas, eventTimeFields, commonFields); + + client = new EventClient(eventSchemas, eventTimeFields, commonFields); + Handler handler = new Handler(); + client.subscribe(SERVER, PORT, "inputTable", "test1", handler, -1, true, "admin", "123456"); + + Preparedata_array(100, 10); + BasicTable bt = (BasicTable)conn.run("select * from data"); + List attributes = new List(); + for (int j = 0; j < bt.columns(); j++) + { + IEntity pt = (bt.getColumn(j)); + Console.WriteLine(pt.getDataType()); + // Console.WriteLine(j + "У" + pt.getObject().ToString()); + attributes.Add(pt); + } + sender.sendEvent("event_all_array_dateType", attributes); + BasicTable bt1 = (BasicTable)conn.run("select * from inputTable;"); + Assert.AreEqual(1, bt1.rows()); + } + + + } +} diff --git a/test/streaming/streamReverse_test/PoolingClientReverseTest.cs b/test/streaming/streamReverse_test/PoolingClientReverseTest.cs index a660519..7c9c121 100644 --- a/test/streaming/streamReverse_test/PoolingClientReverseTest.cs +++ b/test/streaming/streamReverse_test/PoolingClientReverseTest.cs @@ -31,7 +31,7 @@ public class PoolingClientReverseTest private readonly int TIMEOUT = 10000; public static DBConnection conn; private static PollingClient client; - + private static List myLongList; public void clear_env() { try @@ -1590,8 +1590,7 @@ public void Handler_array(List messages) public void Test_PollingClient_subscribe_arrayVector_INT() { PrepareStreamTable_array("INT"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1599,12 +1598,12 @@ public void Test_PollingClient_subscribe_arrayVector_INT() checkResult(conn); client.unsubscribe(SERVER, PORT, "Trades", "sub1"); } + [TestMethod] public void Test_PollingClient_subscribe_arrayVector_BOOL() { PrepareStreamTable_array("BOOL"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1616,8 +1615,7 @@ public void Test_PollingClient_subscribe_arrayVector_BOOL() public void Test_PollingClient_subscribe_arrayVector_CHAR() { PrepareStreamTable_array("CHAR"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1629,8 +1627,7 @@ public void Test_PollingClient_subscribe_arrayVector_CHAR() public void Test_PollingClient_subscribe_arrayVector_SHORT() { PrepareStreamTable_array("SHORT"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1642,8 +1639,7 @@ public void Test_PollingClient_subscribe_arrayVector_SHORT() public void Test_PollingClient_subscribe_arrayVector_LONG() { PrepareStreamTable_array("LONG"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1655,8 +1651,7 @@ public void Test_PollingClient_subscribe_arrayVector_LONG() public void Test_PollingClient_subscribe_arrayVector_DOUBLE() { PrepareStreamTable_array("DOUBLE"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1668,8 +1663,7 @@ public void Test_PollingClient_subscribe_arrayVector_DOUBLE() public void Test_PollingClient_subscribe_arrayVector_FLOAT() { PrepareStreamTable_array("FLOAT"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1681,8 +1675,7 @@ public void Test_PollingClient_subscribe_arrayVector_FLOAT() public void Test_PollingClient_subscribe_arrayVector_TIME() { PrepareStreamTable_array("TIME"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1694,8 +1687,7 @@ public void Test_PollingClient_subscribe_arrayVector_TIME() public void Test_PollingClient_subscribe_arrayVector_MINUTE() { PrepareStreamTable_array("MINUTE"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1707,8 +1699,7 @@ public void Test_PollingClient_subscribe_arrayVector_MINUTE() public void Test_PollingClient_subscribe_arrayVector_SECOND() { PrepareStreamTable_array("SECOND"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1720,8 +1711,7 @@ public void Test_PollingClient_subscribe_arrayVector_SECOND() public void Test_PollingClient_subscribe_arrayVector_DATETIME() { PrepareStreamTable_array("DATETIME"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1733,8 +1723,7 @@ public void Test_PollingClient_subscribe_arrayVector_DATETIME() public void Test_PollingClient_subscribe_arrayVector_TIMESTAMP() { PrepareStreamTable_array("TIMESTAMP"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1746,8 +1735,7 @@ public void Test_PollingClient_subscribe_arrayVector_TIMESTAMP() public void Test_PollingClient_subscribe_arrayVector_NANOTIME() { PrepareStreamTable_array("NANOTIME"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1759,8 +1747,7 @@ public void Test_PollingClient_subscribe_arrayVector_NANOTIME() public void Test_PollingClient_subscribe_arrayVector_NANOTIMESTAMP() { PrepareStreamTable_array("NANOTIMESTAMP"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1789,8 +1776,7 @@ public void Handler_array_UUID(List messages) public void Test_PollingClient_subscribe_arrayVector_UUID() { PrepareStreamTable_array("UUID"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1819,8 +1805,7 @@ public void Handler_array_DATEHOUR(List messages) public void Test_PollingClient_subscribe_arrayVector_DATEHOUR() { PrepareStreamTable_array("DATEHOUR"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1850,8 +1835,7 @@ public void Handler_array_IPADDR(List messages) public void Test_PollingClient_subscribe_arrayVector_IPADDR() { PrepareStreamTable_array("IPADDR"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1881,8 +1865,7 @@ public void Handler_array_INT128(List messages) public void Test_PollingClient_subscribe_arrayVector_INT128() { PrepareStreamTable_array("INT128"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1929,8 +1912,7 @@ public void Handler_array_COMPLEX(List messages) public void Test_PollingClient_subscribe_arrayVector_COMPLEX() { PrepareStreamTable_array("COMPLEX"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1978,8 +1960,7 @@ public void Handler_array_POINT(List messages) public void Test_PollingClient_subscribe_arrayVector_POINT() { PrepareStreamTable_array("POINT"); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -1991,8 +1972,7 @@ public void Test_PollingClient_subscribe_arrayVector_POINT() public void Test_PollingClient_subscribe_DECIMAL32() { PrepareStreamTableDecimal("DECIMAL32", 3, 1000); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -2007,8 +1987,7 @@ public void Test_PollingClient_subscribe_DECIMAL32() public void Test_PollingClient_subscribe_DECIMAL64() { PrepareStreamTableDecimal("DECIMAL64", 3, 1000); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -2024,8 +2003,7 @@ public void Test_PollingClient_subscribe_DECIMAL64() public void Test_PollingClient_subscribe_DECIMAL128() { PrepareStreamTableDecimal("DECIMAL128", 10, 1000); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -2040,8 +2018,7 @@ public void Test_PollingClient_subscribe_DECIMAL128() public void Test_PollingClient_subscribe_DECIMAL32_1() { PrepareStreamTableDecimal("DECIMAL32", 3, 1); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -2058,8 +2035,7 @@ public void Test_PollingClient_subscribe_DECIMAL32_1() public void Test_PollingClient_subscribe_DECIMAL64_1() { PrepareStreamTableDecimal("DECIMAL64", 3, 1); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -2077,8 +2053,7 @@ public void Test_PollingClient_subscribe_DECIMAL64_1() public void Test_PollingClient_subscribe_DECIMAL128_1() { PrepareStreamTableDecimal("DECIMAL128", 10, 1); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -2096,8 +2071,7 @@ public void Test_PollingClient_subscribe_DECIMAL128_1() public void Test_PollingClient_subscribe_arrayVector_DECIMAL32() { PrepareStreamTableDecimal_array("DECIMAL32", 3); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -2110,8 +2084,7 @@ public void Test_PollingClient_subscribe_arrayVector_DECIMAL32() public void Test_PollingClient_subscribe_arrayVector_DECIMAL64() { PrepareStreamTableDecimal_array("DECIMAL64", 5); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -2124,8 +2097,7 @@ public void Test_PollingClient_subscribe_arrayVector_DECIMAL64() public void Test_PollingClient_subscribe_arrayVector_DECIMAL128() { PrepareStreamTableDecimal_array("DECIMAL128", 10); - BasicIntVector filter = new BasicIntVector(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true, filter); + TopicPoller poller = client.subscribe(SERVER, PORT, "Trades", "sub1", 0, true); conn.run("Trades.append!(pub_t);"); //write 1000 rows after subscribe List messages = poller.poll(1000, 1000); @@ -2228,5 +2200,53 @@ public void Test_TopicPoller_take() conn.run("undef(`pub, SHARED)"); conn.run("undef(`sub1, SHARED)"); } + + public void Handler_getOffset(List messages) + { + for (int i = 0; i < messages.Count; i++) + { + try + { + IMessage msg = messages[i]; + String script = String.Format("insert into sub1 values({0},{1},\"{2}\",{3},{4},{5},{6},{7},{8},{9},{10},{11},{12} )", msg.getEntity(0).getString(), msg.getEntity(1).getString(), msg.getEntity(2).getString(), msg.getEntity(3).getString(), msg.getEntity(4).getString(), msg.getEntity(5).getString(), msg.getEntity(6).getString(), msg.getEntity(7).getString(), msg.getEntity(8).getString(), msg.getEntity(9).getString(), msg.getEntity(10).getString(), msg.getEntity(11).getString(), msg.getEntity(12).getString()); + conn.run(script); + Console.Out.WriteLine("msg.getOffset is :" + msg.getOffset()); + myLongList.Add(msg.getOffset()); + } + catch (Exception e) + { + Console.Out.WriteLine(e.ToString()); + } + } + } + + [TestMethod] + public void Test_PollingClient_subscribe_getOffset() + { + PrepareStreamTable1(conn, "pub"); + PrepareStreamTable1(conn, "sub1"); + WriteStreamTable1(conn, "pub", 1000); + myLongList = new List(); + BasicInt num1 = (BasicInt)conn.run("exec count(*) from pub"); + Assert.AreEqual(1000, num1.getInt()); + TopicPoller pool = client.subscribe(SERVER, PORT, "pub", 0); + //write 1000 rows after subscribe + WriteStreamTable1(conn, "pub", 1000); + List messages = pool.poll(1000, 2000); + Handler_getOffset(messages); + checkResult1(conn, "pub", "sub1"); + client.unsubscribe(SERVER, PORT, "pub"); + myLongList.Sort(); + int total = 0; + Assert.AreEqual(2000, myLongList.Count); + foreach (long item in myLongList) + { + Console.WriteLine(item); + Assert.AreEqual(item, total); + total++; + } + conn.run("undef(`pub, SHARED)"); + conn.run("undef(`sub1, SHARED)"); + } } } diff --git a/test/streaming/streamReverse_test/ThreadPoolClientReverseTest.cs b/test/streaming/streamReverse_test/ThreadPoolClientReverseTest.cs index 6e1fb5f..a103c2b 100644 --- a/test/streaming/streamReverse_test/ThreadPoolClientReverseTest.cs +++ b/test/streaming/streamReverse_test/ThreadPoolClientReverseTest.cs @@ -28,6 +28,7 @@ public class ThreadedPoolClientReverseTest private readonly int HASTREAM_GROUPID = MyConfigReader.HASTREAM_GROUPID; public static DBConnection conn; private static ThreadPooledClient client; + private static List myLongList ; public void clear_env() { @@ -327,14 +328,14 @@ public void PrepareStreamTableDecimal(String dataType, int scale,int rows) public static void checkResult(DBConnection conn) { - for (int i = 0; i < 10; i++) + for (int i = 0; i < 20; i++) { BasicInt tmpNum = (BasicInt)conn.run("exec count(*) from sub1"); if (tmpNum.getInt() == (1000)) { break; } - Thread.Sleep(2000); + Thread.Sleep(100); } BasicTable except = (BasicTable)conn.run("select * from Trades order by permno"); BasicTable res = (BasicTable)conn.run("select * from sub1 order by permno"); @@ -2603,5 +2604,72 @@ public void Test_ThreadPooledClient_subscribe_arrayVector_DECIMAL128() Console.WriteLine(res.rows()); client.unsubscribe(SERVER, PORT, "Trades"); } + + class Handler_getOffset : MessageHandler + { + + public void batchHandler(List msgs) + { + throw new NotImplementedException(); + } + + public void doEvent(IMessage msg) + { + try + { + msg.getEntity(0); + String script = String.Format("insert into sub1 values({0},{1},\"{2}\",{3},{4},{5},{6},{7},{8},{9},{10},{11},{12} )", msg.getEntity(0).getString(), msg.getEntity(1).getString(), msg.getEntity(2).getString(), msg.getEntity(3).getString(), msg.getEntity(4).getString(), msg.getEntity(5).getString(), msg.getEntity(6).getString(), msg.getEntity(7).getString(), msg.getEntity(8).getString(), msg.getEntity(9).getString(), msg.getEntity(10).getString(), msg.getEntity(11).getString(), msg.getEntity(12).getString()); + conn.run(script); + Console.Out.WriteLine("msg.getOffset is :" + msg.getOffset()); + myLongList.Add(msg.getOffset()); + } + catch (Exception e) + { + System.Console.Out.WriteLine(e.ToString()); + } + } + }; + + [TestMethod] + public void Test_ThreadPooledClient_subscribe_getOffset() + + { + PrepareStreamTable1(conn, "pub"); + PrepareStreamTable1(conn, "sub1"); + //write 1000 rows first + WriteStreamTable1(conn, "pub", 1000); + BasicInt num1 = (BasicInt)conn.run("exec count(*) from pub"); + Assert.AreEqual(1000, num1.getInt()); + Handler_getOffset handler1 = new Handler_getOffset(); + myLongList = new List(); + client.subscribe(SERVER, PORT, "pub", handler1, 0); + //write 1000 rows after subscribe + WriteStreamTable1(conn, "pub", 1000); + for (int i = 0; i < 10; i++) + { + BasicInt tmpNum = (BasicInt)conn.run("exec count(*) from sub1"); + if (tmpNum.getInt().Equals(2000)) + { + break; + } + Thread.Sleep(1000); + } + BasicInt num2 = (BasicInt)conn.run("exec count(*) from sub1"); + Assert.AreEqual(2000, num2.getInt()); + client.unsubscribe(SERVER, PORT, "pub"); + myLongList.Sort(); + int total = 0; + Assert.AreEqual(2000, myLongList.Count); + foreach (long item in myLongList) + { + Console.WriteLine(item); + Assert.AreEqual(item, total); + total++; + } + + conn.run("undef(`pub, SHARED)"); + conn.run("undef(`sub1, SHARED)"); + } + } } diff --git a/test/streaming/streamReverse_test/ThreadedClientReverseTest.cs b/test/streaming/streamReverse_test/ThreadedClientReverseTest.cs index ea34d6a..ac0d9a1 100644 --- a/test/streaming/streamReverse_test/ThreadedClientReverseTest.cs +++ b/test/streaming/streamReverse_test/ThreadedClientReverseTest.cs @@ -24,7 +24,7 @@ public class ThreadedClientReverseTest private readonly int HASTREAM_GROUPID = MyConfigReader.HASTREAM_GROUPID; public static DBConnection conn; private static ThreadedClient client; - + static private int total = 0; public void clear_env() { try @@ -293,14 +293,14 @@ public void PrepareStreamTableDecimal(String dataType, int scale) public static void checkResult(DBConnection conn) { - for (int i = 0; i < 10; i++) + for (int i = 0; i < 20; i++) { BasicInt tmpNum = (BasicInt)conn.run("exec count(*) from sub1"); if (tmpNum.getInt() == (1000)) { break; } - Thread.Sleep(2000); + Thread.Sleep(100); } BasicTable except = (BasicTable)conn.run("select * from Trades order by permno"); BasicTable res = (BasicTable)conn.run("select * from sub1 order by permno"); @@ -2288,7 +2288,7 @@ public void doEvent(IMessage msg) msg.getEntity(0); String script = String.Format("insert into sub1 values({0},{1})", msg.getEntity(0).getString(), msg.getEntity(1).getString().Replace(",,", ",NULL,").Replace("[,", "[NULL,").Replace(",]", ",NULL]").Replace(',', ' ')); conn.run(script); - System.Console.Out.WriteLine(script); + //System.Console.Out.WriteLine(script); } catch (Exception e) @@ -2844,6 +2844,61 @@ public void Test_ThreadClient_subscribe_arrayVector_DECIMAL128() client.unsubscribe(SERVER, PORT, "Trades"); } + class Handler_getOffset : MessageHandler + { + + public void batchHandler(List msgs) + { + throw new NotImplementedException(); + } + + public void doEvent(IMessage msg) + { + try + { + msg.getEntity(0); + String script = String.Format("insert into sub1 values({0},{1},\"{2}\",{3},{4},{5},{6},{7},{8},{9},{10},{11},{12} )", msg.getEntity(0).getString(), msg.getEntity(1).getString(), msg.getEntity(2).getString(), msg.getEntity(3).getString(), msg.getEntity(4).getString(), msg.getEntity(5).getString(), msg.getEntity(6).getString(), msg.getEntity(7).getString(), msg.getEntity(8).getString(), msg.getEntity(9).getString(), msg.getEntity(10).getString(), msg.getEntity(11).getString(), msg.getEntity(12).getString()); + conn.run(script); + Console.Out.WriteLine("msg.getOffset is :" + msg.getOffset()); + Assert.AreEqual(total, msg.getOffset()); + total++; + } + catch (Exception e) + { + System.Console.Out.WriteLine(e.ToString()); + } + } + }; + + [TestMethod] + public void Test_ThreaedClient_subscribe_getOffset() + + { + PrepareStreamTable1(conn, "pub"); + PrepareStreamTable1(conn, "sub1"); + //write 1000 rows first + WriteStreamTable1(conn, "pub", 1000); + BasicInt num1 = (BasicInt)conn.run("exec count(*) from pub"); + Assert.AreEqual(1000, num1.getInt()); + Handler_getOffset handler1 = new Handler_getOffset(); + client.subscribe(SERVER, PORT, "pub", handler1, 0, -1); + //write 1000 rows after subscribe + WriteStreamTable1(conn, "pub", 1000); + for (int i = 0; i < 10; i++) + { + BasicInt tmpNum = (BasicInt)conn.run("exec count(*) from sub1"); + if (tmpNum.getInt().Equals(2000)) + { + break; + } + Thread.Sleep(1000); + } + BasicInt num2 = (BasicInt)conn.run("exec count(*) from sub1"); + Assert.AreEqual(2000, num2.getInt()); + client.unsubscribe(SERVER, PORT, "pub"); + conn.run("undef(`pub, SHARED)"); + conn.run("undef(`sub1, SHARED)"); + } } }