Core Data Versioning How to migrate your Core Data persistent store

Hermes Agent安装与自我进化型AI智能体实战指南 AI智能体(AI Agent)是当前大模型落地的核心范式,其本质是具备感知、决策、执行与记忆能力的自主运行时系统。不同于传统提示工程或工作流编排工具,现代Agent强调长期存在性、跨会话状态保持与基于经验的技能沉淀能力。Hermes Agent作为2026年主流开源Agent Runtime,以‘自我进化’和‘桌面级开箱即用’为技术锚点,通过SOUL身份定义、Skill Ingestion经验沉淀、本地向量化技能路由等机制,实现无需人工调参的持续能力升级。它支持飞书、Telegram、CLI等多消息网关,适 阅读详情

Core Data Versioning

How to migrate your Core Data persistent store

by Marcus S. Zarra

Introduction

Core Data allows developers the ability to rapidly develop their applications with little worry about object persistence. By utilizing Core Data, developers can "future proof" their applications by taking advantage of the data migration functionality built into Core Data.

Core Data provides an infrastructure for object graph management and persistence. The basis for this infrastructure is often referred to as the Core Data "Stack". While the Xcode templates build this stack for us, it is important to understand how it works.

Building the stack

The Core Data stack is composed of three elements: a persistent store coordinator, a managed object model and a managed object context. In a non-document based application design, this stack is routinely initialized either as part of the start up of the application or lazily upon first request.

The Managed Object Model

It is unusual for an application to access the NSManagedObjectModel directly. Normally it is built upon initialization of the stack and only referenced via the NSManagedObjectContext. Generally, there are two ways to build the managed object model.

Listing 1: managedObjectModel

(1st implementation)

managedObjectModel
Return the existing managedObjectModel if it exists or create a new one.
- (NSManagedObjectModel*)managedObjectModel
{
   if (managedObjectModel) return managedObjectModel;
   NSString *path = [[NSBundle mainBundle] pathForResource:@"Model" 
      ofType:@"mom"];
   NSURL *url = [NSURL fileURLWithPath:path];
   managedObjectModel = [[NSManagedObjectModel alloc] 
      initWithContentsOfURL:url];
   return managedObjectModel;
}

In this first example, the model is built using the initWithContentsOfURL: initalizer of NSManagedObjectModel. This has the advantage of only loading the models that are appropriate. This is useful in many situations such as where it is possible that multiple data models may be in the application bundle. Having an export data model in the bundle is an example of this situation.

Listing 2: managedObjectModel

(2nd implementation)

managedObjectModel

Return the existing managedObjectModel if it exists or create a new one.
- (NSManagedObjectModel*)managedObjectModel
{
   if (managedObjectModel) return managedObjectModel;
   managedObjectModel = [[NSManagedObjectModel 
      mergedModelFromBundles:nil] retain];    
   return managedObjectModel;
}

This second example does not require knowledge of what models are available in the application bundle as it will grab every model available and load it into a single merged NSManagedObjectModel object. This choice allows the developer to easily add and remove models during development.

The persistent store is a representation of the model stored on the file system. Depending on the options chosen when the store was built, it can be in a SQLite database, XML, binary or a custom file format. The persistent store is responsible for serializing all access to the data stored on the file system. Therefore only one persistent store should ever be initialized per file.

When the stack is being initialized, the store accepts a NSManagedObjectModel and a url for the location of the store on the filesystem.

Listing 3: persistentStoreCoordinator

persistentStoreCoordinator

Return the existing NSPersistentStoreCoordinator. If there is not one then initialize a new one with the NSManagedObjectModel from the -managedObjectModel method and adding a xml based persistent store to it.

- (NSPersistentStoreCoordinator*)persistentStoreCoordinator 
{
   NSError *error = nil;
   NSFileManager *fileManager = [NSFileManager defaultManager];
   NSString *path = [self applicationSupportFolder];
   if (![fileManager fileExistsAtPath:path isDirectory:NULL] ) {
      if (![fileManager createDirectoryAtPath:path attributes:nil]) {
         return nil;
      }
   }
   path = [path stringByAppendingPathComponent:@"Example.xml"];
   
   NSURL *url = [NSURL fileURLWithPath:path];
   NSManagedObjectModel *model = [self managedObjectModel];
   if (!model) return nil;
   id psc = [[NSPersistentStoreCoordinator alloc] 
      initWithManagedObjectModel:model];
   if (![psc addPersistentStoreWithType:NSXMLStoreType configuration:nil 
      URL:url options:nil error:&error]) {
      [[NSApplication sharedApplication] presentError:error];
      return nil;
   }       
   return [psc autorelease];
}

Those familiar with building Core Data document based applications will notice quite a bit of a difference with the construction of the NSPersistentStoreCoordinator. Instead of accepting a path coming into the method, the path is constructed from the application support directory. The application support directory is the recommended location for storing application specific data for non-document based applications.

After the NSPersistentStoreCoordinator is initialized, the next step is to add the persistent store to the coordinator. It should be noted that it is possible to add more than one persistent store to the coordinator. Finally the newly created NSPersistentStoreCoordinator is returned to the calling method.

The Managed Object Context

The last step in building the stack, and the first step from the calling methods point of view is the NSManagedObjectContext.

Listing 4: managedObjectContext

managedObjectContext

Return the existing NSManagedObjectContext. If one does not exist, then create it using the persistent store from the -persistentStoreCoordinator method.

- (NSManagedObjectContext*)managedObjectContext 
{
   if (managedObjectContext) return managedObjectContext;
   NSPersistentStoreCoordinator *psc = [self persistentStoreCoordinator];
   if (!psc) return nil;
   managedObjectContext = [[NSManagedObjectContext alloc] init];
   [managedObjectContext setPersistentStoreCoordinator:psc];
   return managedObjectContext;
}

This method simply retrieves a reference to the NSPersistentStoreCoordinator, initializes a new NSManagedObjectContext and sets the retrieved NSPersistentStoreCoordiantor on the NSManagedObjectContext.

Handling Migration

One of the biggest challenges with Core Data is the migration of the store from one version to another. As applications evolve, the data model invariably changes. Prior to OS X 10.5 Leopard, the developer was required to handle these migrations manually. However, starting with Leopard, migration is handled directly by Core Data.

Versioning the Data Model

The first time that the data model needs to be revised it needs to be converted from a "xcdatamodel" file to a "xcdatamodeld" bundle. This is done by selecting Add Model Version with the current model selected.



Figure 1: Adding a Model Version

This will create a xcdatamodeld bundle with the same name as the data file and it will create a copy of the original data model. Both the original data model and the copy will be inserted into the xcdatamodeld bundle. It is recommended to rename the model files for clarity.



Figure 2: The xcdatamodeld structure

Once this is completed, both xcdatamodel files will be added to the application bundle. After the application has been complied there will be a new directory under Resources called "Example_DataModel.momd" which includes both of the complied mom files.

Writing the Mapping Model

For a data migration to occur, a NSMappingModel object is required. This object describes how the data is migrated from one model to another. This object is normally constructed from within XCode with the mapping model editor.

In the current implementation of Core Data, one mapping model is required for each combination of source and destination models. Therefore careful consideration should be used when creating a new version of a data model.

Using a custom NSEntityMigrationPolicy

While the NSMappingModel and its editor can handle a wide range of data migration needs, it does not cover every possible situation. When a migration goes beyond the abilities of the NSMappingModel, it is possible to extend it with custom subclasses. This is normally accomplished by subclassing the NSEntityMigrationPolicy object and using that subclass for one or more objects in the NSMappingModel.

Sample application: ToDo List

The Basic Application Design

The ToDo list will have two objects. The first object will be a list of todo items that are to be displayed to the user. The second object is a list of possible categories for the todo items. The resulting model is as follows:



Figure 3: The data model

Adding the Core Data Stack

Initializing the stack on startup

Since this application will want to access the core data stack immediately to display the ToDo items, I am going to pre-load the ToDo items from the persistent store. To accomplish this, I have added a -applicationDidFinishLaunching: method as follows.

Listing 5: applicationDidFinishLaunching

applicationDidFinishLaunching

Delegate method that is called by the NSApplication once the application has finished start up. Loads the core data objects into memory by doing a retrieval on startup.

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
   NSManagedObjectContext *moc = [self managedObjectContext];
   NSFetchRequest *request = [[NSFetchRequest alloc] init];
   [request setEntity:[NSEntityDescription entityForName:@"ToDo" 
      inManagedObjectContext:moc]];
      
   NSError *error = nil;
   [moc executeFetchRequest:request error:&error];
   if (error) {
      NSLog(@"%@:%s Error retrieving ToDo items:\n%@", [self class], _cmd, 
         error);
   }
}

In this method, I am forcing the core data stack to be initialized and then I am retrieving all of the ToDo items. This will cause them to be in memory and available for the user interface when it is presented to the user.

Saving the stack on shutdown

Since this application has only one core data stack it is unnecessary to force the user to save their changes manually. Therefore the application itself needs to handle saving automatically on exit. To do this, the application delegate needs to implement -applicationShouldTerminate: and handle saving.

Listing 6: applicationShouldTerminate

applicationShouldTerminate

Called by the NSApplication just before it is going to quit. This will attempt to save the NSManagedObjectContext or will abort the termination if an error occurred.

- (NSApplicationTerminateReply)applicationShouldTerminate:(id)sender
{
   if (!managedObjectContext) return NSTerminateNow;
   if (![managedObjectContext commitEditing]) return NSTerminateCancel;
   if (![managedObjectContext hasChanges]) return NSTerminateNow;
      
   NSError *error = nil;
   if ([managedObjectContext save:&error]) return NSTerminateNow;
      
   if ([[NSApplication sharedApplication] presentError:error]) {
      return NSTerminateCancel;
   }
   int alertReturn = NSRunAlertPanel(nil, 
      @"Could not save changes while quitting. Quit anyway?" , 
      @"Quit anyway", @"Cancel", nil);
   if (alertReturn == NSAlertAlertnateReturn) {
      return NSTerminateCancel;
   }
   return NSTerminateNow;
}

When the application is told to quit it will attempt to save the Core Data stack to disk if at all possible and will warn the user if a failure occurred.

Building the UI

The user interface for this application should present the user a list of ToDo items that can be selected, edited, and deleted. While categories are available, there is no need to present those as editable in the main window. This will help to focus the user's attention on the ToDo list itself rather than the details of the relationship between Categories and ToDo items. However, the user will need to edit the categories, therefore I will add a panel that can be accessed from the window menu.

Designing the main window

The main window should be a simple master/detail view. Using the latest version of Interface Builder, drag the Core Data Entity object from the library onto the main window. From there select the ToDo entity from the list and select the master/detail option. Once the UI has been created, change the plain NSTextField for the date to a Date Picker and removed the category from the table view. The resulting UI can be seen in Figure 4.



Figure 4: The Main Window

Designing the category edit window

The design of the category panel is almost identical to the main window. To start with add a panel from the library in Interface Builder. Then add a menu item to the window menu called Categories. Next, bind the menu item to the makeKeyAndOrderFront: method on the category panel.

Again using the Core Data library item but selecting Category instead of ToDo in the entity list, the resulting panel is shown in Figure 5.



Figure 5: The Category Edit Window

Accessing Core Data from InterfaceBuilder

Although the Core Data object does all of the bindings for us, it is important to understand how all of this is connected. Looking at the objects in the MainMenu.xib file, you can see that the Core Data library object added two Array Controllers: one for ToDo and one for the Categories.



Figure 6: MainMenu.xib

Selecting either one of these NSArrayControllers and inspecting its bindings will reveal that it is bound to the NSManagedObjectContext inside of the Application's delegate object.

Looking at the attributes tab of the inspector for either of these Array Controllers will reveal that they are defined to display a specific Core Data Entity. This information is used to populate the array directly from the NSManagedObjectContext when the xib is loaded and initialized.

Accessing the ToDo list from code for alerts

A ToDo list application is not very useful unless it can alert the user to a pending ToDo item. Therefore we want to wake up once per minute and look for any pending items and let the user know. However we do not want to notify users of items that are far into the future so it will need to filter the results.

The first change is in the -applicationDidFinishLaunching: method to start a timer that will fire every minute.

Listing 7: Scheduling an NSTimer

[NSTimer timerWithTimeInterval:]

Schedule a timer to fire every 60 seconds and call the -minuteTimerFired: method.

minuteTimer = [NSTimer timerWithTimeInterval:60.0 target:self  selector:@selector(minuteTimerFired:)  userInfo:nil repeats:YES];

This timer will cause the -minuteTimerFired: method to be called every minute. We should also invalidate this timer in the -dealloc method.

Listing 8: Invalidate an NSTimer

[NSTimer invalidate]

Invalidate the NSTimer so that it will no longer fire and will release itself from memory.

[minuteTimer invalidate], minuteTimer = nil;

Calling -invalidate on the timer will cause it to stop firing and release itself. To be safe from future edits set the reference to the timer to nil.

Using an NSPredicate to filter results

When the -minuteTimerFired: is called, all ToDo items that are due in the next five minutes need to be located. If one or more ToDo items that match that criteria are found, you want to display them to the user.

Listing 9: minuteTimerFired:

minuteTimerFired:

Called by the NSTimer every 60 seconds, will check for any ToDo items that are scheduled within the next five minutes.

- (void)minuteTimerFired:(id)sender
{
   NSDate *now = [NSDate date];
   NSDate *later = [now addTimeInterval:(60.0 * 5)];
   NSManagedObjectContext *moc = [self managedObjectContext];
   NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
   [request setEntity:[NSEntityDescription entityForName:@"ToDo" 
      inManagedObjectContext:moc]];
   NSString *ps = @"dueDate >= %@ AND dueDate <= %@";
   NSPredicate *pred = [NSPredicate predicateWithFormat:pred, 
      now, later];
   [request setPredicate:pred];
   NSError *error = nil;
   NSArray *itemsThatAreDue = [moc executeFetchRequest:request 
      error:&error];
   if (error) { //Error retrieving the todo list
      [[NSApplication sharedApplication] presentError:error];
      return;
   }
   if ([itemsThatAreDue count] == 0) return; //No due items
   [alertItems setContent:itemsThatAreDue];
   [alertWindow makeKeyAndOrderFront:self];
   NSApplication *sa = [NSApplication sharedApplication];
   [sa requestUserAttention:NSInformationalRequest];
}

When the timer fires, you want to first get the current date and then create a second date object set to 5 minutes from now. With those two dates initialized it is time to find all of the matching ToDo items.

Using a NSFetchRequest item, set the entity and, add a NSPredicate to the NSFetchRequest. The predicate will filter the ToDo items down to all of the items that have a dueDate after now and before 5 minutes from now.

Using the completed NSFetchRequest, retrieve all of the ToDo items from the NSManagedObjectContext and set the resulting NSArray as the content for the NSArrayController that handles the alert window and call -makeKeyAndOrderFront: on the alert window. To let the user know that the window has changed, a call to [[NSApplication sharedApplication] requestUserAttention:NSInformationalRequest] will cause the application's dock icon to bounce for 1 second.

Updating the data model and managing versioning

Using this application for a few minutes will quickly expose a few flaws. First, for a ToDo item that is due in 5 minutes the user will be alerted 5 times. In addition, there is no way to tell the application to avoid alerting for a particular ToDo item. To correct these issues an update to the data model is required.



Figure 7: Version 2 Data Model

The new data model introduces two new attributes on the ToDo entity: lastAlertDate and doNotAlert.

Once the new model is built, the current data model version needs to be set in XCode. This is done by selecting the version 2 model and choosing Set Current Version under the design menu.

Basic migration with the built in mapping model

To get core data to migrate the data, two changes are required. First, the persistent store needs to be told to attempt automatic migration. This is an option that is added when the persistent store is added to the coordinator.

Listing 10: persistentStoreCoordinator (modified)

persistentStoreCoordinator

Updated section of the persistentStoreCoordinator method that includes a NSDictionary instructing Core Data to attempt an automatic data migration.

id psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
    
NSMutableDictionary *options = [NSMutableDictionary dictionary];
[options setValue:@"YES" forKey:NSMigratePersistentStoresAutomaticallyOption];
    
if (![psc addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:options error:&error]) {
   [[NSApplication sharedApplication] presentError:error];
   return nil;
}

With this change, Core Data will attempt to find a source model that matches the persistent store and a mapping model that will describe how to migrate the data from the source model to the current model.

The next step is to build the mapping model that will describe the migration. To do this, create a new file in Xcode and selected the Mapping Model template. Then set the Version 1 model as the source and the Version 2 model as the destination for the map. Upon creation, Xcode makes an effort to create the mapping model. For this migration the default is sufficient so no additional work is required.

To expose the Do Not Alert option to the user, add another checkbox to the main window next to the completed checkbox and bind it to the doNotAlert attribute. Lastly, update the -minuteTimerFired: method to use these new attributes.

Listing 11: minuteTimerFired (modified)

minuteTimerFired

Modification to the method to set the last alert time on a ToDo item to avoid repeated alerts.

- (void)minuteTimerFired:(id)sender
{
   NSDate *now = [NSDate date];
   NSDate *later = [now addTimeInterval:(60.0 * 5)];
   NSDate *before = [now addTimeInterval:0 - (60.0 * 5)];
   NSManagedObjectContext *moc = [self managedObjectContext];
   NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
   [request setEntity:[NSEntityDescription entityForName:@"ToDo" 
      inManagedObjectContext:moc]];
   [request setPredicate:[NSPredicate predicateWithFormat:@"dueDate >= %@ 
      AND dueDate <= %@ AND doNotAlert == NO AND (lastAlertDate == nil || 
      lastAlertDate < %@", now, later, before]];
   NSError *error = nil;
   NSArray *itemsThatAreDue = [moc executeFetchRequest:request 
      error:&error];
   if (error) { //Error retrieving the todo list
      [[NSApplication sharedApplication] presentError:error];
      return;
   }
   if ([itemsThatAreDue count] == 0) return; //No due items
   [alertItems setContent:itemsThatAreDue];
   [alertWindow makeKeyAndOrderFront:self];
   [[NSApplication sharedApplication] 
      requestUserAttention:NSInformationalRequest];
   [itemsThatAreDue setValue:now forKey:@"lastAlertDate"];
}

An unusual migration using a custom policy

A common situation is where the migration of data from one model to another is beyond the scope of the standard NSMappingModel. For example, setting the doNotAlert bit to YES on all ToDo items that start with A. When the migration requirements stray outside of the default mapping, it is possible to build a custom migration policy. This requires subclassing NSEntityMigrationPolicy and implementing one of several methods that will be called during the migration processing. For this example, only one of the NSEntityMigrationPolicy object's methods need to be overridden.

Listing 12: createDestinationInstancesForSource-Instances

createDestinationInstancesForSourceInstances

Called during the migration process and adds custom logic to the migration so that ToDo items that start with the letter A are flagged as DoNotAlert.

- (BOOL)createDestinationInstancesForSourceInstance:(NSManagedObject*)src ¬
entityMapping:(NSEntityMapping*)map manager:(NSMigrationManager*)mgr error:(NSError**)error
{
  NSManagedObjectContext *destMOC = [mgr destinationContext];
  NSString *destEntityName = [map destinationEntityName];
  
  NSString *name = [source valueForKey:@"name"];
  NSManagedObject *dest = [NSEntityDescription insertNewObjectForEntityForName:destEntityName ¬
inManagedObjectContext:destMOC];
  
  NSArray *keys = [[[source entity] attributesByName] allKeys];
  NSDictionary *values = [source valuesForKeys:keys];
  
  [dest setValuesForKeysWithDictionary:values];
  if ([[name lowercaseString] hasPrefix:@"a"]) {
    [dest setValue:@"YES" forKey:@"doNotAlert"];
  }
  [manager associateSourceInstance:src withDestinationInstance:dest forEntityMapping:map];
  
  return YES;
}

From the passed in NSMigrationManager it is possible to get a reference to the destination NSManagedObjectContext and then construct the destination NSManagedObject. In this example the change from the source object are trivial so you can copy the attributes directly from the source. The two new attributes, doNotAlert and lastAlertDate are either optional or contain default values so there is no need to alter them. After the destination object has been populated comes the custom logic that this subclass was built for. Using the name from the source, check to see if it starts with the letter a and if it does, then set the doNotAlert attribute to YES.

Since the Category object retains a reference to the ToDo lists, it is not necessary to manage the relationship between the two objects in this policy. However, if it were needed, then you would need to implement the -createRelationshipsForDestinationInstance: entityMapping: manager: error: method.

Conclusion

Since the introduction of Core Data in OS X 10.4 Tiger, data migration within Core Data has come a long way. In one OS X update we have moved from migration being an afterthought that developers tacked on when it was needed to migration becoming a first class citizen with a robust real world solution.

I would highly recommend that anyone who is now targeting OS X 10.5 Leopard for their applications to start using the build in migration tools of Core Data as opposed to a home grown solution.



PS:Orignal text have some image ,please link "http://www.mactech.com/articles/mactech/Vol.25/25.03/CoreDataVersioning/index.html"

ActiveMQ与JMS消息队列实战指南 消息队列作为分布式系统解耦的核心组件,通过异步通信机制实现服务间松耦合。JMS(Java Message Service)是Java平台的标准消息API规范,而ActiveMQ作为其流行实现,支持点对点(Queue)和发布订阅(Topic)两种消息模型。在电商秒杀、订单处理等场景中,消息队列能有效削峰填谷,保证系统稳定性。本文以Spring Boot集成ActiveMQ为例,详细演示了Docker环境部署、消息生产消费、事务管理、死信队列等实战技巧,并提供了性能监控与调优方案,帮助开发者构建高可靠的消息驱动 阅读详情

相关推荐

Spark读取Kafka因为序列化引起的问题:org.apache.spark.sql.streaming.StreamingQueryException: null

背景 从kafka读取数据然后写入到kafka,但是报错,公司的插件化开发,这里手写代码复现一下这个错误 @Test def kafkaToKafkaTest(): Unit ={ val spark = SparkSession.builder.appName("JavaStructuredKafka").master("local[4]").enableHiveSupport...

九师兄 2202

pyspark 链接mongoDB 时报错 (Class not found exception:com.mongodb.spark.sql.DefaultSource)解决方法

18/05/08 11:18:39 INFO StateStoreCoordinatorRef: Registered StateStoreCoordinator endpoint Traceback (most recent call last): File "/home/cisco/spark-mongo-test.py", line 7, in &lt;module&g...

liuhongyue的博客 3357

【信息科学与工程学】【数据中心】 第二十三篇【智算中心】DDC网络-满足大规模训练、推理、存储区网络(Roce2组网)-01

设计维度目标值设计原则实现手段评估指标性能目标​端到端延迟<10ms低延迟优先RDMA优化,拓扑扁平化延迟分布,p99延迟可用性目标​99.99%可用性冗余设计多路径,设备冗余MTBF,MTTR吞吐目标​核心交换>10Tbps无阻塞交换大带宽核心,Clos架构对分带宽扩展性目标​线性扩展至1000节点模块化设计标准Pod架构扩展成本函数安全目标​零信任架构纵深防御微分段,加密传输安全事件数能效目标​PUE<1.2绿色计算高效设备,智能调度能效比(W/IOPS) 2. 物理拓扑设计 2.1 数据中心物理

weixin_49199313的博客 561

org.apache.spark.sql.AnalysisException: Table or view not found

IDEA运行Hive语句错误,报错信息如下 org.apache.spark.sql.AnalysisException: Table or view not found select * from qfbap_dws.dws_user_visit_month1 19/01/11 19:33:03 INFO SharedState: loading hive config file: file:/...

Mr Huo 1万+

【信息科学与工程学】计算机科学与自动化 第二百三十三篇 凤凰架构02

① Firecracker 为每个 microVM 提供极简设备模型:virtio-net, virtio-blk, serial console。:① BB84:Alice 随机选择基矢(+ 或 ×)发送单光子,Bob 随机测量基矢,比对后保留一致位的子集作为原始密钥。:密度 1 EB/mm³;:① Parquet 文件:行组(Row Group)→ 列块(Column Chunk)→ 页(Page)。

weixin_49199313的博客 136

【信息科学与工程学】【数据中心】第三十五篇 云计算数据中心的学科知识04

编号学科(课程)核心知识点在云计算/云存储/云网络/云安全/云MaaS中的作用代表教材/资料/论文 + 数学方程式列表工业界应用D1421​云原生数据库:TiDB​HTAP(混合事务/分析处理)、分布式SQL、水平扩展、强一致(Raft)、自动故障恢复、与MySQL兼容、TiFlash列式引擎提供弹性扩展的分布式数据库;支撑高并发在线交易与实时分析教材:《TiDB in Action》PingCAP(2020) 论文:《TiDB: A Raft-based HTAP Database》(2017)

weixin_49199313的博客 403

spark遇到的一些问题及其解决办法

1. ERROR org.apache.spark.storage.DiskBlockObjectWriter: Uncaught exception while reverting partial writes to file /home/work/hdd9/yarn/ttttt-hadoop/nodemanager/usercache/s_sales/appcache/application_1597370851926_759263/blockmgr-7aa07b85-2ee1-4b1b-9eb1-62

1万+

【信息科学与工程学】计算机科学与技术——第七十七篇 系统架构设计02

编号类型模型配方企业资本运作的方法/规则/条件/依据及所有的步骤(​风险处理/异常处理/危机应对关联知识法律法规和裁决依据​​由发起人(通常是知名投资人、投行或产业资本)先设立一个只有现金、无实际业务的特殊目的收购公司(SPAC),通过IPO募集资金并在交易所上市。然后在规定时间内(通常24个月)寻找一家非上市公司进行合并(De-SPAC),使目标公司迅速实现上市,规避传统IPO的复杂流程和不确定性。1.:在开曼或特拉华注册空壳公司,注入少量种子资金。2.

weixin_49199313的博客 313

Unity集成SQLite实战:五大核心问题与跨平台解决方案

在游戏与应用开发中,本地数据存储是基础且关键的技术环节。SQLite作为一款轻量级、嵌入式的关系型数据库,因其无需独立服务器、单文件存储的特性,成为移动端与单机应用数据管理的首选方案。其核心原理是通过C语言库提供数据操作能力,在Unity等C#环境中需通过.NET封装进行调用。这一技术组合为开发者带来了便捷的结构化数据管理能力,尤其适用于玩家存档、游戏配置、排行榜等场景。然而,在实际工程实践中,跨平台部署、多线程安全、数据迁移等挑战直接影响应用的稳定性与性能。本文将聚焦Unity与SQLite集成时最常见的

weixin_34037515的博客 356

【信息科学与工程学】计算机科学与自动化—第十五篇 云计算 11 算法篇01

编号类型领域问题问题的数学分析(含几何学/拓扑学/代数学/数论/集合论/离散数学/概率论/统计学/其他)及数值分析及算法分析及参数列表及参数数值设计C/C++/rust/python代码软件(含编译器)及硬件资源需求(CPU/GPU/内存【NAND/DRAM/HBM/其他】/HBM、HDD、SSD、RAID卡、其他)关联知识1工作负载调度数据中心最小化总完成时间/成本。

weixin_49199313的博客 218

【信息科学与工程学】【安全领域】第八十三篇 云安全解决方案02

企业中“搞人”与“搞事情”常见问题的分析框架。我将选取4个典型场景,每个场景都从实际管理现象出发,逐步推导出数学模型、参数设定及关联知识。

weixin_49199313的博客 323

【信息科学与工程学】【通信工程】第一百五十五篇 网络拓扑学09

聚焦云数据中心(多region多AZ+多边缘DC)与城域网5G/6G网络一体化的拓扑学编号类型领域问题问题的数学分析(拓扑学+其他)参数列表及参数的数值范围关联知识A166图论/组合优化云原生数据湖如何用Apache Hudi的Timeline拓扑优化增量查询?​1. 拓扑学分析(详细): - 拓扑结构:Apache Hudi使用Timeline管理表的历史变更,Timeline是一个时间轴上的DAG。每个Instant(提交、 compaction、 cleaning等)是一个节点,节点之间按时间顺

weixin_49199313的博客 222

【信息科学与工程学】计算机科学与自动化—第十五篇 云计算 11 算法篇02

但若第一个应用需求40GB/s,第二个10GB/s,总需求50GB/s>40GB/s,第一个得32GB/s,第二个得8GB/s,不公平。但若分区负载不均(分区1-2各有100任务/s,分区3-4各有50任务/s),A负责1-2(200/s),B负责3-4(100/s),仍均衡。任务 τi​ 的计算需求 Wi​(CPU周期),在频率 f 下执行时间 Ti​=Wi​/f,能耗 Ei​=Pdyn​⋅Ti​=Ceff​⋅V2⋅f⋅(Wi​/f)=Ceff​⋅V2⋅Wi​。若 Mneed​>Mi​,需使用远程显存。

weixin_49199313的博客 107

【信息科学与工程学】计算机科学与自动化——第八十四篇 C++分布式软件高并发/高可用算法01

4. 提交:协调者选择提交时间戳(>所有读时间戳),两阶段提交:a) 写意图预提交到所有参与者,b) 参与者持久化后确认,c) 协调者决定提交,异步清理意图。:客户端请求发送到协调节点,协调节点根据路由转发到主分片所在节点。Span有父子关系。1. 索引文档:客户端发送PUT请求到协调节点,协调节点路由到主分片节点,主分片写入本地,然后并行复制到副本分片,等待确认后响应客户端。3. 搜索:客户端发送搜索请求到协调节点,协调节点广播到所有相关分片,每个分片执行查询,返回结果,协调节点合并、排序、分页后返回。

weixin_49199313的博客 1079

【信息科学与工程学】计算机科学与自动化——第三百零四篇 高性能系统开发指南01

高并发:限流、熔断、降级高性能:红包拆分、多级缓存、大Key/热Key拆分、Pipeline、线程池、RocketMQ零丢失、幂等、分布式锁、集群缩容、分批入库海量数据处理:日志分表分片、跨表查询、冷热分层、大数据引擎服务器选型系统安全:网关安全、服务器安全、云存储安全、风控、监控、测试数据一致性:缓存与数据库一致性、大厂方案、蓝绿回滚、流量一致性、流程一致性项目与团队管理:流程问题、管理问题(风险、成本、人员、文档、培训)稳定性建设:上线三板斧、线上五步闭环、混沌工程、容量规划。

weixin_49199313的博客 249

【信息科学与工程学】计算机科学与自动化——第三百零五篇 数据中心 Scale-Up、Scale-Out、Scale-Across 18

普通CDN在遭遇50Gbps攻击时,节点瘫痪率高达70%。云化安全CDN的零信任模型通过将动态身份验证、最小权限访问与CDN的分布式加速能力深度集成,实现安全与性能的协同优化。云化的安全CDN(如腾讯云EdgeOne)与普通的安全CDN在架构、功能、性能和适用场景上存在显著差异。某视频平台接入腾讯云EdgeOne+零信任方案后,全球平均延迟降至46ms,攻击拦截率99.97%,验证了协同模型在高并发场景的普适性。​:随着边缘计算普及,云化安全CDN将逐步取代传统方案,成为高交互、高安全场景的标配基础设施。

weixin_49199313的博客 1698
上一篇: Thead 1:proogram received signal:"SIGABRT" 错误
下一篇: @property
ch_soft
博客等级 码龄17年 828粉丝 166原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值