durable_rules 0.34.32 → 0.34.34

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: df480880781f625f6d6c574922212f450018587e
4
- data.tar.gz: 3bfca807e9d3749a23fb7da99ca813fe902ddcda
3
+ metadata.gz: d23a2b69698c386b592b25d31c9047e011bafa47
4
+ data.tar.gz: 82c5f1f4a37e88c0e4a6ff60364bb93cb735a812
5
5
  SHA512:
6
- metadata.gz: 9aa3ce726b7b4505293a64a05e793b707b94534c282f1d151f68a512bc9f76c41108e26884dd1d5df236e54466e45cd17e4a6f30d20620b24e950836eea26b82
7
- data.tar.gz: b650ece290ba8e7135f55a2e7fb175f171a47a47f09b34204746eaa9cd113ef877ad7e947de134d09fcf2c146b73a221fea88e81deebbc1f51af92375454c876
6
+ metadata.gz: 6d2156f08e81ac88bbc2ed931780e0d7f558af066484e8c2f7c1d1dac143b770ef2b4d4da8bcd0f7a6119b9dfa1e80e8c14ad6ff8b471bb520924973ae66a759
7
+ data.tar.gz: 4ddda7262500bd9f504766f62f1880e14380612718c43243ae88416a8d5d8eef5b9a63e99ac905252c8c9a44214daf62bea8c24a36c3aa59e7b483cdb71f26df
data/librb/durable.rb CHANGED
@@ -145,9 +145,6 @@ module Durable
145
145
  return Expression.new(@name, @left).imatches(other)
146
146
  end
147
147
 
148
- def ref_id(sid)
149
- Arithmetic.new @name, @left, sid
150
- end
151
148
 
152
149
  private
153
150
 
@@ -188,6 +185,7 @@ module Durable
188
185
 
189
186
  def definition(parent_name=nil)
190
187
  new_definition = nil
188
+
191
189
  if @__op == :$or || @__op == :$and
192
190
  new_definition = {@__op => @definitions}
193
191
  else
@@ -202,7 +200,11 @@ module Durable
202
200
  if @__op == :$eq
203
201
  new_definition = {@left => righ_definition}
204
202
  else
205
- new_definition = {@__op => {@left => righ_definition}}
203
+ if not @right
204
+ new_definition = {@__type => @left}
205
+ else
206
+ new_definition = {@__op => {@left => righ_definition}}
207
+ end
206
208
  end
207
209
  end
208
210
 
@@ -283,6 +285,22 @@ module Durable
283
285
  self
284
286
  end
285
287
 
288
+ def +(other)
289
+ return Arithmetic.new(@__type, @left, nil, :$add, other)
290
+ end
291
+
292
+ def -(other)
293
+ return Arithmetic.new(@__type, @left, nil, :$sub, other)
294
+ end
295
+
296
+ def *(other)
297
+ return Arithmetic.new(@__type, @left, nil, :$mul, other)
298
+ end
299
+
300
+ def /(other)
301
+ return Arithmetic.new(@__type, @left, nil, :$div, other)
302
+ end
303
+
286
304
  private
287
305
 
288
306
  def default(name, value=nil)
@@ -415,7 +433,7 @@ module Durable
415
433
  end
416
434
 
417
435
  def s
418
- Arithmetic.new(:$s)
436
+ Expression.new(:$s)
419
437
  end
420
438
 
421
439
  def m
@@ -443,6 +461,10 @@ module Durable
443
461
  expression == name
444
462
  end
445
463
 
464
+ def sref(sid = nil)
465
+ Arithmetic.new :$s, nil, sid
466
+ end
467
+
446
468
  protected
447
469
 
448
470
  def get_options(*args)
data/src/rules/events.c CHANGED
@@ -37,8 +37,8 @@
37
37
  #define OP_STRING_DOUBLE 0x0103
38
38
  #define OP_STRING_STRING 0x0101
39
39
  #define OP_STRING_NIL 0x0107
