/// <summary> /// Instantiate a Table by directly deserializing byte data from the given Deserializer. /// </summary> /// <param name="input">The Deserializer providing the data for the table.</param> internal SingleRowTable(Deserializer input) : base(input) { // Validate row count. if (this.RowCount > 1) { throw new VoltInvalidDataException(Resources.InvalidRowCount, this.RowCount); } else if (this.RowCount == 0) { return; } // Total byte length of the row (ignored). int rowLength = input.ReadInt32(); // Read data and push in storage. for (short c = 0; c < this.ColumnCount; c++) { switch (ColumnType[c]) { case DBType.TINYINT: Column.SetValue(input.ReadSByteN(), c); break; case DBType.SMALLINT: Column.SetValue(input.ReadInt16N(), c); break; case DBType.INTEGER: Column.SetValue(input.ReadInt32N(), c); break; case DBType.BIGINT: Column.SetValue(input.ReadInt64N(), c); break; case DBType.FLOAT: Column.SetValue(input.ReadDoubleN(), c); break; case DBType.DECIMAL: Column.SetValue(input.ReadVoltDecimalN(), c); break; case DBType.TIMESTAMP: Column.SetValue(input.ReadDateTimeN(), c); break; case DBType.VARBINARY: Column.SetValue(input.ReadByteArray(), c); break; default: Column.SetValue(input.ReadString(), c); break; } } }
/// <summary> /// Instantiate a Table by directly deserializing byte data from the given Deserializer. /// </summary> /// <param name="input">The Deserializer providing the data for the table.</param> internal SingleRowTable(Deserializer input) : base(input) { // Validate row count. if (this.RowCount > 1) throw new VoltInvalidDataException(Resources.InvalidRowCount, this.RowCount); else if (this.RowCount == 0) return; // Total byte length of the row (ignored). int rowLength = input.ReadInt32(); // Read data and push in storage. for (short c = 0; c < this.ColumnCount; c++) { switch (ColumnType[c]) { case DBType.TINYINT: Column.SetValue(input.ReadSByteN(), c); break; case DBType.SMALLINT: Column.SetValue(input.ReadInt16N(), c); break; case DBType.INTEGER: Column.SetValue(input.ReadInt32N(), c); break; case DBType.BIGINT: Column.SetValue(input.ReadInt64N(), c); break; case DBType.FLOAT: Column.SetValue(input.ReadDoubleN(), c); break; case DBType.DECIMAL: Column.SetValue(input.ReadVoltDecimalN(), c); break; case DBType.TIMESTAMP: Column.SetValue(input.ReadDateTimeN(), c); break; case DBType.VARBINARY: Column.SetValue(input.ReadByteArray(), c); break; default: Column.SetValue(input.ReadString(), c); break; } } }
/// <summary> /// Instantiate a Table by directly deserializing byte data from the given Deserializer. /// </summary> /// <param name="input">The Deserializer providing the data for the table.</param> internal Table(Deserializer input) : base(input) { // Allocate column-based data storage. for (short c = 0; c < this.ColumnCount; c++) { switch (ColumnType[c]) { case DBType.TINYINT: Column[c] = new sbyte?[this.RowCount]; break; case DBType.SMALLINT: Column[c] = new short?[this.RowCount]; break; case DBType.INTEGER: Column[c] = new int?[this.RowCount]; break; case DBType.BIGINT: Column[c] = new long?[this.RowCount]; break; case DBType.FLOAT: Column[c] = new double?[this.RowCount]; break; case DBType.DECIMAL: Column[c] = new VoltDecimal?[this.RowCount]; break; case DBType.TIMESTAMP: Column[c] = new DateTime?[this.RowCount]; break; case DBType.STRING: Column[c] = new string[this.RowCount]; break; case DBType.VARBINARY: Column[c] = new byte[this.RowCount][]; break; default: throw new VoltUnsupportedTypeException(Resources.UnsupportedDBType, ColumnType[c]); } } // Get data and push to storage. for (int r = 0; r < this.RowCount; r++) { // Total byte length of the row (ignored). input.Skip(4); // Read data and push in storage. for (short c = 0; c < this.ColumnCount; c++) { switch (ColumnType[c]) { case DBType.TINYINT: (Column[c] as sbyte?[])[r] = input.ReadSByteN(); break; case DBType.SMALLINT: (Column[c] as short?[])[r] = input.ReadInt16N(); break; case DBType.INTEGER: (Column[c] as int?[])[r] = input.ReadInt32N(); break; case DBType.BIGINT: (Column[c] as long?[])[r] = input.ReadInt64N(); break; case DBType.FLOAT: (Column[c] as double?[])[r] = input.ReadDoubleN(); break; case DBType.DECIMAL: (Column[c] as VoltDecimal?[])[r] = input.ReadVoltDecimalN(); break; case DBType.TIMESTAMP: (Column[c] as DateTime?[])[r] = input.ReadDateTimeN(); break; case DBType.VARBINARY: (Column[c] as byte[][])[r] = input.ReadByteArray(); break; default: (Column[c] as string[])[r] = input.ReadString(); break; } } } // Attach the enumerable row collection. this._Rows = new RowCollection(this); }
/// <summary> /// Instantiate a Table by directly deserializing byte data from the given Deserializer. /// </summary> /// <param name="input">The Deserializer providing the data for the table.</param> internal Table(Deserializer input) : base(input) { // Allocate column-based data storage. for (short c = 0; c < this.ColumnCount; c++) { switch (ColumnType[c]) { case DBType.TINYINT: Column[c] = new sbyte?[this.RowCount]; break; case DBType.SMALLINT: Column[c] = new short?[this.RowCount]; break; case DBType.INTEGER: Column[c] = new int?[this.RowCount]; break; case DBType.BIGINT: Column[c] = new long?[this.RowCount]; break; case DBType.FLOAT: Column[c] = new double?[this.RowCount]; break; case DBType.DECIMAL: Column[c] = new VoltDecimal?[this.RowCount]; break; case DBType.TIMESTAMP: Column[c] = new DateTime?[this.RowCount]; break; case DBType.STRING: Column[c] = new string[this.RowCount]; break; case DBType.VARBINARY: Column[c] = new byte[this.RowCount][]; break; default: throw new VoltUnsupportedTypeException(Resources.UnsupportedDBType, ColumnType[c]); } } // Get data and push to storage. for (int r = 0; r < this.RowCount; r++) { // Total byte length of the row (ignored). input.Skip(4); // Read data and push in storage. for (short c = 0; c < this.ColumnCount; c++) { switch (ColumnType[c]) { case DBType.TINYINT: (Column[c] as sbyte?[])[r] = input.ReadSByteN(); break; case DBType.SMALLINT: (Column[c] as short?[])[r] = input.ReadInt16N(); break; case DBType.INTEGER: (Column[c] as int?[])[r] = input.ReadInt32N(); break; case DBType.BIGINT: (Column[c] as long?[])[r] = input.ReadInt64N(); break; case DBType.FLOAT: (Column[c] as double?[])[r] = input.ReadDoubleN(); break; case DBType.DECIMAL: (Column[c] as VoltDecimal?[])[r] = input.ReadVoltDecimalN(); break; case DBType.TIMESTAMP: (Column[c] as DateTime?[])[r] = input.ReadDateTimeN(); break; case DBType.VARBINARY: (Column[c] as byte[][])[r] = input.ReadByteArray(); break; default: (Column[c] as string[])[r] = input.ReadString(); break; } } } // Attach the enumerable row collection. this._Rows = new RowCollection(this); }