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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '08354a5b9d64bb706031205f0710774dfe373110'
4
- data.tar.gz: 32d5ec3373973b43b23510c30319215229080f9d
3
+ metadata.gz: 6dcf2ede6d2bd9909805f783b0bf914cd85c4c8e
4
+ data.tar.gz: 5d614d930ce359ac46d0ff33b76c64dc3004840e
5
5
  SHA512:
6
- metadata.gz: 700351f9793a3bdc225208dbfcc85461c72f2640348f74831f616bc82bbc293fa7adc8da9377c62a4ea3152343cf3b0ccf94398436f50e61a013ee59890c26bd
7
- data.tar.gz: a5d572adc4e81d3b79bc9f51bd889f95ff77e592c86ef614b4637838265dc3527a527e8996606098ba2b8e944a094f4936ed685f7eae945d0da3e40ff1dabf01
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->nextListOffset) {
1536
- unsigned int *nextList = &tree->nextPool[arrayAlpha->nextListOffset];
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
- if (arrayAlpha->arrayListOffset) {
1560
- unsigned int *nextHashset = &tree->nextPool[arrayAlpha->arrayListOffset];
1561
- for(unsigned int propertyIndex = 0; propertyIndex < jo.propertiesLength; ++propertyIndex) {
1562
- jsonProperty *currentProperty = &jo.properties[propertyIndex];
1563
- for (unsigned int entry = currentProperty->hash & HASH_MASK; nextHashset[entry] != 0; entry = (entry + 1) % NEXT_BUCKET_LENGTH) {
1564
- node *hashNode = &tree->nodePool[nextHashset[entry]];
1565
- if (currentProperty->hash == hashNode->value.a.expression.left.value.id.propertyNameHash) {
1566
- if (hashNode->value.a.expression.operator == OP_IALL || hashNode->value.a.expression.operator == OP_IANY) {
1567
- CHECK_RESULT(isArrayMatch(tree,
1568
- &jo,
1569
- currentProperty,
1570
- &hashNode->value.a,
1571
- propertyMatch));
1572
- } else {
1573
- CHECK_RESULT(isAlphaMatch(tree,
1574
- &hashNode->value.a,
1575
- &jo,
1576
- propertyMatch));
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
- if (*propertyMatch && hashNode->value.a.nextOffset) {
1580
- CHECK_RESULT(isNextMatch(tree,
1581
- &jo,
1582
- &hashNode->value.a,
1583
- propertyMatch));
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
- if (*propertyMatch && (hashNode->value.a.nextOffset || hashNode->value.a.nextListOffset)) {
1588
- break;
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 ensureNextArrayHashset(ruleset *tree, node *newNode) {
194
- if (!newNode->value.a.arrayListOffset) {
195
- return allocateNext(tree, NEXT_BUCKET_LENGTH, &newNode->value.a.arrayListOffset);
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
- CHECK_RESULT(ensureNextList(tree,
789
- parentAlpha));
790
-
791
- unsigned int *parentNextList = &tree->nextPool[parentAlpha->value.a.nextListOffset];
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(ensureNextArrayHashset(tree,
821
+ CHECK_RESULT(ensureArrayHashset(tree,
804
822
  parentAlpha));
805
823
 
806
- parentNext = &tree->nextPool[parentAlpha->value.a.arrayListOffset];
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.arrayListOffset) {
1662
- unsigned int *nextHashset = &tree->nextPool[alphaNode->value.a.arrayListOffset];
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
@@ -87,6 +87,7 @@ typedef struct alpha {
87
87
  unsigned int betaListOffset;
88
88
  unsigned int nextListOffset;
89
89
  unsigned int arrayListOffset;
90
+ unsigned int arrayOffset;
90
91
  unsigned int nextOffset;
91
92
  } alpha;
92
93
 
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.10
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-06 00:00:00.000000000 Z
11
+ date: 2019-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake