Compare commits
2 Commits
cc40dfd727
...
213ccf981c
| Author | SHA1 | Date |
|---|---|---|
|
|
213ccf981c | |
|
|
c735a74623 |
|
|
@ -349,7 +349,7 @@ export class Cache extends Feature {
|
|||
opers.forEach((oper) => {
|
||||
const { entity, operation } = oper;
|
||||
this.cacheStore.operate(entity, operation, this.context, {
|
||||
checkerTypes: ['logical'], // 这里不能检查data,不然在数据没填完前会有大量异常
|
||||
checkerTypes: ['logical'],
|
||||
dontCollect: true,
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { judgeRelation } from "oak-domain/lib/store/relation";
|
|||
import { Feature } from '../types/Feature';
|
||||
import { generateNewId } from 'oak-domain/lib/utils/uuid';
|
||||
export const MODI_NEXT_PATH_SUFFIX = ':next';
|
||||
const START_LSN = 100;
|
||||
function mergeOperation(schema, entity, oper1, oper2) {
|
||||
const { action, data } = oper2;
|
||||
const operMerged = cloneDeep(oper1);
|
||||
|
|
@ -90,7 +91,7 @@ class UpdateLogManager {
|
|||
constructor(schema, entity, maxLsn) {
|
||||
this.schema = schema,
|
||||
this.entity = entity,
|
||||
this.maxLsn = maxLsn || 0;
|
||||
this.maxLsn = maxLsn || START_LSN;
|
||||
}
|
||||
/**
|
||||
* 合并两个filter完全一致的更新
|
||||
|
|
@ -165,7 +166,7 @@ class UpdateLogManager {
|
|||
rollback(lsn) {
|
||||
const newLogs = this.logs.filter(ele => ele.lsn <= lsn);
|
||||
this.logs = newLogs;
|
||||
this.maxLsn = lsn;
|
||||
this.maxLsn = lsn || START_LSN;
|
||||
}
|
||||
makeOperations() {
|
||||
const opers = {};
|
||||
|
|
@ -1431,7 +1432,7 @@ class SingleNode extends Node {
|
|||
saveRefreshResult(data) {
|
||||
const ids = Object.keys(data);
|
||||
assert(ids.length === 1);
|
||||
this.id = ids[0];
|
||||
this.setId(ids[0]);
|
||||
this.sr = data[ids[0]];
|
||||
this.passRsToChild();
|
||||
// this.publish();
|
||||
|
|
@ -1743,7 +1744,7 @@ export class RunningTree extends Feature {
|
|||
this.nodeCountDict = {};
|
||||
this.pageNodeStack = {};
|
||||
this.singletonDict = {};
|
||||
this.logSerailNumber = 100;
|
||||
this.logSerailNumber = START_LSN;
|
||||
}
|
||||
increaseNodeCount(path) {
|
||||
if (!this.nodeCountDict[path]) {
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@ import { ActionDef } from '../types/Page';
|
|||
import { generateNewId } from 'oak-domain/lib/utils/uuid';
|
||||
|
||||
export const MODI_NEXT_PATH_SUFFIX = ':next';
|
||||
const START_LSN = 100;
|
||||
|
||||
type LegalOperation<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = ED[T]['CreateSingle']
|
||||
| ED[T]['Update']
|
||||
| ED[T]['Remove'];
|
||||
| ED[T]['Update']
|
||||
| ED[T]['Remove'];
|
||||
|
||||
type UpdateLog<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
||||
lsn: number;
|
||||
|
|
@ -26,7 +27,7 @@ type UpdateLog<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
|||
};
|
||||
|
||||
|
||||
function mergeOperation<ED extends EntityDict & BaseEntityDict, T extends keyof ED> (
|
||||
function mergeOperation<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(
|
||||
schema: StorageSchema<ED>,
|
||||
entity: T,
|
||||
oper1: LegalOperation<ED, T>,
|
||||
|
|
@ -130,7 +131,7 @@ class UpdateLogManager<ED extends EntityDict & BaseEntityDict, T extends keyof E
|
|||
constructor(schema: StorageSchema<ED>, entity: T, maxLsn?: number) {
|
||||
this.schema = schema,
|
||||
this.entity = entity,
|
||||
this.maxLsn = maxLsn || 0;
|
||||
this.maxLsn = maxLsn || START_LSN;
|
||||
}
|
||||
/**
|
||||
* 合并两个filter完全一致的更新
|
||||
|
|
@ -213,7 +214,7 @@ class UpdateLogManager<ED extends EntityDict & BaseEntityDict, T extends keyof E
|
|||
ele => ele.lsn <= lsn
|
||||
);
|
||||
this.logs = newLogs;
|
||||
this.maxLsn = lsn;
|
||||
this.maxLsn = lsn || START_LSN;
|
||||
}
|
||||
|
||||
makeOperations() {
|
||||
|
|
@ -1026,7 +1027,7 @@ class ListNode<
|
|||
|
||||
return operations.map(
|
||||
(operation) => {
|
||||
const { filter, ...rest} = operation;
|
||||
const { filter, ...rest } = operation;
|
||||
return {
|
||||
entity: this.entity,
|
||||
operation: {
|
||||
|
|
@ -1389,7 +1390,7 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
|||
if (id !== this.id) {
|
||||
const operations = this.ulManager.makeOperations();
|
||||
assert(operations.length <= 1);
|
||||
const [ operation ] = operations;
|
||||
const [operation] = operations;
|
||||
// 如果本身是create, 这里无视就行(因为框架原因会调用一次)
|
||||
if (operation?.action === 'create') {
|
||||
if (operation.data.id === id) {
|
||||
|
|
@ -1417,7 +1418,7 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
|||
}
|
||||
const operations = this.ulManager.makeOperations();
|
||||
assert(operations.length <= 1);
|
||||
const [ operation ] = operations;
|
||||
const [operation] = operations;
|
||||
if (operation && operation?.action === 'create') {
|
||||
return operation.data.id;
|
||||
}
|
||||
|
|
@ -1607,7 +1608,7 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
|||
this.ulManager.rollback(lsnMax);
|
||||
|
||||
assert(operations.length <= 1);
|
||||
const [ operation ] = operations;
|
||||
const [operation] = operations;
|
||||
|
||||
if (operation) {
|
||||
const { filter, ...rest } = operation;
|
||||
|
|
@ -1728,7 +1729,7 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
|||
saveRefreshResult(data: Record<string, any>) {
|
||||
const ids = Object.keys(data);
|
||||
assert(ids.length === 1);
|
||||
this.id = ids[0];
|
||||
this.setId(ids[0]);
|
||||
this.sr = data[ids[0]!];
|
||||
this.passRsToChild();
|
||||
|
||||
|
|
@ -1784,7 +1785,7 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
|||
|
||||
private getFilter(): ED[T]['Selection']['filter'] | undefined {
|
||||
// 如果是新建,等于没有filter
|
||||
const [ operation ] = this.ulManager.makeOperations();
|
||||
const [operation] = this.ulManager.makeOperations();
|
||||
if (operation?.action === 'create') {
|
||||
return;
|
||||
}
|
||||
|
|
@ -2107,7 +2108,7 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
this.nodeCountDict = {};
|
||||
this.pageNodeStack = {};
|
||||
this.singletonDict = {};
|
||||
this.logSerailNumber = 100;
|
||||
this.logSerailNumber = START_LSN;
|
||||
}
|
||||
|
||||
private increaseNodeCount(path: string) {
|
||||
|
|
@ -2802,7 +2803,7 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
|
||||
savePoint() {
|
||||
const lsn = this.logSerailNumber;
|
||||
this.logSerailNumber ++;
|
||||
this.logSerailNumber++;
|
||||
return lsn;
|
||||
}
|
||||
|
||||
|
|
@ -2812,7 +2813,7 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
* @param lsn 要清除到某个指定的savepoint,不设则完全清空
|
||||
* @param dontPublish
|
||||
*/
|
||||
clean(path: string, lsn?:number, dontPublish?: true) {
|
||||
clean(path: string, lsn?: number, dontPublish?: true) {
|
||||
const node = this.findNode(path)!;
|
||||
|
||||
node.clean(lsn, dontPublish);
|
||||
|
|
|
|||
Loading…
Reference in New Issue