public override void set(int index, IScalar value) { if (value.getString() == null || value.getString() == "") { values[index] = (byte)0; } else { values[index] = value.getNumber().byteValue(); } }
public override void set(int index, IScalar value) { if (value.getString() == null || value.getString() == "") { setNull(index); } else { values[index] = Convert.ToInt64(value.getString()); } }
public override void set(int index, IScalar value) { if (value.getDataType() == DATA_TYPE.DT_STRING) { values[index] = @base.find(value.getString(), true); } else { throw new Exception("The value must be a string scalar. "); } }
public override void set(int index, IScalar value) { if (value.getDataType() == DATA_TYPE.DT_INT) { values[index] = ((BasicInt)value).getInt(); } else { values[index] = Convert.ToInt32(value.getString()); } }
public void Test_Function_Float() { DBConnection db = new DBConnection(); db.connect(SERVER, PORT); List <IEntity> args = new List <IEntity>(1); BasicFloatVector vec = new BasicFloatVector(3); vec.setFloat(0, 1.5f); vec.setFloat(1, 2.5f); vec.setFloat(2, 7f); args.Add(vec); IScalar result = (IScalar)db.run("sum", args); Assert.AreEqual("11", result.getString()); }
public override int asof(IScalar value) { string target = value.getString(); int start = 0; int end = values.Count - 1; int mid; while (start <= end) { mid = (start + end) / 2; if (@base.getSymbol(values[mid]).CompareTo(target) <= 0) { start = mid + 1; } else { end = mid - 1; } } return(end); }
/// <summary> /// transfer data to datatable /// </summary> /// <returns></returns> public DataTable toDataTable() { DataTable dt = new DataTable(_tableName); foreach (string fieldName in names_) { int i = name2index_[fieldName].Value; DATA_TYPE dtype = columns_[i].getDataType(); DataColumn dc = new DataColumn(fieldName, Utils.getSystemType(dtype)); dt.Columns.Add(dc); } if (columns_.Count == 0) { return(null); //table columns not exists } int rowCount = columns_[0].rows(); for (int rowIndex = 0; rowIndex < this.rows(); rowIndex++) { DataRow dr = dt.NewRow(); for (int colIndex = 0; colIndex < this.columns(); colIndex++) { DATA_TYPE dtype = columns_[colIndex].getDataType(); switch (dtype) { case DATA_TYPE.DT_BOOL: BasicBoolean bbobj = (BasicBoolean)columns_[colIndex].get(rowIndex); if (bbobj.isNull()) { dr[colIndex] = DBNull.Value; } else { dr[colIndex] = bbobj.getValue(); } break; case DATA_TYPE.DT_BYTE: BasicByte bobj = (BasicByte)columns_[colIndex].get(rowIndex); if (bobj.isNull()) { dr[colIndex] = DBNull.Value; } else { dr[colIndex] = bobj.getValue(); } break; case DATA_TYPE.DT_SHORT: BasicShort bsobj = (BasicShort)columns_[colIndex].get(rowIndex); if (bsobj.isNull()) { dr[colIndex] = DBNull.Value; } else { dr[colIndex] = bsobj.getValue(); } break; case DATA_TYPE.DT_INT: BasicInt biobj = (BasicInt)columns_[colIndex].get(rowIndex); if (biobj.isNull()) { dr[colIndex] = DBNull.Value; } else { dr[colIndex] = biobj.getValue(); } break; case DATA_TYPE.DT_LONG: BasicLong blobj = (BasicLong)columns_[colIndex].get(rowIndex); if (blobj.isNull()) { dr[colIndex] = DBNull.Value; } else { dr[colIndex] = blobj.getValue(); } break; case DATA_TYPE.DT_FLOAT: BasicFloat bfobj = (BasicFloat)columns_[colIndex].get(rowIndex); if (bfobj.isNull()) { dr[colIndex] = DBNull.Value; } else { dr[colIndex] = bfobj.getValue(); } break; case DATA_TYPE.DT_DOUBLE: BasicDouble bdobj = (BasicDouble)columns_[colIndex].get(rowIndex); if (bdobj.isNull()) { dr[colIndex] = DBNull.Value; } else { dr[colIndex] = bdobj.getValue(); } break; default: IScalar eobj = (IScalar)columns_[colIndex].get(rowIndex); if (eobj.isNull()) { dr[colIndex] = DBNull.Value; } else { dr[colIndex] = eobj.getString(); } break; } } dt.Rows.Add(dr); } return(dt); }
public override void set(int index, IScalar value) { values[index] = Convert.ToInt32(value.getString()); }
public override void set(int index, IScalar value) { values[index] = float.Parse(value.getString()); }