durable_rules 2.0.9 → 2.0.10
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 +69 -65
- data/src/rules/state.c +1 -1
- data/src/rules/state.h +1 -1
- 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: '08354a5b9d64bb706031205f0710774dfe373110'
|
4
|
+
data.tar.gz: 32d5ec3373973b43b23510c30319215229080f9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 700351f9793a3bdc225208dbfcc85461c72f2640348f74831f616bc82bbc293fa7adc8da9377c62a4ea3152343cf3b0ccf94398436f50e61a013ee59890c26bd
|
7
|
+
data.tar.gz: a5d572adc4e81d3b79bc9f51bd889f95ff77e592c86ef614b4637838265dc3527a527e8996606098ba2b8e944a094f4936ed685f7eae945d0da3e40ff1dabf01
|
data/src/rules/events.c
CHANGED
@@ -156,8 +156,8 @@ static unsigned int reduceBool(unsigned char left,
|
|
156
156
|
return RULES_OK;
|
157
157
|
}
|
158
158
|
|
159
|
-
static unsigned int reduceInt(long left,
|
160
|
-
long right,
|
159
|
+
static unsigned int reduceInt(long long left,
|
160
|
+
long long right,
|
161
161
|
unsigned char op,
|
162
162
|
jsonProperty *targetProperty) {
|
163
163
|
switch(op) {
|
@@ -354,10 +354,10 @@ static unsigned int reduceProperties(unsigned char operator,
|
|
354
354
|
{
|
355
355
|
#ifdef _WIN32
|
356
356
|
char *leftString = (char *)_alloca(sizeof(char)*(MAX_INT_LENGTH + 1));
|
357
|
-
sprintf_s(leftString, sizeof(char)*(MAX_INT_LENGTH + 1), "%
|
357
|
+
sprintf_s(leftString, sizeof(char)*(MAX_INT_LENGTH + 1), "%lld", leftProperty->value.i);
|
358
358
|
#else
|
359
359
|
char leftString[MAX_INT_LENGTH + 1];
|
360
|
-
snprintf(leftString, sizeof(char)*(MAX_INT_LENGTH + 1), "%
|
360
|
+
snprintf(leftString, sizeof(char)*(MAX_INT_LENGTH + 1), "%lld", leftProperty->value.i);
|
361
361
|
#endif
|
362
362
|
return reduceString(leftString,
|
363
363
|
leftProperty->valueLength,
|
@@ -403,10 +403,10 @@ static unsigned int reduceProperties(unsigned char operator,
|
|
403
403
|
{
|
404
404
|
#ifdef _WIN32
|
405
405
|
char *rightString = (char *)_alloca(sizeof(char)*(MAX_INT_LENGTH + 1));
|
406
|
-
sprintf_s(rightString, sizeof(char)*(MAX_INT_LENGTH + 1), "%
|
406
|
+
sprintf_s(rightString, sizeof(char)*(MAX_INT_LENGTH + 1), "%lld", rightProperty->value.i);
|
407
407
|
#else
|
408
408
|
char rightString[MAX_INT_LENGTH + 1];
|
409
|
-
snprintf(rightString, sizeof(char)*(MAX_INT_LENGTH + 1), "%
|
409
|
+
snprintf(rightString, sizeof(char)*(MAX_INT_LENGTH + 1), "%lld", rightProperty->value.i);
|
410
410
|
#endif
|
411
411
|
return reduceString(leftProperty->value.s,
|
412
412
|
leftProperty->valueLength,
|
@@ -617,10 +617,10 @@ static unsigned int getFrameHashForExpression(ruleset *tree,
|
|
617
617
|
{
|
618
618
|
#ifdef _WIN32
|
619
619
|
char *string = (char *)_alloca(sizeof(char)*(MAX_INT_LENGTH + 1));
|
620
|
-
sprintf_s(string, sizeof(char)*(MAX_INT_LENGTH + 1), "%
|
620
|
+
sprintf_s(string, sizeof(char)*(MAX_INT_LENGTH + 1), "%lld", property->value.i);
|
621
621
|
#else
|
622
622
|
char string[MAX_INT_LENGTH + 1];
|
623
|
-
snprintf(string, sizeof(char)*(MAX_INT_LENGTH + 1), "%
|
623
|
+
snprintf(string, sizeof(char)*(MAX_INT_LENGTH + 1), "%lld", property->value.i);
|
624
624
|
#endif
|
625
625
|
*hash = fnv1Hash32(string, strlen(string));
|
626
626
|
break;
|
@@ -716,7 +716,6 @@ static unsigned int isAlphaMatch(ruleset *tree,
|
|
716
716
|
alpha *currentAlpha,
|
717
717
|
jsonObject *messageObject,
|
718
718
|
unsigned char *propertyMatch) {
|
719
|
-
|
720
719
|
*propertyMatch = 0;
|
721
720
|
if (currentAlpha->expression.operator == OP_EX) {
|
722
721
|
*propertyMatch = 1;
|
@@ -1444,47 +1443,49 @@ static unsigned int isNextMatch(ruleset *tree,
|
|
1444
1443
|
}
|
1445
1444
|
|
1446
1445
|
if (*propertyMatch) {
|
1447
|
-
|
1446
|
+
return RULES_OK;
|
1448
1447
|
}
|
1449
1448
|
|
1450
1449
|
}
|
1451
1450
|
}
|
1452
1451
|
}
|
1453
|
-
|
1452
|
+
|
1454
1453
|
if (currentAlpha->nextOffset) {
|
1455
1454
|
unsigned int *nextHashset = &tree->nextPool[currentAlpha->nextOffset];
|
1456
1455
|
for(unsigned int propertyIndex = 0; propertyIndex < jo->propertiesLength; ++propertyIndex) {
|
1457
1456
|
jsonProperty *currentProperty = &jo->properties[propertyIndex];
|
1458
1457
|
for (unsigned int entry = currentProperty->hash & HASH_MASK; nextHashset[entry] != 0; entry = (entry + 1) % NEXT_BUCKET_LENGTH) {
|
1459
|
-
node *hashNode = &tree->nodePool[nextHashset[entry]];
|
1460
|
-
if (
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1458
|
+
node *hashNode = &tree->nodePool[nextHashset[entry]];
|
1459
|
+
if (currentProperty->hash == hashNode->value.a.expression.left.value.id.propertyNameHash) {
|
1460
|
+
if (hashNode->value.a.expression.operator == OP_IALL || hashNode->value.a.expression.operator == OP_IANY) {
|
1461
|
+
CHECK_RESULT(isArrayMatch(tree,
|
1462
|
+
jo,
|
1463
|
+
currentProperty,
|
1464
|
+
&hashNode->value.a,
|
1465
|
+
propertyMatch));
|
1466
|
+
} else {
|
1467
|
+
CHECK_RESULT(isAlphaMatch(tree,
|
1468
|
+
&hashNode->value.a,
|
1469
|
+
jo,
|
1470
|
+
propertyMatch));
|
1471
|
+
}
|
1472
1472
|
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1473
|
+
if (*propertyMatch && (hashNode->value.a.nextOffset || hashNode->value.a.nextListOffset)) {
|
1474
|
+
CHECK_RESULT(isNextMatch(tree,
|
1475
|
+
jo,
|
1476
|
+
&hashNode->value.a,
|
1477
|
+
propertyMatch));
|
1478
1478
|
|
1479
|
-
|
1479
|
+
}
|
1480
1480
|
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1481
|
+
if (*propertyMatch) {
|
1482
|
+
break;
|
1483
|
+
}
|
1484
|
+
}
|
1484
1485
|
}
|
1485
1486
|
}
|
1486
1487
|
}
|
1487
|
-
|
1488
|
+
|
1488
1489
|
return RULES_OK;
|
1489
1490
|
}
|
1490
1491
|
|
@@ -1493,6 +1494,7 @@ static unsigned int isArrayMatch(ruleset *tree,
|
|
1493
1494
|
jsonProperty *currentProperty,
|
1494
1495
|
alpha *arrayAlpha,
|
1495
1496
|
unsigned char *propertyMatch) {
|
1497
|
+
|
1496
1498
|
unsigned int result = RULES_OK;
|
1497
1499
|
if (currentProperty->type != JSON_ARRAY) {
|
1498
1500
|
return RULES_OK;
|
@@ -1553,42 +1555,44 @@ static unsigned int isArrayMatch(ruleset *tree,
|
|
1553
1555
|
}
|
1554
1556
|
}
|
1555
1557
|
|
1556
|
-
if (
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
if (
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
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
|
+
}
|
1575
1578
|
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1579
|
+
if (*propertyMatch && hashNode->value.a.nextOffset) {
|
1580
|
+
CHECK_RESULT(isNextMatch(tree,
|
1581
|
+
&jo,
|
1582
|
+
&hashNode->value.a,
|
1583
|
+
propertyMatch));
|
1581
1584
|
|
1582
|
-
|
1585
|
+
}
|
1583
1586
|
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1587
|
+
if (*propertyMatch && (hashNode->value.a.nextOffset || hashNode->value.a.nextListOffset)) {
|
1588
|
+
break;
|
1589
|
+
}
|
1590
|
+
}
|
1591
|
+
}
|
1588
1592
|
}
|
1589
1593
|
}
|
1590
1594
|
}
|
1591
|
-
|
1595
|
+
|
1592
1596
|
// OP_IANY, one element led a a valid path
|
1593
1597
|
// OP_IALL, all elements led to a valid path
|
1594
1598
|
if ((arrayAlpha->expression.operator == OP_IALL && !*propertyMatch) ||
|
@@ -1988,7 +1992,7 @@ unsigned int retractFacts(unsigned int handle,
|
|
1988
1992
|
ruleset *tree;
|
1989
1993
|
RESOLVE_HANDLE(handle, &tree);
|
1990
1994
|
|
1991
|
-
return handleMessages(tree,
|
1995
|
+
return handleMessages(tree, ACTION_RETRACT_FACT, messages, stateOffset);
|
1992
1996
|
}
|
1993
1997
|
|
1994
1998
|
unsigned int updateState(unsigned int handle,
|
data/src/rules/state.c
CHANGED
@@ -1397,7 +1397,7 @@ unsigned int setObjectProperty(jsonObject *jo,
|
|
1397
1397
|
case JSON_INT:
|
1398
1398
|
temp = first[property->valueLength];
|
1399
1399
|
first[property->valueLength] = '\0';
|
1400
|
-
property->value.i =
|
1400
|
+
property->value.i = atoll(first);
|
1401
1401
|
first[property->valueLength] = temp;
|
1402
1402
|
break;
|
1403
1403
|
case JSON_DOUBLE:
|
data/src/rules/state.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.10
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|