Beispiel #1
0
        /// <summary>
        /// Copies all rows in the supplied DataTable to a destination table specified by the DestinationTableName property of the PhoenixBulkCopy object.
        /// </summary>
        /// <param name="table"></param>
        public void WriteToServer(DataTable table)
        {
            pbc::RepeatedField <UpdateBatch> updates = new pbc::RepeatedField <UpdateBatch>();
            long   batchCount = 0;
            string sql        = BuildStatement();

            PrepareResponse pResp = _connection.InternalPrepareStatement(sql);

            foreach (DataRow row in table.Rows)
            {
                UpdateBatch anUpdate = new UpdateBatch();
                foreach (var val in row.ItemArray)
                {
                    anUpdate.ParameterValues.Add(PhoenixParameter.AsPhoenixTypedValue(val));
                }

                updates.Add(anUpdate);

                // If we reached the batch size, then send to server... ?
                batchCount++;
                if (batchCount >= this.BatchSize)
                {
                    // Send to server
                    _connection.InternalExecuteBatch(pResp.Statement.Id, updates);
                    updates.Clear();

                    // Reset batch counter
                    batchCount = 0;
                }
            }

            // Last batch
            if (batchCount > 0)
            {
                // Send to server
                _connection.InternalExecuteBatch(pResp.Statement.Id, updates);
                updates.Clear();
            }
        }
Beispiel #2
0
 /// <summary>
 /// Converts the specified parameter to and returns the Apache Phoenix TypedValue structure.
 /// </summary>
 /// <returns></returns>
 public static TypedValue AsPhoenixTypedValue(PhoenixParameter parameter)
 {
     return(PhoenixParameter.AsPhoenixTypedValue(parameter.Value));
 }
Beispiel #3
0
 /// <summary>
 /// Converts this parameter to and returns the Apache Phoenix TypedValue structure.
 /// </summary>
 /// <returns></returns>
 public TypedValue AsPhoenixTypedValue()
 {
     return(PhoenixParameter.AsPhoenixTypedValue(this));
 }