From bb1dcee350ba52a0966ef0d27a3707d92f4d6190 Mon Sep 17 00:00:00 2001 From: dailyccc <963922242@qq.com> Date: Tue, 21 Feb 2023 20:29:40 +0800 Subject: [PATCH] =?UTF-8?q?-=E5=A2=9E=E5=8A=A0RestAPI=20ExecuteBulkCopy?= =?UTF-8?q?=E9=80=82=E9=85=8D=20=E8=A7=A3=E5=86=B3=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=20table=20busy=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FreeSql.Provider.QuestDb/QuestDbUtils.cs | 143 +----------------- 1 file changed, 6 insertions(+), 137 deletions(-) diff --git a/Providers/FreeSql.Provider.QuestDb/QuestDbUtils.cs b/Providers/FreeSql.Provider.QuestDb/QuestDbUtils.cs index f898bf64..d957a940 100644 --- a/Providers/FreeSql.Provider.QuestDb/QuestDbUtils.cs +++ b/Providers/FreeSql.Provider.QuestDb/QuestDbUtils.cs @@ -14,10 +14,16 @@ using System.Globalization; using System.Linq; using System.Linq.Expressions; using System.Net; +using System.Net.Http; using System.Numerics; using System.Text; using System.Threading; using FreeSql.QuestDb; +using System.Web; +using System.Threading.Tasks; +using Newtonsoft.Json; +using System.IO; +using CsvHelper; namespace FreeSql.QuestDb { @@ -382,141 +388,4 @@ namespace FreeSql /// M } - - public static class SampleByExtension - { - //是否使用该方法 - internal static AsyncLocal IsExistence = new AsyncLocal() - { - Value = false - }; - - internal static AsyncLocal SamoleByString = new AsyncLocal() - { - Value = string.Empty - }; - - public static void Initialize() - { - IsExistence.Value = false; - SamoleByString.Value = string.Empty; - } - - /// - /// SAMPLE BY用于时间序列数据,将大型数据集汇总为同质时间块的聚合,作为SELECT语句的一部分。对缺少数据的数据集执行查询的用户可以使用FILL关键字指定填充行为 - /// - /// - /// - /// 时长 - /// 单位 - /// - public static ISelect SampleBy(this ISelect select, double time, SampleUnits unit) - { - var _unit = Enum.GetName(typeof(SampleUnits), unit); - IsExistence.Value = true; - var samoleByTemple = $"{Environment.NewLine}SAMPLE BY {{0}}{{1}}{Environment.NewLine}"; - SamoleByString.Value = string.Format(samoleByTemple, time.ToString(), _unit); - return select; - } - } - - public static class LatestOnExtension - { - //是否使用该方法 - internal static AsyncLocal IsExistence = new AsyncLocal() - { - Value = false - }; - - internal static AsyncLocal LatestOnString = new AsyncLocal() - { - Value = string.Empty - }; - - public static void Initialize() - { - IsExistence.Value = false; - LatestOnString.Value = string.Empty; - } - - /// - /// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。 - /// - /// - /// - /// - /// 时间标识 - /// 最新项的列 - /// - public static ISelect LatestOn(this ISelect select, Expression> timestamp, - Expression> partition) - { - Provider(timestamp, partition); - return select; - } - - private static void Provider(Expression> timestamp, - Expression> partition) - { - IsExistence.Value = true; - var latestOnTemple = $"{Environment.NewLine}LATEST ON {{0}} PARTITION BY {{1}} "; - var expressionVisitor = new QuestDbExpressionVisitor(); - expressionVisitor.Visit(timestamp); - var _timestamp = expressionVisitor.Fields(); - expressionVisitor.Visit(partition); - var _partition = expressionVisitor.Fields(); - LatestOnString.Value = string.Format(latestOnTemple, _timestamp, _partition); - } - - /// - /// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。 - /// - /// - /// - /// - /// 时间标识 - /// 最新项的列 - /// - public static ISelect LatestOn(this ISelect select, - Expression> timestamp, - Expression> partition) where T2 : class - { - Provider(timestamp, partition); - return select; - } - - /// - /// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。 - /// - /// - /// - /// - /// 时间标识 - /// 最新项的列 - /// - public static ISelect LatestOn(this ISelect select, - Expression> timestamp, - Expression> partition) where T2 : class where T3 : class - { - Provider(timestamp, partition); - return select; - } - - /// - /// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。 - /// - /// - /// - /// - /// 时间标识 - /// 最新项的列 - /// - public static ISelect LatestOn(this ISelect select, - Expression> timestamp, - Expression> partition) where T2 : class where T3 : class where T4 : class - { - Provider(timestamp, partition); - return select; - } - } } \ No newline at end of file