40
- #define OP_STRING_REGEX 0x010C
41
- #define OP_STRING_IREGEX 0x010D
40
+ #define OP_STRING_REGEX 0x010E
41
+ #define OP_STRING_IREGEX 0x010F
42
42
  #define OP_NIL_BOOL 0x0704
43
43
  #define OP_NIL_INT 0x0702
44
44
  #define OP_NIL_DOUBLE 0x0703
@@ -68,12 +68,14 @@ static unsigned int handleMessage(ruleset *tree,
68
68
  unsigned int *commandCount,
69
69
  void **rulesBinding);
70
70
 
71
- static unsigned int reduceStateIdiom(ruleset *tree,
72
- char *sid,
73
- unsigned int idiomOffset,
74
- char **state,
75
- unsigned char *releaseState,
76
- jsonProperty **targetValue);
71
+ static unsigned int reduceIdiom(ruleset *tree,
72
+ char *sid,
73
+ char *message,
74
+ jsonObject *messageObject,
75
+ unsigned int idiomOffset,
76
+ char **state,
77
+ unsigned char *releaseState,
78
+ jsonProperty **targetValue);
77
79
 
78
80
  static unsigned char compareBool(unsigned char left,
79
81
  unsigned char right,
@@ -418,6 +420,8 @@ static unsigned int handleBeta(ruleset *tree,
418
420
 
419
421
  static unsigned int valueToProperty(ruleset *tree,
420
422
  char *sid,
423
+ char *message,
424
+ jsonObject *messageObject,
421
425
  jsonValue *sourceValue,
422
426
  char **state,
423
427
  unsigned char *releaseState,
@@ -426,22 +430,35 @@ static unsigned int valueToProperty(ruleset *tree,
426
430
  unsigned int result = RULES_OK;
427
431
  *releaseState = 0;
428
432
  switch(sourceValue->type) {
433
+ case JSON_EVENT_LOCAL_IDIOM:
429
434
  case JSON_STATE_IDIOM:
430
- result = reduceStateIdiom(tree,
431
- sid,
432
- sourceValue->value.idiomOffset,
433
- state,
434
- releaseState,
435
- targetProperty);
435
+ result = reduceIdiom(tree,
436
+ sid,
437
+ message,
438
+ messageObject,
439
+ sourceValue->value.idiomOffset,
440
+ state,
441
+ releaseState,
442
+ targetProperty);
436
443
 
437
444
  return result;
445
+ case JSON_EVENT_LOCAL_PROPERTY:
446
+ for (unsigned short i = 0; i < messageObject->propertiesLength; ++i) {
447
+ if (sourceValue->value.property.nameHash == messageObject->properties[i].hash) {
448
+ *targetProperty = &messageObject->properties[i];
449
+ rehydrateProperty(*targetProperty, message);
450
+ return RULES_OK;
451
+ }
452
+ }
453
+
454
+ return ERR_PROPERTY_NOT_FOUND;
438
455
  case JSON_STATE_PROPERTY:
439
456
  if (sourceValue->value.property.idOffset) {
440
457
  sid = &tree->stringPool[sourceValue->value.property.idOffset];
441
458
  }
442
459
  result = fetchStateProperty(tree,
443
460
  sid,
444
- sourceValue->value.property.hash,
461
+ sourceValue->value.property.nameHash,
445
462
  MAX_STATE_PROPERTY_TIME,
446
463
  0,
447
464
  state,
@@ -455,7 +472,7 @@ static unsigned int valueToProperty(ruleset *tree,
455
472
 
456
473
  result = fetchStateProperty(tree,
457
474
  sid,
458
- sourceValue->value.property.hash,
475
+ sourceValue->value.property.nameHash,
459
476
  MAX_STATE_PROPERTY_TIME,
460
477
  0,
461
478
  state,
@@ -498,7 +515,7 @@ static unsigned int reduceProperties(unsigned char operator,
498
515
  char rightTemp = 0;
499
516
  if (leftProperty->type == JSON_STRING || rightProperty->type == JSON_STRING) {
500
517
  if (operator != OP_ADD) {
501
- *state = (char*)calloc(1, sizeof(char));
518
+ *state = (char *)calloc(1, sizeof(char));
502
519
  if (!*state) {
503
520
  return ERR_OUT_OF_MEMORY;
504
521
  }
@@ -629,12 +646,14 @@ static unsigned int reduceProperties(unsigned char operator,
629
646
  return RULES_OK;
630
647
  }
631
648
 
632
- static unsigned int reduceStateIdiom(ruleset *tree,
633
- char *sid,
634
- unsigned int idiomOffset,
635
- char **state,
636
- unsigned char *releaseState,
637
- jsonProperty **targetValue) {
649
+ static unsigned int reduceIdiom(ruleset *tree,
650
+ char *sid,
651
+ char *message,
652
+ jsonObject *messageObject,
653
+ unsigned int idiomOffset,
654
+ char **state,
655
+ unsigned char *releaseState,
656
+ jsonProperty **targetValue) {
638
657
  unsigned int result = RULES_OK;
639
658
  *releaseState = 0;
640
659
  idiom *currentIdiom = &tree->idiomPool[idiomOffset];
@@ -644,6 +663,8 @@ static unsigned int reduceStateIdiom(ruleset *tree,
644
663
  char *leftState = NULL;
645
664
  result = valueToProperty(tree,
646
665
  sid,
666
+ message,
667
+ messageObject,
647
668
  &currentIdiom->left,
648
669
  &leftState,
649
670
  &releaseLeftState,
@@ -658,6 +679,8 @@ static unsigned int reduceStateIdiom(ruleset *tree,
658
679
  char *rightState = NULL;
659
680
  result = valueToProperty(tree,
660
681
  sid,
682
+ message,
683
+ messageObject,
661
684
  &currentIdiom->right,
662
685
  &rightState,
663
686
  &releaseRightState,
@@ -696,6 +719,7 @@ static unsigned int reduceStateIdiom(ruleset *tree,
696
719
  static unsigned int isMatch(ruleset *tree,
697
720
  char *sid,
698
721
  char *message,
722
+ jsonObject *messageObject,
699
723
  jsonProperty *currentProperty,
700
724
  alpha *currentAlpha,
701
725
  unsigned char *propertyMatch,
@@ -717,6 +741,8 @@ static unsigned int isMatch(ruleset *tree,
717
741
  char *rightState = NULL;
718
742
  result = valueToProperty(tree,
719
743
  sid,
744
+ message,
745
+ messageObject,
720
746
  &currentAlpha->right,
721
747
  &rightState,
722
748
  &releaseRightState,
@@ -939,6 +965,7 @@ static unsigned int handleAlpha(ruleset *tree,
939
965
 
940
966
  if (!exists) {
941
967
  if (top == MAX_STACK_SIZE) {
968
+ printf("exiting 1\n");
942
969
  return ERR_MAX_STACK_SIZE;
943
970
  }
944
971
 
@@ -959,7 +986,6 @@ static unsigned int handleAlpha(ruleset *tree,
959
986
  if (top == MAX_STACK_SIZE) {
960
987
  return ERR_MAX_STACK_SIZE;
961
988
  }
962
-
963
989
  stack[top] = &hashNode->value.a;
964
990
  ++top;
965
991
  } else {
@@ -967,6 +993,7 @@ static unsigned int handleAlpha(ruleset *tree,
967
993
  unsigned int mresult = isMatch(tree,
968
994
  sid,
969
995
  message,
996
+ jo,
970
997
  currentProperty,
971
998
  &hashNode->value.a,
972
999
  &match,
@@ -974,6 +1001,7 @@ static unsigned int handleAlpha(ruleset *tree,
974
1001
  if (mresult != RULES_OK){
975
1002
  return mresult;
976
1003
  }
1004
+
977
1005
  if (match) {
978
1006
  if (top == MAX_STACK_SIZE) {
979
1007
  return ERR_MAX_STACK_SIZE;
data/src/rules/json.h CHANGED
@@ -12,10 +12,12 @@
12
12
  #define JSON_NIL 0x07
13
13
  #define JSON_STATE_PROPERTY 0x08
14
14
  #define JSON_EVENT_PROPERTY 0x09
15
- #define JSON_STATE_IDIOM 0x0A
16
- #define JSON_EVENT_IDIOM 0x0B
17
- #define JSON_REGEX 0x0C
18
- #define JSON_IREGEX 0x0D
15
+ #define JSON_EVENT_LOCAL_PROPERTY 0x0A
16
+ #define JSON_STATE_IDIOM 0x0B
17
+ #define JSON_EVENT_IDIOM 0x0C
18
+ #define JSON_EVENT_LOCAL_IDIOM 0x0D
19
+ #define JSON_REGEX 0x0E
20
+ #define JSON_IREGEX 0x0F
19
21
 
20
22
  #define FNV_32_OFFSET_BASIS 0x811c9dc5
21
23
  #define FNV_32_PRIME 16777619
data/src/rules/net.c CHANGED
@@ -104,6 +104,13 @@ static unsigned int createIdiom(ruleset *tree, jsonValue *newValue, char **idiom
104
104
  return ERR_OUT_OF_MEMORY;
105
105
  }
106
106
  break;
107
+ case JSON_EVENT_LOCAL_PROPERTY:
108
+ rightProperty = &tree->stringPool[newValue->value.property.nameOffset];
109
+ if (asprintf(idiomString, "message[\"%s\"]", rightProperty) == -1) {
110
+ return ERR_OUT_OF_MEMORY;
111
+ }
112
+ break;
113
+ case JSON_EVENT_LOCAL_IDIOM:
107
114
  case JSON_EVENT_IDIOM:
108
115
  newIdiom = &tree->idiomPool[newValue->value.idiomOffset];
109
116
  char *op = "";
@@ -577,6 +584,7 @@ static unsigned int loadDeleteSessionCommand(ruleset *tree, binding *rulesBindin
577
584
  " redis.call(\"del\", all_keys[i])\n"
578
585
  " end\n"
579
586
  "end\n"
587
+ "redis.call(\"hdel\", \"%s!p\", ARGV[2])\n"
580
588
  "redis.call(\"hdel\", \"%s!c\", sid)\n"
581
589
  "redis.call(\"hdel\", \"%s!s\", sid)\n"
582
590
  "redis.call(\"hdel\", \"%s!s!v\", sid)\n"
@@ -589,6 +597,7 @@ static unsigned int loadDeleteSessionCommand(ruleset *tree, binding *rulesBindin
589
597
  name,
590
598
  name,
591
599
  name,
600
+ name,
592
601
  name,
593
602
  name,
594
603
  name,
@@ -2136,6 +2145,7 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
2136
2145
  lua) == -1) {
2137
2146
  return ERR_OUT_OF_MEMORY;
2138
2147
  }
2148
+
2139
2149
  free(oldLua);
2140
2150
  unsigned int result = redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
2141
2151
  GET_REPLY(result, "loadEvalMessageCommand", reply);
@@ -2183,6 +2193,17 @@ static unsigned int setNames(ruleset *tree, binding *rulesBinding) {
2183
2193
  eventsHashset[nameLength + 2] = '\0';
2184
2194
  rulesBinding->eventsHashset = eventsHashset;
2185
2195
 
2196
+ char *partitionHashset = malloc((nameLength + 3) * sizeof(char));
2197
+ if (!partitionHashset) {
2198
+ return ERR_OUT_OF_MEMORY;
2199
+ }
2200
+
2201
+ strncpy(partitionHashset, name, nameLength);
2202
+ partitionHashset[nameLength] = '!';
2203
+ partitionHashset[nameLength + 1] = 'p';
2204
+ partitionHashset[nameLength + 2] = '\0';
2205
+ rulesBinding->partitionHashset = partitionHashset;
2206
+
2186
2207
  char *timersSortedset = malloc((nameLength + 3) * sizeof(char));
2187
2208
  if (!timersSortedset) {
2188
2209
  return ERR_OUT_OF_MEMORY;
@@ -2352,7 +2373,7 @@ unsigned int getBindingIndex(ruleset *tree, unsigned int sidHash, unsigned int *
2352
2373
  redisContext *reContext = firstBinding->reContext;
2353
2374
 
2354
2375
  int result = redisAppendCommand(reContext,
2355
- "evalsha %s 0 %d %d",
2376
+ "evalsha %s 0 %u %d",
2356
2377
  firstBinding->partitionHash,
2357
2378
  sidHash,
2358
2379
  list->bindingsLength);
@@ -3018,15 +3039,28 @@ unsigned int getSessionVersion(void *rulesBinding, char *sid, unsigned long *sta
3018
3039
  return REDIS_OK;
3019
3040
  }
3020
3041
 
3021
- unsigned int deleteSession(void *rulesBinding, char *sid) {
3042
+ unsigned int deleteSession(ruleset *tree, void *rulesBinding, char *sid, unsigned int sidHash) {
3022
3043
  binding *currentBinding = (binding*)rulesBinding;
3023
3044
  redisContext *reContext = currentBinding->reContext;
3024
3045
 
3025
3046
  int result = redisAppendCommand(reContext,
3026
- "evalsha %s 0 %s",
3047
+ "evalsha %s 0 %s %u",
3027
3048
  currentBinding->deleteSessionHash,
3028
- sid);
3049
+ sid,
3050
+ sidHash);
3029
3051
  VERIFY(result, "deleteSession");
3052
+
3053
+ bindingsList *list = tree->bindingsList;
3054
+ binding *firstBinding = &list->bindings[0];
3055
+ if (firstBinding != currentBinding) {
3056
+ reContext = firstBinding->reContext;
3057
+ result = redisAppendCommand(reContext,
3058
+ "hdel %s %u",
3059
+ firstBinding->partitionHashset,
3060
+ sidHash);
3061
+ VERIFY(result, "deleteSession");
3062
+ }
3063
+
3030
3064
  return REDIS_OK;
3031
3065
  }
3032
3066
 
data/src/rules/net.h CHANGED
@@ -33,6 +33,7 @@ typedef struct binding {
33
33
  functionHash removeTimerHash;
34
34
  functionHash updateActionHash;
35
35
  functionHash deleteSessionHash;
36
+ char *partitionHashset;
36
37
  char *sessionHashset;
37
38
  char *factsHashset;
38
39
  char *eventsHashset;
@@ -153,8 +154,10 @@ unsigned int getSessionVersion(void *rulesBinding,
153
154
  char *sid,
154
155
  unsigned long *stateVersion);
155
156
 
156
- unsigned int deleteSession(void *rulesBinding,
157
- char *sid);
157
+ unsigned int deleteSession(ruleset *tree,
158
+ void *rulesBinding,
159
+ char *sid,
160
+ unsigned int sidHash);
158
161
 
159
162
  unsigned int updateAction(void *rulesBinding,
160
163
  char *sid);
data/src/rules/rete.c CHANGED
@@ -26,6 +26,7 @@
26
26
  #define HASH_OR 340911698 // $or
27
27
  #define HASH_AND 3746487396 // $and
28
28
  #define HASH_S 1186729920 // $s
29
+ #define HASH_M 1690058490 // $m
29
30
  #define HASH_NAME 2369371622 // name
30
31
  #define HASH_ADD 4081054038 // $add
31
32
  #define HASH_SUB 1040718071 // $sub
@@ -304,13 +305,15 @@ static unsigned int copyValue(ruleset *tree,
304
305
  char temp;
305
306
  switch(type) {
306
307
  case JSON_EVENT_PROPERTY:
308
+ case JSON_EVENT_LOCAL_PROPERTY:
307
309
  case JSON_STATE_PROPERTY:
308
- right->value.property.hash = ref->hash;
310
+ right->value.property.nameHash = ref->nameHash;
309
311
  right->value.property.nameOffset = ref->nameOffset;
310
312
  right->value.property.idOffset = ref->idOffset;
311
313
  break;
312
314
  case JSON_STATE_IDIOM:
313
315
  case JSON_EVENT_IDIOM:
316
+ case JSON_EVENT_LOCAL_IDIOM:
314
317
  right->value.idiomOffset = idiomOffset;
315
318
  break;
316
319
  case JSON_STRING:
@@ -373,8 +376,9 @@ static unsigned char compareValue(ruleset *tree,
373
376
  char temp;
374
377
  switch(type) {
375
378
  case JSON_EVENT_PROPERTY:
379
+ case JSON_EVENT_LOCAL_PROPERTY:
376
380
  case JSON_STATE_PROPERTY:
377
- if (right->value.property.hash == ref->hash &&
381
+ if (right->value.property.nameHash == ref->nameHash &&
378
382
  right->value.property.nameOffset == ref->nameOffset &&
379
383
  right->value.property.idOffset == ref->idOffset)
380
384
  return 1;
@@ -382,6 +386,7 @@ static unsigned char compareValue(ruleset *tree,
382
386
  return 0;
383
387
  case JSON_STATE_IDIOM:
384
388
  case JSON_EVENT_IDIOM:
389
+ case JSON_EVENT_LOCAL_IDIOM:
385
390
  return 0;
386
391
  case JSON_STRING:
387
392
  {
@@ -456,6 +461,11 @@ static unsigned int validateReference(char *rule, unsigned char *referenceType)
456
461
 
457
462
  if (hash != HASH_S) {
458
463
  *referenceType = JSON_EVENT_PROPERTY;
464
+
465
+ if (hash == HASH_M) {
466
+ *referenceType = JSON_EVENT_LOCAL_PROPERTY;
467
+ }
468
+
459
469
  result = readNextString(last, &first, &last, &hash);
460
470
  if (result != PARSE_OK) {
461
471
  return result;
@@ -531,7 +541,8 @@ static unsigned int validateIdiom(char *rule, unsigned char *idiomType) {
531
541
  }
532
542
 
533
543
  if (newIdiomType == JSON_EVENT_PROPERTY || newIdiomType == JSON_EVENT_IDIOM) {
534
- if (*idiomType == JSON_STATE_PROPERTY || *idiomType == JSON_STATE_IDIOM) {
544
+ if (*idiomType == JSON_STATE_PROPERTY || *idiomType == JSON_STATE_IDIOM ||
545
+ *idiomType == JSON_EVENT_LOCAL_PROPERTY || *idiomType == JSON_EVENT_LOCAL_PROPERTY) {
535
546
  return ERR_UNEXPECTED_TYPE;
536
547
  }
537
548
 
@@ -539,13 +550,23 @@ static unsigned int validateIdiom(char *rule, unsigned char *idiomType) {
539
550
  }
540
551
 
541
552
  if (newIdiomType == JSON_STATE_PROPERTY || newIdiomType == JSON_STATE_IDIOM) {
542
- if (*idiomType == JSON_EVENT_PROPERTY || *idiomType == JSON_EVENT_IDIOM) {
553
+ if (*idiomType == JSON_EVENT_PROPERTY || *idiomType == JSON_EVENT_IDIOM ||
554
+ *idiomType == JSON_EVENT_LOCAL_PROPERTY || *idiomType == JSON_EVENT_LOCAL_IDIOM) {
543
555
  return ERR_UNEXPECTED_TYPE;
544
556
  }
545
557
 
546
558
  *idiomType = JSON_STATE_IDIOM;
547
559
  }
548
560
 
561
+ if (newIdiomType == JSON_EVENT_LOCAL_PROPERTY || newIdiomType == JSON_EVENT_LOCAL_IDIOM) {
562
+ if (*idiomType == JSON_STATE_PROPERTY || *idiomType == JSON_STATE_IDIOM ||
563
+ *idiomType == JSON_EVENT_PROPERTY || *idiomType == JSON_EVENT_PROPERTY) {
564
+ return ERR_UNEXPECTED_TYPE;
565
+ }
566
+
567
+ *idiomType = JSON_EVENT_IDIOM;
568
+ }
569
+
549
570
  if (hash != HASH_L && hash != HASH_R) {
550
571
  return ERR_UNEXPECTED_NAME;
551
572
  }
@@ -857,8 +878,12 @@ static unsigned int readReference(ruleset *tree, char *rule, unsigned char *idio
857
878
  return result;
858
879
  }
859
880
 
881
+ if (hash == HASH_M) {
882
+ *idiomType = JSON_EVENT_LOCAL_PROPERTY;
883
+ }
884
+
860
885
  readNextString(last, &first, &last, &hash);
861
- ref->hash = hash;
886
+ ref->nameHash = hash;
862
887
  result = storeString(tree, first, &ref->nameOffset, last - first);
863
888
  if (result != RULES_OK) {
864
889
  return result;
@@ -866,7 +891,7 @@ static unsigned int readReference(ruleset *tree, char *rule, unsigned char *idio
866
891
  } else {
867
892
  *idiomType = JSON_STATE_PROPERTY;
868
893
  if (readNextString(last, &first, &last, &hash) == PARSE_OK) {
869
- ref->hash = hash;
894
+ ref->nameHash = hash;
870
895
  result = storeString(tree, first, &ref->nameOffset, last - first);
871
896
  if (result != RULES_OK) {
872
897
  return result;
@@ -879,7 +904,7 @@ static unsigned int readReference(ruleset *tree, char *rule, unsigned char *idio
879
904
  switch (hash) {
880
905
  case HASH_NAME:
881
906
  readNextString(last, &first, &last, &hash);
882
- ref->hash = hash;
907
+ ref->nameHash = hash;
883
908
  result = storeString(tree, first, &ref->nameOffset, last - first);
884
909
  if (result != RULES_OK) {
885
910
  return result;
@@ -898,7 +923,7 @@ static unsigned int readReference(ruleset *tree, char *rule, unsigned char *idio
898
923
  return result;
899
924
  }
900
925
  }
901
-
926
+
902
927
  break;
903
928
  default:
904
929
  readNextValue(last, &first, &last, &type);
@@ -968,6 +993,10 @@ static unsigned int readIdiom(ruleset *tree, char *rule, unsigned char *idiomTyp
968
993
  *idiomType = JSON_EVENT_IDIOM;
969
994
  }
970
995
 
996
+ if (*idiomType != JSON_EVENT_IDIOM && (type == JSON_EVENT_LOCAL_PROPERTY || type == JSON_EVENT_LOCAL_IDIOM)) {
997
+ *idiomType = JSON_EVENT_LOCAL_IDIOM;
998
+ }
999
+
971
1000
  // newIdiom address might have changed after readIdiom
972
1001
  newIdiom = &tree->idiomPool[*idiomOffset];
973
1002
  switch (hash) {
data/src/rules/rete.h CHANGED
@@ -29,7 +29,7 @@
29
29
  #define NODE_M_OFFSET 0
30
30
 
31
31
  typedef struct reference {
32
- unsigned int hash;
32
+ unsigned int nameHash;
33
33
  unsigned int nameOffset;
34
34
  unsigned int idOffset;
35
35
  } reference;
data/src/rules/state.c CHANGED
@@ -175,7 +175,9 @@ static void insertSortProperties(jsonObject *jo, jsonProperty **properties) {
175
175
  }
176
176
 
177
177
  static void radixSortProperties(jsonObject *jo, jsonProperty **properties) {
178
- unsigned char counts[43] = {};
178
+ unsigned char counts[43];
179
+ memset(counts, 0, 43 * sizeof(char));
180
+
179
181
  for (unsigned char i = 0; i < jo->propertiesLength; ++i) {
180
182
  unsigned char mostSignificant = jo->properties[i].hash / 100000000;
181
183
  ++counts[mostSignificant];
@@ -615,5 +617,6 @@ unsigned int deleteState(void *handle, char *sid) {
615
617
  return result;
616
618
  }
617
619
 
618
- return deleteSession(rulesBinding, sid);
620
+ unsigned int sidHash = fnv1Hash32(sid, strlen(sid));
621
+ return deleteSession(handle, rulesBinding, sid, sidHash);
619
622
  }
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: 0.34.32
4
+ version: 0.34.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesus Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-28 00:00:00.000000000 Z
11
+ date: 2017-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake