Provider Model Design Pattern Part 1

Excel日期差计算的5种业务级方法:从自然日到自定义工作日 在Excel中计算两个日期之间的天数,表面是基础算术操作,实则涉及时间语义、业务规则与系统逻辑的深度耦合。理解‘日期差’的本质,需区分自然日流逝、组织工作日运行、法定节假日约束、人因周期表达(如工龄)及实时动态锚点等不同维度。其中NETWORKDAYS.INTL()凭借7位二进制周末定义与可扩展假日列表,成为支撑跨国协作、金融计息、HR合规与项目排期等高要求场景的核心函数;而DATEDIF()则在年/月/日整数单位转换中不可替代。掌握这些函数背后的业务映射逻辑,才能避免‘数字正确但业务错误’的致命陷阱。 阅读详情

 

 

Related Books

This column has been quiet for some time—sorry about that. I have a really, really good excuse, though: We've been busy working on the next version of the Microsoft® .NET Framework and Microsoft® Visual Studio® .NET, code-named "Whidbey."

Busy is actually an understatement. For Microsoft® ASP.NET, we've roughly doubled the number of class libraries! Is that a good thing? Yes it is, and in the coming months we'll explore some of these new ASP.NET features. However, before focusing all of our attention towards Whidbey, we'll spend the first several articles on ASP.NET 1.1 and relate it to what's to come in Whidbey.

Our first article is about the new Whidbey provider-model design pattern and how you can start using it in your ASP.NET 1.1 applications today.

There has been a lot of buzz recently surrounding the announcement of the next version of Microsoft® Visual Studio® .NET and the Microsoft® .NET Framework code-named "Whidbey." No, this isn't another Whidbey article, but it is an article that discusses an important new design pattern that is going to show up in Whidbey, and more importantly, a pattern you can start using in your applications today.

In the next article, we'll look at implementing this pattern in an ASP.NET 1.1 application. In this article, we'll discuss why the pattern is needed, and walk through the "Whidbey" provider specification. Let's look at some of the reasons why we need the provider design pattern first.

Fixed Choices

In published APIs you are usually limited to a fixed number of options. An example I commonly use is the Microsoft® ASP.NET Session State feature. ASP.NET Session State supports an "out-of-process" mode. Using either Microsoft® SQL Server or the ASP.NET State Server, you can store user's Session data in a process separate from the running application. There are many benefits: reliability, easy Web farm support, and scalability. Most people tend to lean towards the database solution, since it allows for replication and other benefits not offered by the State Server. One small problem: What if you're not a SQL Server customer?

Fixed Internal Behaviors

Here's another common situation, again using Session State. Say you want to change some internal behaviors of ASP.NET APIs, for example changing how ASP.NET Session sets or retrieves values from its out-of-process store. Today you're constrained by the design. It is all or nothing: either we fetch all your data, or we fetch none of your data. If you're storing 5 MB of data and only need 50 KB to satisfy the current request... You get the picture.

Fixed Data Schema

The final scenario relevant to this discussion concerns schema. A schema is the logical model of how data is stored. For example, if you ever used Microsoft® Site Server 3.0 Personalization, it forced you to move your data into the schema that it desired. That's all well and good, but typically the people who built that schema don't know a whole lot about your business. In other words, fixed schemas are typically built to be really good for everyone, but excellent for no one.

These are common problems that all technologies share: the inability to change core behavior or functionality of published APIs.

Who Cares, I'll Write My Own

You definitely can create your own solutions for all these problems, but there are a lot of benefits to using applications with published APIs. One of the main benefits is that many developers know and understand what these APIs are and how they work. If you need to augment your staff, for instance, you can hire a consultant that is already familiar with these well-documented APIs. If you write your own, guess what; you also get to pay that person to learn your proprietary system.

What we really want is a way for everyone to get the benefits of well-documented and familiar programming interfaces, such as Session State, but the ability to completely control the internal Business Logic Layer (BLL) and Data Access Layer (DAL) of these APIs.

Introducing the Provider Design Pattern

The Provider Design Pattern is a pattern we've used in several of our ASP.NET Starter Kits, formalized in ASP.NET Whidbey, and one that we'll hope you'll start using for your applications, too. The theory of the pattern is that it allows us to define a well-documented, easy-to-understand API, such as our new Whidbey Membership APIs, but at the same time give developers complete control over the internals of what occurs when those APIs are called.

The pattern was officially named in the summer of 2002 when we were designing the new Personalization feature of ASP.NET Whidbey. We were struggling to design the "right" schema that worked for everyone—the Personalization feature of ASP.NET Whidbey adds a new Profile class to which you can add strongly typed properties, for example, FirstName, whose values are stored in a database. The problem was that we needed a flexible design, but at the same time we wanted it to be easily extensible without everyone having to be a DBA; turns out this simple requirement is an incredibly challenging problem.

On the one hand, we could have designed the system to be entirely schema driven. This would have meant that we would have designed what I call, for lack of a better name, vertical tables in the database. Rather than using traditional columns, there would be a set of tables used to define the schema and a data table used to map data to a particular type. Each new item in the data table would correspond to a type in the schema table identifying what type of property it was. Below is a very simplistic data model of this design:

Figure 1. A simple model for personalization

Using this data model, we would see something like the data below in the Schema table:

Figure 2. Proposed schema table

And data in the PersonalizationData table similar to the data below:

Figure 3. PersonalizationData table

As you can see, this model maps the property type (such as FirstName) to a property value in the PersonalizationData table, such as FirstName: Rob.

While being infinitely flexible, this model starts breaking down with a large number of users and properties. For example, while testing this design, we used the data from the ASP.NET Forums. At the time, this was 200,000 users, each with about 15 properties. This resulted in 3,000,000 rows in the data table! An important benefit that SQL can provide, namely normalized data, is lost. We also knew that people would want to use standard SQL syntax for selecting from the tables for reporting and maintenance—for example, try running a report on this type of design for all who live in a certain zip code using the vertical table design—not easy!

The obvious solution was to use normal tables, but we didn't want users to have to call a DBA to modify the tables for incremental changes. For example, to add a new property called ZipCode would require adding a new column to the Person table.

The conundrum was that we could choose either a very flexible schema-based design that had scale limitations, or a super-scalable design that might be too inflexible for some people. Furthermore, beyond the simple data schema problems, we also wanted partitioned data access, and we wanted the Personalization APIs to be extensible. We wanted a lot!

What did we decide? Well, we decided that each customer scenario would be unique. We knew that we would eventually want to implement it ourselves on www.asp.net, and would want control over the data model. To solve the problem, we borrowed a pattern we had been experimenting with in the ASP.NET Forums.

The Pattern

The pattern itself is exceedingly simple and is given the name "provider" since it provides the functionality for an API. Defined, a provider is simply a contract between an API and the Business Logic/Data Abstraction Layer. The provider is the implementation of the API separate from the API itself. For example, the new Whidbey Membership feature has a static method called Membership.ValidateUser(). The Membership class itself contains no business logic; instead it simply forwards this call to the configured provider. It is the responsibility of the provider class to contain the implementation for that method, calling whatever Business Logic Layer (BLL) or Data Access Layer (DAL) is necessary.

There are some rules for how a provider behaves. A provider implementation must derive from an abstract base class, which is used to define a contract for a particular feature. For example, to create a membership provider for Oracle, you create a new class OracleMembershipProvider, which derives from MembershipProviderBase. The feature base class, for example, MembershipProviderBase, in turn derives from a common ProviderBase base class. The ProviderBase class is used to mark implementers as a provider and forces the implementation of a required method and property common to all providers. Figure 4 gives an example of the inheritance chain.

Click here for larger image.

Figure 4. A provider inheritance chain

The implementer must also define a configuration section entry used to load the provider. Below is an example of what this configuration entry looks like (borrowed from the ASP.NET Forums):

<configuration>
    <forums>
        <forums defaultProvider="SqlForumsProvider" 
          defaultLanguage="en-en" >
            <providers>
                <clear/>

                <add name = "SqlForumsProvider" 
                     type = "AspNetForums.Data.SqlDataProvider, 
                             AspNetForums.SqlDataProvider" 
                     connectionString = "[connection string]"
                     databaseOwner = "dbo"
                />

                <add name = "AccessForumsProvider" 
                     type = "AspNetForums.Data.AccessDataProvider, 
                             AspNetForums.AccessDataProvider" 
                     fileLocation = 
                     "~/data/AccessDataProvider/AspNetForums.mdb"
                />

            </providers>

        </forums>
    </forums>
</configuration>

We'll see what this all means momentarily.

The beauty of this pattern is you can create a new class, for example, OracleForumsProvider, by deriving from the ForumsProvider base class and use Oracle as your data store. Or, if you prefer to continue using SQL Server, but wish to change the behavior of a single method, you can derive from SqlForumsProvider, override the method whose behavior you want to change, and then add that new class to the <providers> section of configuration. More simply put: the provider design allows developers to publish well-known APIs and also allows for a rich, enterprise-level extensibility model.

The following information comes directly from the provider specification for ASP.NET Whidbey.

Common Behaviors/Characteristics

Below is a listing of characteristics common to providers.

Base class

A base class should have as few methods and properties as possible. This is desirable to encourage developers to write providers.

Threading

Providers should be free-threaded/thread safe, with one instance per application domain. Any provider-specific objects created more frequently (for example, one per request) should be created through provider APIs.

Factory methods

The abstract base class should support factory methods to create new objects wherever appropriate, for example, CreateUser().

If a feature allows a provider to create a framework object, but does not allow the provider to extend the object, the framework class should be sealed.

Complex objects created by a provider may keep track of the provider that created it, and expose it as a Provider property. This allows users of the feature to determine the provider that owns the data for the object. For example, when a new user is created with the Membership API, it may be useful for the developer to be aware of the provider that data for the object is stored in.

Administration

The object model for ProviderCollection should include APIs to add, remove, and clear the collection and to set parameters of individual providers in the collection.

Every feature that has providers should have a Provider property that returns type ProviderCollection, for example, Membershp.Providers.

Class naming and namespaces

The specific provider base classes should be named [Feature]ProviderBase, for example, MembershipProviderBase.

Implementations should be named [ImplementationType][Feature]Provider, for example, SqlRoleManagerProvider.

Server controls that allow selection of a provider should have a property named Provider. This property should default to the value of the defaultProvider attribute in the related configuration section for the feature. For example, the new <asp:login/> server control's default provider is equivalent to the Membership default provider. The list of providers available to the login control is restricted by the providers defined for use in the <membership> section.

Common naming patterns for provider classes

Figure 5 below calls out some of the common names and casing that should be used for various data stores (where name is [Name][Feature]Provider).

Figure 5. Suggested prefixes for provider class names

For data stores that are not named above, the name value should be Pascal cased.

Configuring the default provider

All features that have providers must have a configuration section and should define a defaultProvider attribute. If a default provider is not specified, the first item in the collection is considered the default. For example:

<configuration>
  <system.web>
    <roleManager defaultProvider="AspNetSqlProvider" ...>

      <providers>

        <add name="AspNetWindowsProvider" 
             type="System.Web.Security.WindowsTokenRoleProvider, 
                    System.Web, 
             Version=1.2.3300.0, Culture=neutral, 
             PublicKeyToken=b03f5f7f11d50a3a"
             description=" description here " />

        <add name="AspNetSqlProvider"
             type="System.Web.Security.SqlRoleProvider, System.Web, 
             Version=1.2.3300.0, Culture=neutral, 
             PublicKeyToken=b03f5f7f11d50a3a"
             description=" description here "
             connectionStringName="[name in <connectionStrings/>" />

      </providers>
    </roleManager>
  </system.web>
</configuration>

Specifying a defaultProvider attribute is not required, although it is highly recommended. All ASP.NET providers will specify a defaultProvider attribute.

Provider-friendly name or dictionary key

When defining a provider within configuration, it is required for the name attribute to be defined. Furthermore, it is recommended that provider names follow a pattern to easily distinguish who owns the providers. The suggested pattern, and the pattern followed by the ASP.NET team is: [Provider Creator][Data Store]Provider.

For example, the Membership provider capable of storing data in SQL Server is:

<add name="AspNetSqlProvider"
    type="System.Web.Security.SqlRoleProvider, System.Web, 
    Version=1.2.3300.0, Culture=neutral, 
    PublicKeyToken=b03f5f7f11d50a3a"
    description = "ASP.NET SQL Server provider"
    connectionStringName="[name in <connectionStrings/>" />

It is important to note the friendly name of the provider when specified in configuration is distinct from the class name of the provider. The friendly name does not need to include the feature name, for example, Role, since the friendly name values are only usable within the context of the feature, for example, Roles.Providers["AspNetSqlProvider"]. The provider creator detail is added to distinguish between providers that may access similar data stores but pose differing behavior.

Provider type

When defining a provider within configuration, it is required for the type attribute to be defined. The type value must be a fully qualified type name following the format:

       type="[namespace.class], [assembly name], 
             Version=[version], Culture=[culture], 
             PublicKeyToken=[public token]"

For example:

       type="System.Web.Security.SqlRoleProvider, System.Web, 
             Version=1.2.3300.0, Culture=neutral, 
             PublicKeyToken=b03f5f7f11d50a3a"

The strongly typed name is desired, however, it is also legitimate to use the shorter style assembly type name:

       type="System.Web.Security.SqlRoleProvider, System.Web"
Expected APIs

Features that derive from the various provider base classes should follow the common pattern of supporting a Provider property and Providers collection property that allow the developer to access the default configured provider as well as the other providers specified in configuration. For example:

SqlMembershipProvider p = (SqlMembershipProvider) Membership.Provider;

AccessMembershipProvider a = 
(AccessMembershipProvider)Membership.Providers["AspNetAccessProvider"];

The Provider property and Providers collection allow for runtime access to the underlying Provider class instance. The Provider property returns the currently configured default provider, while the Providers collection returns a collection of all the available providers defined within configuration.

Use of <connectionStrings/>

All providers that require a connection to a database or require the use of a connection string to locate their data store should use the <connectionStrings/> section of configuration. Additionally, the name of the property on the provider should be connectionStringName with the value being the named value in <connectionStrings/>.

A connection string value is required; there cannot be an internal default.

For all providers shipped by Microsoft, it should not be possible to store a connection string in the provider definition. Rather the <connectionStrings/> section should be used. This will allow us to encrypt the connection string, further securing the application.

An exception will be thrown when a provider attempts to use a connection string obtained from <connectionStrings/> that either does not exist or is invalid.

Description attribute

Although not an explicit requirement for all providers, any providers created by Microsoft should have a description attribute. The description attribute should contain a brief, friendly description that can be displayed in the Web administration tool or other displays.

The description attribute is optional and it is not an error for the description attribute to be missing; empty string is assumed.

String comparisons

When any string comparisons are done from with the configuration system for providers, a culture-invariant string comparison is performed. This rule applies to the name value defined for providers.

Conceptual Specification

The conceptual specification section addresses common classes shared by all providers, the collection class used to manage providers, and rules for how providers are managed within a features configuration section.

ProviderBase

All providers derive from a common ProviderBase class. By supporting this common abstract base class, all providers additionally share a common base type.

namespace System.Configuration.Provider {
  abstract class ProviderBase {

    // Methods
    public abstract void Initialize(string name, 
      NameValueCollection config);

    // Properties
    public abstract string Name { get; }
  }
}

When a new instance of a provider is created, internally the Initialize() method is called. It is assumed that all provider instances will add additional functionality to the provider beyond ProviderBase, for example, MembershipProvider. However, all providers should still derive from ProviderBase.

Figure 6 Initialize method for ProviderBase

Figure 7. Name property of ProviderBase

Figure 8. Add method of ProviderCollection

Figure 9. Clear method of ProviderCollection

ProviderCollection

The ProviderCollection is a utility collection class used to manage classes that derive from ProviderBase. Features that implement providers can use the ProviderCollection to add, remove, or clear all providers. Internally, instances are cast to the correct type when a typed provider is needed.

namespace System.Configuration.Provider {

  public class ProviderCollection : IEnumerable {

    // Methods
    //
    public void Add(ProviderBase provider);
    public void Clear();
    public void Remove(string name);
    public void SetReadOnly(string name);

    // Properties
    //
    public ProviderBase this(string name) { get; set; }
    public int Count { get; set; }
  }

}

Figure 10. Remove method of ProviderCollection

Figure 11. SetReadOnly property of ProviderCollection

Figure 12. Add method of ProviderCollection

For example, when Membership.Providers["AspNetSqlProvider"] is requested, internally the following code is assumed:

public MembershipProvider this [string name] {

  get { return (MembershipProvider) providerCollection[name]; }

  ...
}
Configuration

Features that make use of providers must implement a <providers> configuration section within their feature's configuration slot. It is within the <providers> section that providers may be added, inherited providers may be cleared, or individual providers may be removed.

Providers are defined at the machine or application level. Providers cannot be defined in web.config files in application directories that are not application roots.

Setting the default provider

All features that have providers should have a defaultProvider attribute on the main configuration section. If a default provider is not specified, the first item in the collection is considered the default. For example:

<configuration>
  <system.web>
    <roleManager defaultProvider="AspNetWindowsProvider" ...>

      <providers>

        <add name="Windows" 
             type="System.Web.Security.WindowsTokenRoleProvider, 
                    System.Web, 
             Version=1.2.3300.0, Culture=neutral, 
             PublicKeyToken=b03f5f7f11d50a3a"
             description=" description here " />

        <add name="AspNetSqlProvider"
             type="System.Web.Security.SqlRoleProvider, System.Web, 
             Version=1.2.3300.0, Culture=neutral, 
             PublicKeyToken=b03f5f7f11d50a3a"
             description=" description here "
             connectionStringName="[name in <connectionStrings/>" />

      </providers>
    </roleManager>
  </system.web>
</configuration>
Managing providers in configuration: <providers>

The <providers> configuration section contains 0 or more <add>, <remove>, or <clear> elements. The following rules apply when processing these elements:

  1. It is not an error to declare an empty <providers /> element.
  2. Providers inherit items from parent application configuration <add> statements.
  3. It is an error to redefine an item using <add> if the item already exists or is inherited.
  4. It is an error to <remove> a non-existing item.
  5. It is not an error to <add>, <remove>, and then <add> the same item again.
  6. It is not an error to <add>, <clear>, and then <add> the same item again.

<clear> removes all inherited items and items previously defined. For example, an <add> declared before a <clear> is removed, while an <add> declared after a <clear> is not removed.

Figure 13. Add element for configuration

New providers are added using the <add> element nested beneath <providers>.

Figure 14. Remove element for configuration

Figure 15. Clear element for configuration

Conclusion

The provider model can help you design flexible and easily evolved APIs for your applications. In fact, today it's being used in the ASP.NET Forums (http://forums.asp.net) as well as DotNetNuke (http://www.dotnetnuke.com), both of which are ASP.NET 1.1 applications. In Part 2 of this article, we'll examine an implementation of this specification/pattern that you can begin using in your ASP.NET 1.1 applications.

After we conclude with the next provider article, we'll look at how to build a scalable database cache invalidation system for ASP.NET 1.1—something that many have tried, but few have succeeded with (I even had a stab at this about 3 years ago). If you've got other articles you'd like to see, let me know. My contact information is below.

工作日计算实战:法定节假日与调休补班的全语言实现 在项目排期、工单SLA统计、请假核算等场景中,计算两个日期之间的工作日天数远非“相减再扣周末”那么简单。法定节假日和调休补班机制打破了自然周的规律,直接按周一到周五过滤会导致结果与业务实际严重偏差。本文从“日历工作日”的定义出发,讲解如何区分自然工作日、法定放假日与调休补班日,并给出节假日数据的配置与存储方案。核心算法涵盖逐日遍历的稳妥实现与整周批量的高效优化,同时提供Java、Python、SQL等语言的落地代码。针对时区、跨年数据空窗、补班漏维护等常见坑点,也给出了实用的规避策略。无论是开发排期工具还是 阅读详情

相关推荐

蓝桥杯国赛真题深度解析:从动态规划到双向BFS的实战技巧

动态规划(DP)是解决最优化问题的核心算法范式,其原理在于将复杂问题分解为重叠子问题,并通过状态转移方程高效求解。在算法竞赛和工程优化中,DP的价值在于能以多项式时间复杂度解决指数级搜索空间的问题。图论中的广度优先搜索(BFS)则是解决最短路径、状态空间遍历的基础技术,其应用场景广泛,如网络路由、游戏AI和拼图求解。当状态空间爆炸时,双向BFS能通过从起点和目标同时搜索,将时间复杂度从O(b^d)降至约O(b^(d/2)),是应对大规模搜索问题的关键技术。本文以蓝桥杯国赛真题为例,深入剖析了带约束的完全背包

weixin_30764883的博客 411

Cursor 提示We‘re having trouble connecting to the model provider. This might be temporary - please try

今天在使用cursor时,突然提示We're having trouble connecting to the model provider. This might be temporary - please try again in a moment. 把我可吓得不轻,我刚冲完还没一周呢,我第一反应是不能用啦???? 后来总结出来的解决方案

xiaohua616的博客 3210

机器学习实战成长路线图:从环境配置到模型部署的七步实操指南

机器学习(ML)作为人工智能的核心分支,其本质是通过数据驱动的方式解决预测与决策问题。理解其原理需扎根于数学基础与编程实践,技术价值体现在将模糊业务需求转化为可量化、可迭代、可监控的模型服务。典型应用场景包括用户流失预测、智能推荐、异常检测与图像分类等。然而初学者常困于环境配置失败、特征工程无从下手、模型调参盲目低效等现实瓶颈。本文聚焦scikit-learn工程实践、Kaggle端到端项目闭环、Python数据处理肌肉记忆三大高频痛点,提供一条经1172天验证、43次复盘打磨的渐进式成长路径,覆盖从pip

cique2620的博客 515

雇工模式(Servant Design Pattern)。

定义 雇工模式也叫做仆人模式,其意图是: 雇工模式是行为模式的一种,他为一组类提供通用的功能,而不需要类实现这些功能,他是命令模式的一种扩展。 IServiced是用于定义“一组类”所具有的功能,其示例代码如下所示。 public interface IServiced { /** * 具有的特质或功能 */ void serviced(); } 针对不同的服务对象具备不同...

孤芳不自赏 881

SoC验证新思路:除了UVM仿真,你还可以试试Cadence JasperGold的形式化验证

本文深入探讨了Cadence JasperGold形式化验证在SoC设计中的创新应用,对比传统UVM仿真验证,详细解析了其数学穷尽性验证优势。通过实战案例展示了JasperGold在总线协议、时钟域交叉等关键场景的验证方法,并提供了混合验证流程设计与效能优化方案,帮助工程师提升验证效率30%以上。

weixin_30566063的博客 122

il2cpp分析-gobal-metadata.dat解密

打开ida,把libil2cpp拖到ida中按快捷键Shift+F12等待字符串分析完后,搜索global-metadata.dat。ida中双击sub_57EE7C进入,VS code中也跳转到LoadMetadataFile函数。VSCode打开il2cpp源代码,全局搜索global-metadata.dat。工具:010Editor,IDA 7.5,Jadx,VS Code。判断加密逻辑为根据文件的长度循环读取字节码做亦或加密。双击搜索出来的结果,切记要选il2cpp目录下的。

Android_machong的博客 8024

FreeMarker - 配置参数用法说明

【1】locale 作用: 设置默认地区,主要影响数字、日期输出格式,request中没有指定地区时模板查找的值。 值: zh_CN,en_US 配置实例: prop key="locale">zh_CNprop> 【2】classic_compatible 作用: 兼容旧版freemarker习惯,不建议使用,可能会导致一些额外的问题。如,include必须用绝

小小默:进无止境 5149

TIBCO Spotfire 入门指南

数据分析工具 - TIBCO Spotfire 入门指南(一) 文章目录数据分析工具 - TIBCO Spotfire 入门指南(一)前言一、Sportfire 是什么?二、使用Sportfire 创建一个简单的数据分析模型1.设置分析(加载数据)2.编辑数据源3.创建图表3.1 创建交叉表3.2 创建饼图3.3 创建树形图3.4 创建散点图3.5 创建自定义筛选器总结 前言 通过对本指南的学习,你可以了解到如何开始用TIBCO Sportfire分析数据,并能详细了解您可以做什么以及怎么做 一、Spo

kaiakai111的博客 1万+

在springboot中添加自定义TemplateResolver

我们都知道springboot的模板文件默认是在 classpath:templates/ 下面并且以.html结尾,但当在生产环境中我们需要动态的修改或替换某些模板文件时这样就不满足了, 这时就需要自定义一个TemplateResolver来解析我们的模板文件了,具体实现如下: 方法一(推荐): 这种方式继承了之前默认的配置,如下这种设置只需把模板文件与可执行jar文件放于...

SANDKING2015的博客 1533

【kubeEdge】离线部署

根据k8s的这个规则,可以将节点通过 label 的方式进行分组,比如将某几个节点都打上标签为 name=edge,当调度应用到 edge 节点时,会找到 label 为 edge 的所有节点,根据设置的副本数,将应用启动起来,如果设置的副本数超过了设置 edge 标签的节点数,则多出的将会显示 pending 状态,从而无法启动。清除 keadm init 或 keadm join 造成的影响均可使用 keadm reset,这个操作会删除 /etc/kubeedge 下的文件,如有需要请提前备份。

qq_42944740的博客 1716

Token算力工厂建设方案:从GPU集群到计量计费的全链路设计

在AI应用从“租核”走向“买Token”的范式转换中,算力交付的核心指标已不再是vCPU或GPU实例,而是单位时间内的Token产出量与单Token成本。这一变化推动基础设施从资源租赁向计件生产演进,要求GPU集群、推理引擎、调度系统、计量计费等模块像工厂产线一样协同运转。本文从硬件异构混部、存储网络设计、推理引擎调优、Token网关与配额管理、稳定性治理等维度,系统拆解如何构建一座可量化、可计费、可扩展的Token算力工厂,并给出分三期落地的推进节奏,帮助架构师与技术管理者在AI基础设施建设中实现成本可控

weixin_29095587的博客 265

vue中提示$index is not defined

今天学习Vue中遇到了一个报错信息:$index is not defined,是我写了个for循环在HTML中,然后是因为版本的问题 下面是解决方法: 原来的是 v-for="person  in  items"     v-on:click="deletePerson($index)"//这个仅仅适用于1.0版本,不要采坑了同学们 这个在Vue1.0版本中式

shaleilei的博客 1万+

【C#程序员入门AI】AI应用的操作系统:Semantic Kernel 2026实战

用户ID用户信息

人工智能AI技术 1251

计算一段日期内的周末天数(星期六,星期日总和)

/* | Author: Yang Yu | @param char|int $start_date 一个有效的日期格式,例如:20091016,2009-10-16 | @param char|int $end_date 同上 | @return 给定日期之间的周末天数

再见伍德 6899

Android CCodec (十七) 硬件解码调用分析-1(基于V4l2)

简单的分析V4L2DecodeComponent和其相关内容,后续针对解码调用单独分析。

给大佬递杯卡布奇诺的博客 6594

樽海鞘优化算法详解:原理、实现与应用

本文详细介绍了樽海鞘优化算法(SSA)的原理、实现与应用。该算法模拟樽海鞘链式群体行为,将优化问题解空间映射为群体移动空间,通过领导者引导和追随者跟随的协作机制寻找最优解。文章从生物特性、数学模型到Python代码实现进行了系统阐述,包括种群初始化、位置更新公式和收敛因子等核心要素,并展示了算法在函数优化等领域的应用潜力。该算法具有结构简单、参数少、实现容易等特点,在多种优化问题上表现良好。

qq_42212808的博客 646

计算一段日期内的周末天数的php代码(星期六,星期日总和)

就是取得开始日期的星期数,如果不足一周,则补上对应的天数,比如开始日期是星期3,那么总天数就补上2天(星期1,星期2),如果开始日期是星期6,则补上5天,也就是6-1,就是函数中的$start_N - 1,如果开始日期恰好是周日,那么补上6天的同时,最后的结果需要减去一天(周六),也就是函数中的 $start_reduce ,好了,现在“前补”解释完了。最后算一段时间内的天数,不建议用date(z)来算,因为通用性会不好,涉及到跨年的问题,如果跨多年,还要考虑闰年的问题,倒不如这样算来的直接。

邓草的博客 448

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

POJ 1698 网络流

讲每个任务以及每个星期的每一天zuo

I will Do iT @ hlyblog.net 1028

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

UVA 10050 - Hartals

UVA 10050 Hartals

坟头草一米七五 317

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

蓝桥杯2022年真题及答案

小明计划周一到周五每天做a道题目,周六和周日每天做b道题目,请你帮小明计算,按照计划他将在第几天是先做题数大于等于n题?

qq_62968038的博客 463

SAP工厂日历:不只是日历,而是生产计划的时间底层协议

工厂日历是SAP系统中定义‘工作日’与‘非工作日’的基础时间参照系,其本质是贯穿PP、MM、SD、FICO、EWM等模块的统一时间基准。它决定MRP运算中的日期推算逻辑、ATP可用性检查的交货日判定、工单排程的时段约束、固定资产按工作日计提折旧的财务规则,以及EWM任务触发的业务日边界。理解工厂日历,就是理解SAP如何将现实世界的班次、假日、检修等物理时间规则,映射为系统可执行的逻辑约束。尤其在MD07计划延迟、VL02N交货日校验失败等高频问题中,90%的根因都指向日历配置偏差或跨模块绑定不一致。

weixin_29587015的博客 370

POJ1698 最大流或者匈牙利

题意: 一个人他有n个任务,每个任务都有一些限制: (1)只能在一个星期中指定的日子去做,比如周1 2 6啥的 (2)总工作量有几天,就是一共要工作几天 (3)必须在几周之内完成,就是你可以在能干活的日子里面选择那天去干活,但是不能超过规定的星期。 然后问,是否可以不冲突的干完所有的活?...

墨鱼菜鸡 238

回归树入门:用‘如果…那么…’思维理解机器学习

回归树是机器学习中最基础、最可解释的预测模型,其核心思想是通过递归分组实现数值预测,而非依赖复杂数学公式。它基于业务决策逻辑,将连续目标变量按特征阈值离散化为多个局部均值,天然适配存在断点规则的实际场景(如运营时段、促销周期、天气阈值)。相比线性模型,回归树不假设数据平滑,更擅长捕捉隐性分段关系与非线性交互;其分裂准则(如方差最小)背后实为业务可解释性、数据稳定性与计算效率三重约束的平衡。作为XGBoost、随机森林等集成方法的基学习器,回归树既是可落地的独立工具,也是理解更复杂AI模型的思维起点。

weixin_33713503的博客 376

8月14日销量预测:Prophet时间序列模型实战教程

时间序列预测是业务决策中不可或缺的技术,它通过分析历史数据中的趋势、季节性和节假日效应,推断未来特定时间点的指标值。不同于普通回归,时间序列数据具有顺序相关性和自相关性,因此需要专门模型处理。Prophet作为Facebook开源的分解式预测模型,凭借其对节假日支持好、训练快、可解释性强的优势,成为业务指标预测的常用基线方案。在电商大促、活动上线等场景中,准确的销量预测能帮助团队提前规划库存与容量,避免资源浪费或系统过载。本文以预测8月14日销量为例,完整演示从数据准备、Prophet建模、结果评估到工程落

weixin_33981932的博客 433

生产级多维聚合实战:银行风控中的pandas工程化指南

多维聚合是数据分析的核心能力,本质是按多个维度组合对数据进行分组计算。其原理涉及分组索引构建、聚合函数并行执行与结果结构重塑,技术价值在于支撑高并发、低延迟、可审计的业务决策。典型应用场景包括金融客户分层、实时风险敞口计算、电商大促多维归因分析等。在真实生产环境中,必须应对维度爆炸、业务逻辑耦合、时间语义错位、下游系统适配等挑战。本文聚焦pandas多维聚合的工程化落地,结合银行级风控实践,详解多重agg、自定义函数封装、时间窗口锚定、unstack维度治理等关键技术,覆盖从原始交易日志到高管简报的完整链路

dihuangxiu8828的博客 317
下一篇: 在DataGrid的每一行中用图片的形式显示Edit和Delete的功能
brusehht
博客等级 码龄23年 0粉丝 18原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值