Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of git://git.hyperdex.org/HyperDex

  • Loading branch information...
commit 751b9f4c301f87c2919471dc1af27e96a022bd17 2 parents 6dac8b0 + 893c270
authored April 22, 2012
1  hyperclient/python/hyperclient.pyx
@@ -644,6 +644,7 @@ cdef class DeferredDelete(Deferred):
644 644
                                       key_cstr, len(key), &self._status)
645 645
         if self._reqid < 0:
646 646
             raise HyperClientException(self._status)
  647
+        client._ops[self._reqid] = self
647 648
 
648 649
     def wait(self):
649 650
         Deferred.wait(self)
193  hyperdaemon/datatypes.cc
@@ -198,7 +198,7 @@ apply_string(const e::slice& old_value,
198 198
     {
199 199
         switch (ops[i].action)
200 200
         {
201  
-            case OP_STRING_SET:
  201
+            case OP_SET:
202 202
 
203 203
                 if (set_base || prepend || append)
204 204
                 {
@@ -229,7 +229,6 @@ apply_string(const e::slice& old_value,
229 229
 
230 230
                 append = ops + i;
231 231
                 break;
232  
-            case OP_INT64_SET:
233 232
             case OP_INT64_ADD:
234 233
             case OP_INT64_SUB:
235 234
             case OP_INT64_MUL:
@@ -420,7 +419,7 @@ apply_int64(const e::slice& old_value,
420 419
 
421 420
         switch (op->action)
422 421
         {
423  
-            case OP_INT64_SET:
  422
+            case OP_SET:
424 423
                 number = arg;
425 424
                 break;
426 425
             case OP_INT64_ADD:
@@ -447,7 +446,6 @@ apply_int64(const e::slice& old_value,
447 446
             case OP_INT64_XOR:
448 447
                 number ^= arg;
449 448
                 break;
450  
-            case OP_STRING_SET:
451 449
             case OP_STRING_APPEND:
452 450
             case OP_STRING_PREPEND:
453 451
             case OP_LIST_LPUSH:
@@ -493,7 +491,10 @@ validate_list(bool (*validate_elem)(const uint8_t** ptr,
493 491
 }
494 492
 
495 493
 static uint8_t*
496  
-apply_list(bool (*validate_elem_micro)(const hyperdex::microop* op),
  494
+apply_list(bool (*validate_elem)(const uint8_t** ptr,
  495
+                                 uint32_t* ptr_sz,
  496
+                                 const uint8_t* end),
  497
+           bool (*validate_elem_micro)(const hyperdex::microop* op),
497 498
            uint8_t* (*copy_elem_from_micro)(uint8_t* writeto,
498 499
                                             const hyperdex::microop* op),
499 500
            const e::slice& old_value,
@@ -502,10 +503,22 @@ apply_list(bool (*validate_elem_micro)(const hyperdex::microop* op),
502 503
            uint8_t* writeto,
503 504
            hyperdex::network_returncode* error)
504 505
 {
  506
+    if (num_ops == 1 && ops->action == hyperdex::OP_SET)
  507
+    {
  508
+        if (!validate_list(validate_elem, ops->arg1))
  509
+        {
  510
+            *error = hyperdex::NET_BADMICROS;
  511
+            return NULL;
  512
+        }
  513
+
  514
+        memmove(writeto, ops->arg1.data(), ops->arg1.size());
  515
+        return writeto + ops->arg1.size();
  516
+    }
  517
+
505 518
     // Apply the lpush ops
506 519
     for (ssize_t i = num_ops - 1; i >= 0; --i)
507 520
     {
508  
-        if (ops->action != hyperdex::OP_LIST_LPUSH)
  521
+        if (ops[i].action != hyperdex::OP_LIST_LPUSH)
509 522
         {
510 523
             continue;
511 524
         }
@@ -526,9 +539,9 @@ apply_list(bool (*validate_elem_micro)(const hyperdex::microop* op),
526 539
     // Apply the rpush ops
527 540
     for (size_t i = 0; i < num_ops; ++i)
528 541
     {
529  
-        if (ops->action != hyperdex::OP_LIST_RPUSH)
  542
+        if (ops[i].action != hyperdex::OP_LIST_RPUSH)
530 543
         {
531  
-            if (ops->action != hyperdex::OP_LIST_LPUSH)
  544
+            if (ops[i].action != hyperdex::OP_LIST_LPUSH)
532 545
             {
533 546
                 *error = hyperdex::NET_BADMICROS;
534 547
                 return NULL;
@@ -672,10 +685,8 @@ apply_set_add_remove(bool (*validate_elem)(const uint8_t** ptr, uint32_t* ptr_sz
672 685
                     break;
673 686
                 case OP_SET_INTERSECT:
674 687
                 case OP_SET_UNION:
675  
-                case OP_STRING_SET:
676 688
                 case OP_STRING_APPEND:
677 689
                 case OP_STRING_PREPEND:
678  
-                case OP_INT64_SET:
679 690
                 case OP_INT64_ADD:
680 691
                 case OP_INT64_SUB:
681 692
                 case OP_INT64_MUL:
@@ -688,6 +699,7 @@ apply_set_add_remove(bool (*validate_elem)(const uint8_t** ptr, uint32_t* ptr_sz
688 699
                 case OP_LIST_RPUSH:
689 700
                 case OP_MAP_ADD:
690 701
                 case OP_MAP_REMOVE:
  702
+                case OP_SET:
691 703
                 case OP_FAIL:
692 704
                 default:
693 705
                     *error = NET_BADMICROS;
@@ -709,10 +721,8 @@ apply_set_add_remove(bool (*validate_elem)(const uint8_t** ptr, uint32_t* ptr_sz
709 721
                     break;
710 722
                 case OP_SET_INTERSECT:
711 723
                 case OP_SET_UNION:
712  
-                case OP_STRING_SET:
713 724
                 case OP_STRING_APPEND:
714 725
                 case OP_STRING_PREPEND:
715  
-                case OP_INT64_SET:
716 726
                 case OP_INT64_ADD:
717 727
                 case OP_INT64_SUB:
718 728
                 case OP_INT64_MUL:
@@ -725,6 +735,7 @@ apply_set_add_remove(bool (*validate_elem)(const uint8_t** ptr, uint32_t* ptr_sz
725 735
                 case OP_LIST_RPUSH:
726 736
                 case OP_MAP_ADD:
727 737
                 case OP_MAP_REMOVE:
  738
+                case OP_SET:
728 739
                 case OP_FAIL:
729 740
                 default:
730 741
                     *error = NET_BADMICROS;
@@ -761,10 +772,8 @@ apply_set_add_remove(bool (*validate_elem)(const uint8_t** ptr, uint32_t* ptr_sz
761 772
                 break;
762 773
             case OP_SET_INTERSECT:
763 774
             case OP_SET_UNION:
764  
-            case OP_STRING_SET:
765 775
             case OP_STRING_APPEND:
766 776
             case OP_STRING_PREPEND:
767  
-            case OP_INT64_SET:
768 777
             case OP_INT64_ADD:
769 778
             case OP_INT64_SUB:
770 779
             case OP_INT64_MUL:
@@ -777,6 +786,7 @@ apply_set_add_remove(bool (*validate_elem)(const uint8_t** ptr, uint32_t* ptr_sz
777 786
             case OP_LIST_RPUSH:
778 787
             case OP_MAP_ADD:
779 788
             case OP_MAP_REMOVE:
  789
+            case OP_SET:
780 790
             case OP_FAIL:
781 791
             default:
782 792
                 *error = NET_BADMICROS;
@@ -788,14 +798,32 @@ apply_set_add_remove(bool (*validate_elem)(const uint8_t** ptr, uint32_t* ptr_sz
788 798
 }
789 799
 
790 800
 static uint8_t*
  801
+apply_set_set(bool (*validate_set)(const e::slice& data),
  802
+              const hyperdex::microop* op,
  803
+              uint8_t* writeto,
  804
+              hyperdex::network_returncode* error)
  805
+{
  806
+    using namespace hyperdex;
  807
+    assert(op->action == hyperdex::OP_SET);
  808
+
  809
+    if (!validate_set(op->arg1))
  810
+    {
  811
+        *error = NET_BADMICROS;
  812
+        return NULL;
  813
+    }
  814
+
  815
+    memmove(writeto, op->arg1.data(), op->arg1.size());
  816
+    return writeto + op->arg1.size();
  817
+}
  818
+
  819
+static uint8_t*
791 820
 apply_set_intersect(bool (*validate_set)(const e::slice& data),
792 821
                     bool (*validate_elem)(const uint8_t** ptr, uint32_t* ptr_sz, const uint8_t* end),
793 822
                     int (*compare_elem)(const uint8_t* a_ptr, uint32_t a_sz,
794 823
                                         const uint8_t* b_ptr, uint32_t b_sz),
795 824
                     uint8_t* (*copy_elem_from_set)(uint8_t* writeto, const uint8_t* ptr, uint32_t ptr_sz),
796 825
                     const e::slice& old_value,
797  
-                    const hyperdex::microop* ops,
798  
-                    size_t num_ops,
  826
+                    const hyperdex::microop* op,
799 827
                     uint8_t* writeto,
800 828
                     hyperdex::network_returncode* error)
801 829
 {
@@ -805,16 +833,9 @@ apply_set_intersect(bool (*validate_set)(const e::slice& data),
805 833
     // that the set is sorted, and the efficiency trade-off is on the order of
806 834
     // constants.
807 835
     using namespace hyperdex;
  836
+    assert(op->action == hyperdex::OP_SET_INTERSECT);
808 837
 
809  
-    if (num_ops != 1)
810  
-    {
811  
-        *error = NET_BADMICROS;
812  
-        return NULL;
813  
-    }
814  
-
815  
-    assert(ops->action == hyperdex::OP_SET_INTERSECT);
816  
-
817  
-    if (!validate_set(e::slice(ops->arg1)))
  838
+    if (!validate_set(op->arg1))
818 839
     {
819 840
         *error = NET_BADMICROS;
820 841
         return NULL;
@@ -822,8 +843,8 @@ apply_set_intersect(bool (*validate_set)(const e::slice& data),
822 843
 
823 844
     const uint8_t* set_ptr = old_value.data();
824 845
     const uint8_t* const set_end = old_value.data() + old_value.size();
825  
-    const uint8_t* new_ptr = ops->arg1.data();
826  
-    const uint8_t* const new_end = ops->arg1.data() + ops->arg1.size();
  846
+    const uint8_t* new_ptr = op->arg1.data();
  847
+    const uint8_t* const new_end = op->arg1.data() + op->arg1.size();
827 848
 
828 849
     // We only need to consider this case.
829 850
     while (set_ptr < set_end && new_ptr < new_end)
@@ -873,22 +894,14 @@ apply_set_union(bool (*validate_set)(const e::slice& data),
873 894
                                     const uint8_t* b_ptr, uint32_t b_sz),
874 895
                 uint8_t* (*copy_elem_from_set)(uint8_t* writeto, const uint8_t* ptr, uint32_t ptr_sz),
875 896
                 const e::slice& old_value,
876  
-                const hyperdex::microop* ops,
877  
-                size_t num_ops,
  897
+                const hyperdex::microop* op,
878 898
                 uint8_t* writeto,
879 899
                 hyperdex::network_returncode* error)
880 900
 {
881 901
     using namespace hyperdex;
  902
+    assert(op->action == hyperdex::OP_SET_UNION);
882 903
 
883  
-    if (num_ops != 1)
884  
-    {
885  
-        *error = NET_BADMICROS;
886  
-        return NULL;
887  
-    }
888  
-
889  
-    assert(ops->action == hyperdex::OP_SET_UNION);
890  
-
891  
-    if (!validate_set(e::slice(ops->arg1)))
  904
+    if (!validate_set(op->arg1))
892 905
     {
893 906
         *error = NET_BADMICROS;
894 907
         return NULL;
@@ -896,8 +909,8 @@ apply_set_union(bool (*validate_set)(const e::slice& data),
896 909
 
897 910
     const uint8_t* set_ptr = old_value.data();
898 911
     const uint8_t* const set_end = old_value.data() + old_value.size();
899  
-    const uint8_t* new_ptr = ops->arg1.data();
900  
-    const uint8_t* const new_end = ops->arg1.data() + ops->arg1.size();
  912
+    const uint8_t* new_ptr = op->arg1.data();
  913
+    const uint8_t* const new_end = op->arg1.data() + op->arg1.size();
901 914
 
902 915
     while (set_ptr < set_end && new_ptr < new_end)
903 916
     {
@@ -1031,6 +1044,25 @@ validate_map(bool (*validate_key)(const uint8_t** ptr,
1031 1044
 }
1032 1045
 
1033 1046
 static uint8_t*
  1047
+apply_map_set(bool (*validate_map)(const e::slice& data),
  1048
+              const hyperdex::microop* op,
  1049
+              uint8_t* writeto,
  1050
+              hyperdex::network_returncode* error)
  1051
+{
  1052
+    using namespace hyperdex;
  1053
+    assert(op->action == hyperdex::OP_SET);
  1054
+
  1055
+    if (!validate_map(op->arg1))
  1056
+    {
  1057
+        *error = NET_BADMICROS;
  1058
+        return NULL;
  1059
+    }
  1060
+
  1061
+    memmove(writeto, op->arg1.data(), op->arg1.size());
  1062
+    return writeto + op->arg1.size();
  1063
+}
  1064
+
  1065
+static uint8_t*
1034 1066
 apply_map_add_remove(bool (*validate_key)(const uint8_t** ptr, uint32_t* ptr_sz, const uint8_t* end),
1035 1067
                      bool (*validate_val)(const uint8_t** ptr, uint32_t* ptr_sz, const uint8_t* end),
1036 1068
                      bool (*validate_elem_micro_arg1)(const hyperdex::microop* op),
@@ -1119,12 +1151,8 @@ apply_map_add_remove(bool (*validate_key)(const uint8_t** ptr, uint32_t* ptr_sz,
1119 1151
                     // Nothing to remove
1120 1152
                     ++i;
1121 1153
                     break;
1122  
-                case OP_SET_INTERSECT:
1123  
-                case OP_SET_UNION:
1124  
-                case OP_STRING_SET:
1125 1154
                 case OP_STRING_APPEND:
1126 1155
                 case OP_STRING_PREPEND:
1127  
-                case OP_INT64_SET:
1128 1156
                 case OP_INT64_ADD:
1129 1157
                 case OP_INT64_SUB:
1130 1158
                 case OP_INT64_MUL:
@@ -1137,6 +1165,9 @@ apply_map_add_remove(bool (*validate_key)(const uint8_t** ptr, uint32_t* ptr_sz,
1137 1165
                 case OP_LIST_RPUSH:
1138 1166
                 case OP_SET_ADD:
1139 1167
                 case OP_SET_REMOVE:
  1168
+                case OP_SET_INTERSECT:
  1169
+                case OP_SET_UNION:
  1170
+                case OP_SET:
1140 1171
                 case OP_FAIL:
1141 1172
                 default:
1142 1173
                     *error = NET_BADMICROS;
@@ -1157,12 +1188,8 @@ apply_map_add_remove(bool (*validate_key)(const uint8_t** ptr, uint32_t* ptr_sz,
1157 1188
                     ptr = next_from_map;
1158 1189
                     ++i;
1159 1190
                     break;
1160  
-                case OP_SET_INTERSECT:
1161  
-                case OP_SET_UNION:
1162  
-                case OP_STRING_SET:
1163 1191
                 case OP_STRING_APPEND:
1164 1192
                 case OP_STRING_PREPEND:
1165  
-                case OP_INT64_SET:
1166 1193
                 case OP_INT64_ADD:
1167 1194
                 case OP_INT64_SUB:
1168 1195
                 case OP_INT64_MUL:
@@ -1175,6 +1202,9 @@ apply_map_add_remove(bool (*validate_key)(const uint8_t** ptr, uint32_t* ptr_sz,
1175 1202
                 case OP_LIST_RPUSH:
1176 1203
                 case OP_SET_ADD:
1177 1204
                 case OP_SET_REMOVE:
  1205
+                case OP_SET_INTERSECT:
  1206
+                case OP_SET_UNION:
  1207
+                case OP_SET:
1178 1208
                 case OP_FAIL:
1179 1209
                 default:
1180 1210
                     *error = NET_BADMICROS;
@@ -1220,12 +1250,8 @@ apply_map_add_remove(bool (*validate_key)(const uint8_t** ptr, uint32_t* ptr_sz,
1220 1250
             case OP_MAP_REMOVE:
1221 1251
                 ++i;
1222 1252
                 break;
1223  
-            case OP_SET_INTERSECT:
1224  
-            case OP_SET_UNION:
1225  
-            case OP_STRING_SET:
1226 1253
             case OP_STRING_APPEND:
1227 1254
             case OP_STRING_PREPEND:
1228  
-            case OP_INT64_SET:
1229 1255
             case OP_INT64_ADD:
1230 1256
             case OP_INT64_SUB:
1231 1257
             case OP_INT64_MUL:
@@ -1238,6 +1264,9 @@ apply_map_add_remove(bool (*validate_key)(const uint8_t** ptr, uint32_t* ptr_sz,
1238 1264
             case OP_LIST_RPUSH:
1239 1265
             case OP_SET_ADD:
1240 1266
             case OP_SET_REMOVE:
  1267
+            case OP_SET_INTERSECT:
  1268
+            case OP_SET_UNION:
  1269
+            case OP_SET:
1241 1270
             case OP_FAIL:
1242 1271
             default:
1243 1272
                 *error = NET_BADMICROS;
@@ -1428,7 +1457,8 @@ apply_list_string(const e::slice& old_value,
1428 1457
                   uint8_t* writeto,
1429 1458
                   hyperdex::network_returncode* error)
1430 1459
 {
1431  
-    return apply_list(validate_string_micro,
  1460
+    return apply_list(validate_string,
  1461
+                      validate_string_micro,
1432 1462
                       copy_string_from_micro_arg1,
1433 1463
                       old_value, ops, num_ops, writeto, error);
1434 1464
 }
@@ -1440,7 +1470,8 @@ apply_list_int64(const e::slice& old_value,
1440 1470
                  uint8_t* writeto,
1441 1471
                  hyperdex::network_returncode* error)
1442 1472
 {
1443  
-    return apply_list(validate_int64_micro_arg1,
  1473
+    return apply_list(validate_int64,
  1474
+                      validate_int64_micro_arg1,
1444 1475
                       copy_int64_from_micro_arg1,
1445 1476
                       old_value, ops, num_ops, writeto, error);
1446 1477
 }
@@ -1479,17 +1510,21 @@ apply_set_string(const e::slice& old_value,
1479 1510
                                     copy_string_from_micro_arg1,
1480 1511
                                     old_value, ops, num_ops, writeto, error);
1481 1512
     }
1482  
-    else if (ops[0].action == hyperdex::OP_SET_INTERSECT)
  1513
+    else if (ops[0].action == hyperdex::OP_SET && num_ops == 1)
  1514
+    {
  1515
+        return apply_set_set(validate_set_string, ops, writeto, error);
  1516
+    }
  1517
+    else if (ops[0].action == hyperdex::OP_SET_INTERSECT && num_ops == 1)
1483 1518
     {
1484 1519
         return apply_set_intersect(validate_set_string, validate_string,
1485 1520
                                    compare_string, copy_string_from_serialized,
1486  
-                                   old_value, ops, num_ops, writeto, error);
  1521
+                                   old_value, ops, writeto, error);
1487 1522
     }
1488  
-    else if (ops[0].action == hyperdex::OP_SET_UNION)
  1523
+    else if (ops[0].action == hyperdex::OP_SET_UNION && num_ops == 1)
1489 1524
     {
1490 1525
         return apply_set_union(validate_set_string, validate_string,
1491 1526
                                compare_string, copy_string_from_serialized,
1492  
-                               old_value, ops, num_ops, writeto, error);
  1527
+                               old_value, ops, writeto, error);
1493 1528
     }
1494 1529
     else
1495 1530
     {
@@ -1518,17 +1553,21 @@ apply_set_int64(const e::slice& old_value,
1518 1553
                                     copy_int64_from_micro_arg1,
1519 1554
                                     old_value, ops, num_ops, writeto, error);
1520 1555
     }
1521  
-    else if (ops[0].action == hyperdex::OP_SET_INTERSECT)
  1556
+    else if (ops[0].action == hyperdex::OP_SET && num_ops == 1)
  1557
+    {
  1558
+        return apply_set_set(validate_set_int64, ops, writeto, error);
  1559
+    }
  1560
+    else if (ops[0].action == hyperdex::OP_SET_INTERSECT && num_ops == 1)
1522 1561
     {
1523 1562
         return apply_set_intersect(validate_set_int64, validate_int64,
1524 1563
                                    compare_int64, copy_int64_from_serialized,
1525  
-                                   old_value, ops, num_ops, writeto, error);
  1564
+                                   old_value, ops, writeto, error);
1526 1565
     }
1527  
-    else if (ops[0].action == hyperdex::OP_SET_UNION)
  1566
+    else if (ops[0].action == hyperdex::OP_SET_UNION && num_ops == 1)
1528 1567
     {
1529 1568
         return apply_set_union(validate_set_int64, validate_int64,
1530 1569
                                compare_int64, copy_int64_from_serialized,
1531  
-                               old_value, ops, num_ops, writeto, error);
  1570
+                               old_value, ops, writeto, error);
1532 1571
     }
1533 1572
     else
1534 1573
     {
@@ -1604,6 +1643,10 @@ apply_map_string_string(const e::slice& old_value,
1604 1643
                                     copy_string_from_micro_arg1,
1605 1644
                                     old_value, ops, num_ops, writeto, error);
1606 1645
     }
  1646
+    else if (ops[0].action == hyperdex::OP_SET && num_ops == 1)
  1647
+    {
  1648
+        return apply_map_set(validate_map_string_string, ops, writeto, error);
  1649
+    }
1607 1650
     else
1608 1651
     {
1609 1652
         return apply_map_microop(validate_string,
@@ -1645,6 +1688,10 @@ apply_map_string_int64(const e::slice& old_value,
1645 1688
                                     copy_int64_from_micro_arg1,
1646 1689
                                     old_value, ops, num_ops, writeto, error);
1647 1690
     }
  1691
+    else if (ops[0].action == hyperdex::OP_SET && num_ops == 1)
  1692
+    {
  1693
+        return apply_map_set(validate_map_string_int64, ops, writeto, error);
  1694
+    }
1648 1695
     else
1649 1696
     {
1650 1697
         return apply_map_microop(validate_string,
@@ -1686,6 +1733,10 @@ apply_map_int64_string(const e::slice& old_value,
1686 1733
                                     copy_string_from_micro_arg1,
1687 1734
                                     old_value, ops, num_ops, writeto, error);
1688 1735
     }
  1736
+    else if (ops[0].action == hyperdex::OP_SET && num_ops == 1)
  1737
+    {
  1738
+        return apply_map_set(validate_map_int64_string, ops, writeto, error);
  1739
+    }
1689 1740
     else
1690 1741
     {
1691 1742
         return apply_map_microop(validate_int64,
@@ -1727,6 +1778,10 @@ apply_map_int64_int64(const e::slice& old_value,
1727 1778
                                     copy_int64_from_micro_arg1,
1728 1779
                                     old_value, ops, num_ops, writeto, error);
1729 1780
     }
  1781
+    else if (ops[0].action == hyperdex::OP_SET && num_ops == 1)
  1782
+    {
  1783
+        return apply_map_set(validate_map_int64_int64, ops, writeto, error);
  1784
+    }
1730 1785
     else
1731 1786
     {
1732 1787
         return apply_map_microop(validate_int64,
@@ -1787,11 +1842,21 @@ hyperdaemon :: sizeof_microop(const hyperdex::microop& op)
1787 1842
     {
1788 1843
         case OP_FAIL:
1789 1844
             return 0;
1790  
-        case OP_STRING_SET:
  1845
+        case OP_SET:
  1846
+
  1847
+            if (op.type == HYPERDATATYPE_STRING)
  1848
+            {
  1849
+                return sizeof(uint32_t) + op.arg1.size();
  1850
+            }
  1851
+            else if (op.type == HYPERDATATYPE_INT64)
  1852
+            {
  1853
+                return sizeof(int64_t);
  1854
+            }
  1855
+
  1856
+            return op.arg1.size();
1791 1857
         case OP_STRING_APPEND:
1792 1858
         case OP_STRING_PREPEND:
1793 1859
             return sizeof(uint32_t) + op.arg1.size();
1794  
-        case OP_INT64_SET:
1795 1860
         case OP_INT64_ADD:
1796 1861
         case OP_INT64_SUB:
1797 1862
         case OP_INT64_MUL:
90  hyperdaemon/replication_manager.cc
@@ -694,57 +694,57 @@ hyperdaemon :: replication_manager :: client_common(const hyperdex::network_msgt
694 694
     e::intrusive_ptr<keyholder> kh = get_keyholder(to.get_region(), key);
695 695
 
696 696
     // Find the pending or committed version with the largest number.
697  
-    uint64_t oldversion = 0;
698  
-    bool has_oldvalue = false;
699  
-    std::vector<e::slice> oldvalue;
  697
+    uint64_t old_version = 0;
  698
+    bool has_old_value = false;
  699
+    std::vector<e::slice> old_value;
700 700
     hyperdisk::reference ref;
701 701
 
702 702
     if (kh->has_blocked_ops())
703 703
     {
704  
-        oldversion = kh->most_recent_blocked_version();
705  
-        has_oldvalue = kh->most_recent_blocked_op()->has_value;
706  
-        oldvalue = kh->most_recent_blocked_op()->value;
  704
+        old_version = kh->most_recent_blocked_version();
  705
+        has_old_value = kh->most_recent_blocked_op()->has_value;
  706
+        old_value = kh->most_recent_blocked_op()->value;
707 707
     }
708 708
     else if (kh->has_committable_ops())
709 709
     {
710  
-        oldversion = kh->most_recent_committable_version();
711  
-        has_oldvalue = kh->most_recent_committable_op()->has_value;
712  
-        oldvalue = kh->most_recent_committable_op()->value;
  710
+        old_version = kh->most_recent_committable_version();
  711
+        has_old_value = kh->most_recent_committable_op()->has_value;
  712
+        old_value = kh->most_recent_committable_op()->value;
713 713
     }
714  
-    else if (!from_disk(to.get_region(), key, &has_oldvalue, &oldvalue, &oldversion, &ref))
  714
+    else if (!from_disk(to.get_region(), key, &has_old_value, &old_value, &old_version, &ref))
715 715
     {
716 716
         return;
717 717
     }
718 718
 
719  
-    e::intrusive_ptr<pending> newpend;
  719
+    e::intrusive_ptr<pending> new_pend;
720 720
     std::tr1::shared_ptr<e::buffer> sharedbacking(backing.release());
721  
-    newpend = new pending(has_value, sharedbacking, key, value, co);
722  
-    newpend->retcode = retcode;
723  
-    newpend->ref = ref;
  721
+    new_pend = new pending(has_value, sharedbacking, key, value, co);
  722
+    new_pend->retcode = retcode;
  723
+    new_pend->ref = ref;
724 724
 
725  
-    if (!has_value && !has_oldvalue)
  725
+    if (!has_value && !has_old_value)
726 726
     {
727 727
         respond_to_client(to, from, nonce, retcode, hyperdex::NET_NOTFOUND);
728 728
         g.dismiss();
729 729
         return;
730 730
     }
731 731
 
732  
-    if (has_value && !has_oldvalue)
  732
+    if (has_value && !has_old_value)
733 733
     {
734 734
         if (opcode == hyperdex::RESP_CONDPUT)
735 735
         {
736  
-          // a conditional put or atomic inc/dec on an object that does not exist should fail
737  
-          respond_to_client(to, from, nonce, retcode, hyperdex::NET_NOTFOUND);
738  
-          g.dismiss();
739  
-          return;
  736
+            // a conditional put or atomic inc/dec on an object that does not exist should fail
  737
+            respond_to_client(to, from, nonce, retcode, hyperdex::NET_NOTFOUND);
  738
+            g.dismiss();
  739
+            return;
740 740
         }
741 741
 
742  
-        newpend->fresh = true;
  742
+        new_pend->fresh = true;
743 743
     }
744 744
 
745  
-    std::tr1::shared_ptr<e::buffer> old_backing = newpend->backing;
  745
+    std::tr1::shared_ptr<e::buffer> old_backing = new_pend->backing;
746 746
 
747  
-    if (has_value && has_oldvalue)
  747
+    if (has_value && has_old_value)
748 748
     {
749 749
         size_t need_moar = 0;
750 750
 
@@ -752,49 +752,49 @@ hyperdaemon :: replication_manager :: client_common(const hyperdex::network_msgt
752 752
         {
753 753
             if (!value_mask.get(i))
754 754
             {
755  
-                need_moar += oldvalue[i].size();
  755
+                need_moar += old_value[i].size();
756 756
             }
757 757
         }
758 758
 
759 759
         if (need_moar)
760 760
         {
761 761
 #define REBASE(X) \
762  
-            ((X) - newpend->backing->data() + new_backing->data())
763  
-            std::tr1::shared_ptr<e::buffer> new_backing(e::buffer::create(newpend->backing->size() + need_moar));
764  
-            new_backing->resize(newpend->backing->size() + need_moar);
765  
-            memmove(new_backing->data(), newpend->backing->data(), newpend->backing->size());
766  
-            e::slice oldkey = newpend->key;
767  
-            newpend->key = e::slice(REBASE(newpend->key.data()), newpend->key.size());
768  
-            assert(oldkey == newpend->key);
769  
-            size_t curdata = newpend->backing->size();
  762
+            ((X) - new_pend->backing->data() + new_backing->data())
  763
+            std::tr1::shared_ptr<e::buffer> new_backing(e::buffer::create(new_pend->backing->size() + need_moar));
  764
+            new_backing->resize(new_pend->backing->size() + need_moar);
  765
+            memmove(new_backing->data(), new_pend->backing->data(), new_pend->backing->size());
  766
+            e::slice oldkey = new_pend->key;
  767
+            new_pend->key = e::slice(REBASE(new_pend->key.data()), new_pend->key.size());
  768
+            assert(oldkey == new_pend->key);
  769
+            size_t curdata = new_pend->backing->size();
770 770
 
771 771
             for (size_t i = 0; i < value.size(); ++i)
772 772
             {
773 773
                 if (value_mask.get(i))
774 774
                 {
775  
-                    e::slice oldslice = newpend->value[i];
776  
-                    newpend->value[i] = e::slice(REBASE(newpend->value[i].data()), newpend->value[i].size());
777  
-                    assert(oldslice == newpend->value[i]);
  775
+                    e::slice oldslice = new_pend->value[i];
  776
+                    new_pend->value[i] = e::slice(REBASE(new_pend->value[i].data()), new_pend->value[i].size());
  777
+                    assert(oldslice == new_pend->value[i]);
778 778
                 }
779 779
                 else
780 780
                 {
781  
-                    e::slice oldslice = oldvalue[i];
782  
-                    memmove(new_backing->data() + curdata, oldvalue[i].data(), oldvalue[i].size());
783  
-                    newpend->value[i] = e::slice(new_backing->data() + curdata, oldvalue[i].size());
784  
-                    curdata += oldvalue[i].size();
785  
-                    assert(oldslice == newpend->value[i]);
  781
+                    e::slice oldslice = old_value[i];
  782
+                    memmove(new_backing->data() + curdata, old_value[i].data(), old_value[i].size());
  783
+                    new_pend->value[i] = e::slice(new_backing->data() + curdata, old_value[i].size());
  784
+                    curdata += old_value[i].size();
  785
+                    assert(oldslice == new_pend->value[i]);
786 786
                 }
787 787
             }
788 788
 
789  
-            assert(curdata == newpend->backing->size() + need_moar);
790  
-            newpend->backing = new_backing;
  789
+            assert(curdata == new_pend->backing->size() + need_moar);
  790
+            new_pend->backing = new_backing;
791 791
         }
792 792
 
793 793
         if (opcode == hyperdex::RESP_CONDPUT)
794 794
         {
795 795
           for (size_t i = 0; i < condvalue.size(); ++i)
796 796
           {
797  
-              if (condvalue_mask.get(i) && (oldvalue[i] != condvalue[i]))
  797
+              if (condvalue_mask.get(i) && (old_value[i] != condvalue[i]))
798 798
               {
799 799
                 // cond value mismatch, put operation should fail
800 800
                 respond_to_client(to, from, nonce, retcode, hyperdex::NET_CMPFAIL);
@@ -805,7 +805,7 @@ hyperdaemon :: replication_manager :: client_common(const hyperdex::network_msgt
805 805
         }
806 806
     }
807 807
 
808  
-    if (!prev_and_next(to.get_region(), key, has_value, newpend->value, has_oldvalue, oldvalue, newpend))
  808
+    if (!prev_and_next(to.get_region(), new_pend->key, has_value, new_pend->value, has_old_value, old_value, new_pend))
809 809
     {
810 810
         respond_to_client(to, from, nonce, retcode, hyperdex::NET_NOTUS);
811 811
         g.dismiss();
@@ -813,7 +813,7 @@ hyperdaemon :: replication_manager :: client_common(const hyperdex::network_msgt
813 813
     }
814 814
 
815 815
     assert(!kh->has_deferred_ops());
816  
-    kh->append_blocked(oldversion + 1, newpend);
  816
+    kh->append_blocked(old_version + 1, new_pend);
817 817
     move_operations_between_queues(to, key, kh);
818 818
     g.dismiss();
819 819
 }
4  hyperdex/hyperdex/microop.h
@@ -42,11 +42,11 @@ enum microop_type
42 42
 {
43 43
     OP_FAIL,
44 44
 
45  
-    OP_STRING_SET,
  45
+    OP_SET,
  46
+
46 47
     OP_STRING_APPEND,
47 48
     OP_STRING_PREPEND,
48 49
 
49  
-    OP_INT64_SET,
50 50
     OP_INT64_ADD,
51 51
     OP_INT64_SUB,
52 52
     OP_INT64_MUL,

0 notes on commit 751b9f4

Please sign in to comment.
Something went wrong with that request. Please try again.