durable_rules 2.0.10 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/src/rules/events.c +34 -35
- data/src/rules/rete.c +40 -12
- data/src/rules/rete.h +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dcf2ede6d2bd9909805f783b0bf914cd85c4c8e
|
4
|
+
data.tar.gz: 5d614d930ce359ac46d0ff33b76c64dc3004840e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a51d1872c5ac2696591a5aea0a75a84c5176a067e157ae69d8a9c506227910bc9111a75b90b2bf6299272b52c4d1d278ed46b7629ca9a3412256dd203d31899f
|
7
|
+
data.tar.gz: 9972206de9323de12674942bc4993d022fb0808f7be3559fa62ff468bb61e1ba87c25a4516e15025c8996701603e64cf1e2c0cb15aebc2839cb85289eff3ac30
|
data/src/rules/events.c
CHANGED
@@ -1449,7 +1449,7 @@ static unsigned int isNextMatch(ruleset *tree,
|
|
1449
1449
|
}
|
1450
1450
|
}
|
1451
1451
|
}
|
1452
|
-
|
1452
|
+
|
1453
1453
|
if (currentAlpha->nextOffset) {
|
1454
1454
|
unsigned int *nextHashset = &tree->nextPool[currentAlpha->nextOffset];
|
1455
1455
|
for(unsigned int propertyIndex = 0; propertyIndex < jo->propertiesLength; ++propertyIndex) {
|
@@ -1532,8 +1532,8 @@ static unsigned int isArrayMatch(ruleset *tree,
|
|
1532
1532
|
last - first + 1));
|
1533
1533
|
}
|
1534
1534
|
|
1535
|
-
if (arrayAlpha->
|
1536
|
-
unsigned int *nextList = &tree->nextPool[arrayAlpha->
|
1535
|
+
if (arrayAlpha->arrayListOffset) {
|
1536
|
+
unsigned int *nextList = &tree->nextPool[arrayAlpha->arrayListOffset];
|
1537
1537
|
for (unsigned int entry = 0; nextList[entry] != 0; ++entry) {
|
1538
1538
|
node *listNode = &tree->nodePool[nextList[entry]];
|
1539
1539
|
jsonProperty *currentProperty;
|
@@ -1553,45 +1553,44 @@ static unsigned int isArrayMatch(ruleset *tree,
|
|
1553
1553
|
|
1554
1554
|
}
|
1555
1555
|
}
|
1556
|
-
}
|
1556
|
+
}
|
1557
1557
|
|
1558
|
-
if (!*propertyMatch) {
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
if (
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
}
|
1558
|
+
if (!*propertyMatch && arrayAlpha->arrayOffset) {
|
1559
|
+
unsigned int *nextHashset = &tree->nextPool[arrayAlpha->arrayOffset];
|
1560
|
+
for(unsigned int propertyIndex = 0; propertyIndex < jo.propertiesLength; ++propertyIndex) {
|
1561
|
+
jsonProperty *currentProperty = &jo.properties[propertyIndex];
|
1562
|
+
for (unsigned int entry = currentProperty->hash & HASH_MASK; nextHashset[entry] != 0; entry = (entry + 1) % NEXT_BUCKET_LENGTH) {
|
1563
|
+
node *hashNode = &tree->nodePool[nextHashset[entry]];
|
1564
|
+
if (currentProperty->hash == hashNode->value.a.expression.left.value.id.propertyNameHash) {
|
1565
|
+
if (hashNode->value.a.expression.operator == OP_IALL || hashNode->value.a.expression.operator == OP_IANY) {
|
1566
|
+
CHECK_RESULT(isArrayMatch(tree,
|
1567
|
+
&jo,
|
1568
|
+
currentProperty,
|
1569
|
+
&hashNode->value.a,
|
1570
|
+
propertyMatch));
|
1571
|
+
} else {
|
1572
|
+
CHECK_RESULT(isAlphaMatch(tree,
|
1573
|
+
&hashNode->value.a,
|
1574
|
+
&jo,
|
1575
|
+
propertyMatch));
|
1576
|
+
}
|
1578
1577
|
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1578
|
+
if (*propertyMatch && (hashNode->value.a.nextOffset || hashNode->value.a.nextListOffset)) {
|
1579
|
+
CHECK_RESULT(isNextMatch(tree,
|
1580
|
+
&jo,
|
1581
|
+
&hashNode->value.a,
|
1582
|
+
propertyMatch));
|
1584
1583
|
|
1585
|
-
|
1584
|
+
}
|
1586
1585
|
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
}
|
1586
|
+
if (*propertyMatch && (hashNode->value.a.nextOffset || hashNode->value.a.nextListOffset)) {
|
1587
|
+
break;
|
1588
|
+
}
|
1589
|
+
}
|
1592
1590
|
}
|
1593
1591
|
}
|
1594
1592
|
}
|
1593
|
+
|
1595
1594
|
|
1596
1595
|
// OP_IANY, one element led a a valid path
|
1597
1596
|
// OP_IALL, all elements led to a valid path
|
data/src/rules/rete.c
CHANGED
@@ -156,6 +156,7 @@ static unsigned int storeAlpha(ruleset *tree,
|
|
156
156
|
return result;
|
157
157
|
}
|
158
158
|
|
159
|
+
(*newNode)->value.a.arrayOffset = 0;
|
159
160
|
(*newNode)->value.a.arrayListOffset = 0;
|
160
161
|
(*newNode)->value.a.nextListOffset = 0;
|
161
162
|
(*newNode)->value.a.betaListOffset = 0;
|
@@ -190,9 +191,9 @@ static unsigned int allocateNext(ruleset *tree,
|
|
190
191
|
return RULES_OK;
|
191
192
|
}
|
192
193
|
|
193
|
-
static unsigned int
|
194
|
-
if (!newNode->value.a.
|
195
|
-
return allocateNext(tree, NEXT_BUCKET_LENGTH, &newNode->value.a.
|
194
|
+
static unsigned int ensureArrayHashset(ruleset *tree, node *newNode) {
|
195
|
+
if (!newNode->value.a.arrayOffset) {
|
196
|
+
return allocateNext(tree, NEXT_BUCKET_LENGTH, &newNode->value.a.arrayOffset);
|
196
197
|
}
|
197
198
|
|
198
199
|
return RULES_OK;
|
@@ -206,6 +207,14 @@ static unsigned int ensureNextHashset(ruleset *tree, node *newNode) {
|
|
206
207
|
return RULES_OK;
|
207
208
|
}
|
208
209
|
|
210
|
+
static unsigned int ensureArrayList(ruleset *tree, node *newNode) {
|
211
|
+
if (!newNode->value.a.arrayListOffset) {
|
212
|
+
return allocateNext(tree, NEXT_LIST_LENGTH, &newNode->value.a.arrayListOffset);
|
213
|
+
}
|
214
|
+
|
215
|
+
return RULES_OK;
|
216
|
+
}
|
217
|
+
|
209
218
|
static unsigned int ensureNextList(ruleset *tree, node *newNode) {
|
210
219
|
if (!newNode->value.a.nextListOffset) {
|
211
220
|
return allocateNext(tree, NEXT_LIST_LENGTH, &newNode->value.a.nextListOffset);
|
@@ -785,10 +794,19 @@ static unsigned int linkAlpha(ruleset *tree,
|
|
785
794
|
|
786
795
|
parentBetaList[entry] = nextOffset;
|
787
796
|
} else if (nextNode->value.a.expression.operator == OP_NEX) {
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
797
|
+
unsigned int *parentNextList = NULL;
|
798
|
+
if ((parentAlpha->value.a.expression.operator == OP_IALL || parentAlpha->value.a.expression.operator == OP_IANY) && linkToArray) {
|
799
|
+
CHECK_RESULT(ensureArrayList(tree,
|
800
|
+
parentAlpha));
|
801
|
+
|
802
|
+
parentNextList = &tree->nextPool[parentAlpha->value.a.arrayListOffset];
|
803
|
+
} else {
|
804
|
+
CHECK_RESULT(ensureNextList(tree,
|
805
|
+
parentAlpha));
|
806
|
+
|
807
|
+
parentNextList = &tree->nextPool[parentAlpha->value.a.nextListOffset];
|
808
|
+
}
|
809
|
+
|
792
810
|
unsigned int entry;
|
793
811
|
for (entry = 0; parentNextList[entry] != 0; ++entry) {
|
794
812
|
if (entry == NEXT_LIST_LENGTH) {
|
@@ -800,10 +818,10 @@ static unsigned int linkAlpha(ruleset *tree,
|
|
800
818
|
} else {
|
801
819
|
unsigned int *parentNext = NULL;
|
802
820
|
if ((parentAlpha->value.a.expression.operator == OP_IALL || parentAlpha->value.a.expression.operator == OP_IANY) && linkToArray) {
|
803
|
-
CHECK_RESULT(
|
821
|
+
CHECK_RESULT(ensureArrayHashset(tree,
|
804
822
|
parentAlpha));
|
805
823
|
|
806
|
-
parentNext = &tree->nextPool[parentAlpha->value.a.
|
824
|
+
parentNext = &tree->nextPool[parentAlpha->value.a.arrayOffset];
|
807
825
|
} else {
|
808
826
|
CHECK_RESULT(ensureNextHashset(tree,
|
809
827
|
parentAlpha));
|
@@ -1097,7 +1115,10 @@ static unsigned int createForwardAlpha(ruleset *tree,
|
|
1097
1115
|
|
1098
1116
|
newAlpha->nameOffset = 0;
|
1099
1117
|
newAlpha->type = NODE_ALPHA;
|
1118
|
+
newAlpha->value.a.arrayOffset = 0;
|
1100
1119
|
newAlpha->value.a.arrayListOffset = 0;
|
1120
|
+
newAlpha->value.a.nextOffset = 0;
|
1121
|
+
newAlpha->value.a.nextListOffset = 0;
|
1101
1122
|
newAlpha->value.a.expression.left.type = JSON_MESSAGE_IDENTIFIER;
|
1102
1123
|
newAlpha->value.a.expression.left.value.id.propertyNameOffset = 0;
|
1103
1124
|
newAlpha->value.a.expression.left.value.id.propertyNameHash = HASH_FORWARD;
|
@@ -1280,7 +1301,7 @@ static unsigned int createAlpha(ruleset *tree,
|
|
1280
1301
|
&first,
|
1281
1302
|
&last,
|
1282
1303
|
&type));
|
1283
|
-
|
1304
|
+
|
1284
1305
|
CHECK_RESULT(createAlpha(tree,
|
1285
1306
|
first,
|
1286
1307
|
1,
|
@@ -1658,8 +1679,8 @@ static void printAlphaNode(ruleset *tree, node *alphaNode, int level, char *pref
|
|
1658
1679
|
printSimpleExpression(tree, &alphaNode->value.a.expression, 1, NULL);
|
1659
1680
|
|
1660
1681
|
printf("\n");
|
1661
|
-
if (alphaNode->value.a.
|
1662
|
-
unsigned int *nextHashset = &tree->nextPool[alphaNode->value.a.
|
1682
|
+
if (alphaNode->value.a.arrayOffset) {
|
1683
|
+
unsigned int *nextHashset = &tree->nextPool[alphaNode->value.a.arrayOffset];
|
1663
1684
|
for (unsigned int entry = 0; entry < NEXT_BUCKET_LENGTH; ++entry) {
|
1664
1685
|
if (nextHashset[entry]) {
|
1665
1686
|
printAlphaNode(tree, &tree->nodePool[nextHashset[entry]], level + 1, "Next Array ", nextHashset[entry]);
|
@@ -1676,6 +1697,13 @@ static void printAlphaNode(ruleset *tree, node *alphaNode, int level, char *pref
|
|
1676
1697
|
}
|
1677
1698
|
}
|
1678
1699
|
|
1700
|
+
if (alphaNode->value.a.arrayListOffset) {
|
1701
|
+
unsigned int *nextList = &tree->nextPool[alphaNode->value.a.arrayListOffset];
|
1702
|
+
for (unsigned int entry = 0; nextList[entry] != 0; ++entry) {
|
1703
|
+
printAlphaNode(tree, &tree->nodePool[nextList[entry]], level + 1, "Next Array List ", nextList[entry]);
|
1704
|
+
}
|
1705
|
+
}
|
1706
|
+
|
1679
1707
|
if (alphaNode->value.a.nextListOffset) {
|
1680
1708
|
unsigned int *nextList = &tree->nextPool[alphaNode->value.a.nextListOffset];
|
1681
1709
|
for (unsigned int entry = 0; nextList[entry] != 0; ++entry) {
|
data/src/rules/rete.h
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: durable_rules
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesus Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|