All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
as_policy.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2025 Aerospike, Inc.
3 *
4 * Portions may be licensed to Aerospike, Inc. under one or more contributor
5 * license agreements.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8 * use this file except in compliance with the License. You may obtain a copy of
9 * the License at http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17#pragma once
18
19/**
20 * @defgroup client_policies Client Policies
21 *
22 * Policies define the behavior of database operations.
23 *
24 * Policies fall into two groups: policy values and operation policies.
25 * A policy value is a single value which defines how the client behaves. An
26 * operation policy is a group of policy values which affect an operation.
27 *
28 * ## Policy Values
29 *
30 * The following are the policy values. For details, please see the documentation
31 * for each policy value
32 *
33 * - as_policy_key
34 * - as_policy_gen
35 * - as_policy_exists
36 * - as_policy_replica
37 * - as_policy_read_mode_ap
38 * - as_policy_read_mode_sc
39 * - as_policy_commit_level
40 *
41 * ## Operation Policies
42 *
43 * The following are the operation policies. Operation policies are groups of
44 * policy values for a type of operation.
45 *
46 * - as_policy_batch
47 * - as_policy_info
48 * - as_policy_operate
49 * - as_policy_read
50 * - as_policy_remove
51 * - as_policy_query
52 * - as_policy_scan
53 * - as_policy_write
54 */
55
56#include <aerospike/as_std.h>
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
62//---------------------------------
63// Macros
64//---------------------------------
65
66/**
67 * Default socket idle timeout value
68 *
69 * @ingroup client_policies
70 */
71#define AS_POLICY_SOCKET_TIMEOUT_DEFAULT 30000
72
73/**
74 * Default total timeout value
75 *
76 * @ingroup client_policies
77 */
78#define AS_POLICY_TOTAL_TIMEOUT_DEFAULT 1000
79
80/**
81 * Default value for compression threshold
82 *
83 * @ingroup client_policies
84 */
85#define AS_POLICY_COMPRESSION_THRESHOLD_DEFAULT 0
86
87/**
88 * Default as_policy_gen value
89 *
90 * @ingroup client_policies
91 */
92#define AS_POLICY_GEN_DEFAULT AS_POLICY_GEN_IGNORE
93
94/**
95 * Default as_policy_key value
96 *
97 * @ingroup client_policies
98 */
99#define AS_POLICY_KEY_DEFAULT AS_POLICY_KEY_DIGEST
100
101/**
102 * Default as_policy_exists value
103 *
104 * @ingroup client_policies
105 */
106#define AS_POLICY_EXISTS_DEFAULT AS_POLICY_EXISTS_IGNORE
107
108/**
109 * Default as_policy_replica value
110 *
111 * @ingroup client_policies
112 */
113#define AS_POLICY_REPLICA_DEFAULT AS_POLICY_REPLICA_SEQUENCE
114
115/**
116 * Default as_policy_read_mode_ap value
117 *
118 * @ingroup client_policies
119 */
120#define AS_POLICY_READ_MODE_AP_DEFAULT AS_POLICY_READ_MODE_AP_ONE
121
122/**
123 * Default as_policy_read_mode_sc value
124 *
125 * @ingroup client_policies
126 */
127#define AS_POLICY_READ_MODE_SC_DEFAULT AS_POLICY_READ_MODE_SC_SESSION
128
129/**
130 * Default as_policy_commit_level value for write
131 *
132 * @ingroup client_policies
133 */
134#define AS_POLICY_COMMIT_LEVEL_DEFAULT AS_POLICY_COMMIT_LEVEL_ALL
135
136//---------------------------------
137// Types
138//---------------------------------
139
140struct as_exp;
141struct as_txn;
142
143/**
144 * Retry Policy
145 *
146 * Specifies the behavior of failed operations.
147 *
148 * @ingroup client_policies
149 */
150typedef enum as_policy_retry_e {
151
152 /**
153 * Only attempt an operation once.
154 */
156
157 /**
158 * If an operation fails, attempt the operation
159 * one more time.
160 */
162
164
165/**
166 * Generation Policy
167 *
168 * Specifies the behavior of record modifications with regard to the
169 * generation value.
170 *
171 * @ingroup client_policies
172 */
173typedef enum as_policy_gen_e {
174
175 /**
176 * Do not use record generation to restrict writes.
177 */
179
180 /**
181 * Update/delete record if expected generation is equal to server generation. Otherwise, fail.
182 */
184
185 /**
186 * Update/delete record if expected generation greater than the server generation.
187 * Otherwise, fail. This is useful for restore after backup.
188 */
190
192
193/**
194 * Key Policy
195 *
196 * Specifies the behavior for whether keys or digests
197 * should be sent to the cluster.
198 *
199 * @ingroup client_policies
200 */
201typedef enum as_policy_key_e {
202
203 /**
204 * Send the digest value of the key.
205 *
206 * This is the recommended mode of operation. This calculates the digest
207 * and send the digest to the server. The digest is only calculated on
208 * the client, and not on the server.
209 */
211
212 /**
213 * Send the key, in addition to the digest value.
214 *
215 * If you want keys to be returned when scanning or querying, the keys must
216 * be stored on the server. This policy causes a write operation to store
217 * the key. Once a key is stored, the server will keep it - there is no
218 * need to use this policy on subsequent updates of the record.
219 *
220 * If this policy is used on read or delete operations, or on subsequent
221 * updates of a record with a stored key, the key sent will be compared
222 * with the key stored on the server. A mismatch will cause
223 * AEROSPIKE_ERR_RECORD_KEY_MISMATCH to be returned.
224 */
226
228
229/**
230 * Existence Policy
231 *
232 * Specifies the behavior for writing the record
233 * depending whether or not it exists.
234 *
235 * @ingroup client_policies
236 */
237typedef enum as_policy_exists_e {
238
239 /**
240 * Write the record, regardless of existence. (i.e. create or update.)
241 */
243
244 /**
245 * Create a record, ONLY if it doesn't exist.
246 */
248
249 /**
250 * Update a record, ONLY if it exists.
251 */
253
254 /**
255 * Completely replace a record, ONLY if it exists.
256 */
258
259 /**
260 * Completely replace a record if it exists, otherwise create it.
261 */
263
265
266/**
267 * Replica Policy
268 *
269 * Defines algorithm used to determine the target node for a command.
270 *
271 * @ingroup client_policies
272 */
273typedef enum as_policy_replica_e {
274
275 /**
276 * Use node containing key's master partition.
277 */
279
280 /**
281 * Distribute reads across nodes containing key's master and replicated partition
282 * in round-robin fashion.
283 */
285
286 /**
287 * Try node containing master partition first.
288 * If connection fails, all commands try nodes containing replicated partitions.
289 * If socketTimeout is reached, reads also try nodes containing replicated partitions,
290 * but writes remain on master node.
291 */
293
294 /**
295 * For reads, try node on preferred racks first. If there are no nodes on preferred racks,
296 * use SEQUENCE instead. Also use SEQUENCE for writes.
297 *
298 * as_config.rack_aware, as_config.rack_id or as_config.rack_ids, and server rack
299 * configuration must also be set to enable this functionality.
300 */
302
304
305/**
306 * Read policy for AP (availability) namespaces.
307 *
308 * How duplicates should be consulted in a read operation.
309 * Only makes a difference during migrations and only applicable in AP mode.
310 *
311 * @ingroup client_policies
312 */
313typedef enum as_policy_read_mode_ap_e {
314
315 /**
316 * Involve single node in the read operation.
317 */
319
320 /**
321 * Involve all duplicates in the read operation.
322 */
324
326
327/**
328 * Read policy for SC (strong consistency) namespaces.
329 *
330 * Determines SC read consistency options.
331 *
332 * @ingroup client_policies
333 */
334typedef enum as_policy_read_mode_sc_e {
335
336 /**
337 * Ensures this client will only see an increasing sequence of record versions.
338 * Client only reads from master. This is the default.
339 */
341
342 /**
343 * Ensures all clients will only see an increasing sequence of record versions.
344 * Client only reads from master.
345 */
347
348 /**
349 * Client may read from master or any full (non-migrating) replica.
350 * Increasing sequence of record versions is not guaranteed.
351 */
353
354 /**
355 * Client may read from master or any full (non-migrating) replica or from unavailable
356 * partitions. Increasing sequence of record versions is not guaranteed.
357 */
359
361
362/**
363 * Commit Level
364 *
365 * Specifies the number of replicas required to be successfully
366 * committed before returning success in a write operation
367 * to provide the desired consistency guarantee.
368 *
369 * @ingroup client_policies
370 */
371typedef enum as_policy_commit_level_e {
372
373 /**
374 * Return succcess only after successfully committing all replicas.
375 */
377
378 /**
379 * Return succcess after successfully committing the master replica.
380 */
382
384
385/**
386 * Expected query duration. The server treats the query in different ways depending on the expected duration.
387 * This enum is ignored for aggregation queries, background queries and server versions &lt; 6.0.
388 *
389 * @ingroup client_policies
390 */
391typedef enum as_query_duration_e {
392
393 /**
394 * The query is expected to return more than 100 records per node. The server optimizes for a
395 * large record set in the following ways:
396 * <ul>
397 * <li>Allow query to be run in multiple threads using the server's query threading configuration.</li>
398 * <li>Do not relax read consistency for AP namespaces.</li>
399 * <li>Add the query to the server's query monitor.</li>
400 * <li>Do not add the overall latency to the server's latency histogram.</li>
401 * <li>Do not allow server timeouts.</li>
402 * </ul>
403 */
405
406 /**
407 * The query is expected to return less than 100 records per node. The server optimizes for a
408 * small record set in the following ways:
409 * <ul>
410 * <li>Always run the query in one thread and ignore the server's query threading configuration.</li>
411 * <li>Allow query to be inlined directly on the server's service thread.</li>
412 * <li>Relax read consistency for AP namespaces.</li>
413 * <li>Do not add the query to the server's query monitor.</li>
414 * <li>Add the overall latency to the server's latency histogram.</li>
415 * <li>Allow server timeouts. The default server timeout for a short query is 1 second.</li>
416 * </ul>
417 */
419
420 /**
421 * Treat query as a LONG query, but relax read consistency for AP namespaces.
422 * This value is treated exactly like LONG for server versions &lt; 7.1.
423 */
425
427
428/**
429 * Generic policy fields shared among all policies.
430 *
431 * @ingroup client_policies
432 */
433typedef struct as_policy_base_s {
434
435 /**
436 * Socket idle timeout in milliseconds when processing a database command.
437 *
438 * If socket_timeout is zero and total_timeout is non-zero, then socket_timeout will be set
439 * to total_timeout. If both socket_timeout and total_timeout are non-zero and
440 * socket_timeout > total_timeout, then socket_timeout will be set to total_timeout. If both
441 * socket_timeout and total_timeout are zero, then there will be no socket idle limit.
442 *
443 * If socket_timeout is non-zero and the socket has been idle for at least socket_timeout,
444 * both max_retries and total_timeout are checked. If max_retries and total_timeout are not
445 * exceeded, the command is retried.
446 *
447 * Default: 30000ms
448 */
450
451 /**
452 * Total command timeout in milliseconds.
453 *
454 * The total_timeout is tracked on the client and sent to the server along with
455 * the command in the wire protocol. The client will most likely timeout
456 * first, but the server also has the capability to timeout the command.
457 *
458 * If total_timeout is not zero and total_timeout is reached before the command
459 * completes, the command will return error AEROSPIKE_ERR_TIMEOUT.
460 * If totalTimeout is zero, there will be no total time limit.
461 *
462 * Default: 1000
463 */
465
466 /**
467 * Maximum number of retries before aborting the current command.
468 * The initial attempt is not counted as a retry.
469 *
470 * If max_retries is exceeded, the command will return error AEROSPIKE_ERR_TIMEOUT.
471 *
472 * WARNING: Database writes that are not idempotent (such as "add")
473 * should not be retried because the write operation may be performed
474 * multiple times if the client timed out previous command attempts.
475 * It's important to use a distinct write policy for non-idempotent
476 * writes which sets max_retries = 0;
477 *
478 * Default for read: 2 (initial attempt + 2 retries = 3 attempts)
479 *
480 * Default for write: 0 (no retries)
481 *
482 * Default for partition scan or query with null filter: 5
483 *
484 * No default for legacy scan/query. No retries are allowed for these commands.
485 */
486 uint32_t max_retries;
487
488 /**
489 * Milliseconds to sleep between retries. Enter zero to skip sleep.
490 * This field is ignored when max_retries is zero.
491 * This field is also ignored in async mode.
492 *
493 * Reads do not have to sleep when a node goes down because the cluster
494 * does not shut out reads during cluster reformation. The default for
495 * reads is zero.
496 *
497 * The default for writes is also zero because writes are not retried by default.
498 * Writes need to wait for the cluster to reform when a node goes down.
499 * Immediate write retries on node failure have been shown to consistently
500 * result in errors. If max_retries is greater than zero on a write, then
501 * sleep_between_retries should be set high enough to allow the cluster to
502 * reform (>= 3000ms).
503 *
504 * Default: 0 (do not sleep between retries).
505 */
507
508 /**
509 * Optional expression filter. If filter_exp exists and evaluates to false, the
510 * command is ignored. This can be used to eliminate a client/server roundtrip
511 * in some cases.
512 *
513 * aerospike_destroy() automatically calls as_exp_destroy() on all global default
514 * policy filter expression instances. The user is responsible for calling as_exp_destroy()
515 * on filter expressions when setting temporary command policies.
516 *
517 * ~~~~~~~~~~{.c}
518 * as_exp_build(filter,
519 * as_exp_cmp_eq(as_exp_bin_int("a"), as_exp_int(10)));
520 *
521 * as_policy_read p;
522 * as_policy_read_init(&p);
523 * p.filter_exp = filter;
524 * ...
525 * as_exp_destroy(filter);
526 * ~~~~~~~~~~
527 *
528 * Default: NULL
529 */
531
532 /**
533 * Transaction identifier. If set for an async command, the source txn instance must
534 * be allocated on the heap using as_txn_create() or as_txn_create_capacity().
535 *
536 * Default: NULL
537 */
538 struct as_txn* txn;
539
540 /**
541 * Use zlib compression on write or batch read commands when the command buffer size is greater
542 * than 128 bytes. In addition, tell the server to compress it's response on read commands.
543 * The server response compression threshold is also 128 bytes.
544 *
545 * This option will increase cpu and memory usage (for extra compressed buffers), but
546 * decrease the size of data sent over the network.
547 *
548 * This compression feature requires the Enterprise Edition Server.
549 *
550 * Default: false
551 */
553
555
556/**
557 * Read Policy
558 *
559 * @ingroup client_policies
560 */
561typedef struct as_policy_read_s {
562
563 /**
564 * Generic policy fields.
565 */
567
568 /**
569 * Specifies the behavior for the key.
570 */
572
573 /**
574 * Algorithm used to determine target node.
575 */
577
578 /**
579 * Read policy for AP (availability) namespaces.
580 * Default: AS_POLICY_READ_MODE_AP_ONE
581 */
583
584 /**
585 * Read policy for SC (strong consistency) namespaces.
586 * Default: AS_POLICY_READ_MODE_SC_SESSION
587 */
589
590 /**
591 * Determine how record TTL (time to live) is affected on reads. When enabled, the server can
592 * efficiently operate as a read-based LRU cache where the least recently used records are expired.
593 * The value is expressed as a percentage of the TTL sent on the most recent write such that a read
594 * within this interval of the record’s end of life will generate a touch.
595 *
596 * For example, if the most recent write had a TTL of 10 hours and read_touch_ttl_percent is set to
597 * 80, the next read within 8 hours of the record's end of life (equivalent to 2 hours after the most
598 * recent write) will result in a touch, resetting the TTL to another 10 hours.
599 *
600 * Values:
601 * <ul>
602 * <li> 0 : Use server config default-read-touch-ttl-pct for the record's namespace/set.</li>
603 * <li>-1 : Do not reset record TTL on reads.</li>
604 * <li>1 - 100 : Reset record TTL on reads when within this percentage of the most recent write TTL.</li>
605 * </ul>
606 *
607 * Default: 0
608 */
610
611 /**
612 * Should raw bytes representing a list or map be deserialized to as_list or as_map.
613 * Set to false for backup programs that just need access to raw bytes.
614 *
615 * Default: true
616 */
618
619 /**
620 * Should as_record instance be allocated on the heap before user listener is called in
621 * async commands. If true, the user is responsible for calling as_record_destroy() when done
622 * with the record. If false, as_record_destroy() is automatically called by the client after
623 * the user listener function completes. This field is ignored for sync commands.
624 *
625 * Default: false
626 */
628
630
631/**
632 * Write Policy
633 *
634 * @ingroup client_policies
635 */
636typedef struct as_policy_write_s {
637
638 /**
639 * Generic policy fields.
640 */
642
643 /**
644 * Specifies the behavior for the key.
645 */
647
648 /**
649 * Algorithm used to determine target node.
650 */
652
653 /**
654 * Specifies the number of replicas required to be committed successfully when writing
655 * before returning command succeeded.
656 */
658
659 /**
660 * Specifies the behavior for the generation value.
661 */
663
664 /**
665 * Specifies the behavior for the existence of the record.
666 */
668
669 /**
670 * The default time-to-live (expiration) of the record in seconds. This field will
671 * only be used if "as_record.ttl" is set to AS_RECORD_CLIENT_DEFAULT_TTL. The
672 * as_record instance is passed in to write functions along with as_policy_write.
673 *
674 * There are also special values that can be set in the record ttl:
675 * <ul>
676 * <li>AS_RECORD_DEFAULT_TTL: Use the server default ttl from the namespace.</li>
677 * <li>AS_RECORD_NO_EXPIRE_TTL: Do not expire the record.</li>
678 * <li>AS_RECORD_NO_CHANGE_TTL: Keep the existing record ttl when the record is updated.</li>
679 * </ul>
680 */
681 uint32_t ttl;
682
683 /**
684 * Minimum record size beyond which it is compressed and sent to the server.
685 */
687
688 /**
689 * If the command results in a record deletion, leave a tombstone for the record.
690 * This prevents deleted records from reappearing after node failures.
691 * Valid for Aerospike Server Enterprise Edition only.
692 *
693 * Default: false (do not tombstone deleted records).
694 */
696
697 /**
698 * Execute the write command only if the record is not already locked by this transaction.
699 * If this field is true and the record is already locked by this transaction, the command will
700 * return AEROSPIKE_MRT_ALREADY_LOCKED.
701 *
702 * This field is useful for safely retrying non-idempotent writes as an alternative to simply
703 * aborting the transaction.
704 *
705 * Default: false.
706 */
708
710
711/**
712 * Key Apply Policy
713 *
714 * @ingroup client_policies
715 */
716typedef struct as_policy_apply_s {
717
718 /**
719 * Generic policy fields.
720 */
722
723 /**
724 * Specifies the behavior for the key.
725 */
727
728 /**
729 * Algorithm used to determine target node.
730 */
732
733 /**
734 * Specifies the number of replicas required to be committed successfully when writing
735 * before returning command succeeded.
736 */
738
739 /**
740 * The time-to-live (expiration) of the record in seconds. Note that ttl
741 * is only used on write/update calls.
742 *
743 * There are also special values that can be set in the record ttl:
744 * <ul>
745 * <li>AS_RECORD_DEFAULT_TTL: Use the server default ttl from the namespace.</li>
746 * <li>AS_RECORD_NO_EXPIRE_TTL: Do not expire the record.</li>
747 * <li>AS_RECORD_NO_CHANGE_TTL: Keep the existing record ttl when the record is updated.</li>
748 * </ul>
749 */
750 uint32_t ttl;
751
752 /**
753 * If the command results in a record deletion, leave a tombstone for the record.
754 * This prevents deleted records from reappearing after node failures.
755 * Valid for Aerospike Server Enterprise Edition only.
756 *
757 * Default: false (do not tombstone deleted records).
758 */
760
761 /**
762 * Execute the write command only if the record is not already locked by this transaction.
763 * If this field is true and the record is already locked by this transaction, the command will
764 * return AEROSPIKE_MRT_ALREADY_LOCKED.
765 *
766 * This field is useful for safely retrying non-idempotent writes as an alternative to simply
767 * aborting the transaction.
768 *
769 * Default: false.
770 */
772
774
775/**
776 * Operate Policy
777 *
778 * @ingroup client_policies
779 */
780typedef struct as_policy_operate_s {
781
782 /**
783 * Generic policy fields.
784 */
786
787 /**
788 * Specifies the behavior for the key.
789 */
791
792 /**
793 * Algorithm used to determine target node.
794 */
796
797 /**
798 * Read policy for AP (availability) namespaces.
799 * Default: AS_POLICY_READ_MODE_AP_ONE
800 */
802
803 /**
804 * Read policy for SC (strong consistency) namespaces.
805 * Default: AS_POLICY_READ_MODE_SC_SESSION
806 */
808
809 /**
810 * Specifies the number of replicas required to be committed successfully when writing
811 * before returning command succeeded.
812 */
814
815 /**
816 * Specifies the behavior for the generation value.
817 */
819
820 /**
821 * Specifies the behavior for the existence of the record.
822 */
824
825 /**
826 * The default time-to-live (expiration) of the record in seconds. This field will
827 * only be used if one or more of the operations is a write operation and if "as_operations.ttl"
828 * is set to AS_RECORD_CLIENT_DEFAULT_TTL. The as_operations instance is passed in to
829 * operate functions along with as_policy_operate.
830 *
831 * There are also special values that can be set in the record ttl:
832 * <ul>
833 * <li>AS_RECORD_DEFAULT_TTL: Use the server default ttl from the namespace.</li>
834 * <li>AS_RECORD_NO_EXPIRE_TTL: Do not expire the record.</li>
835 * <li>AS_RECORD_NO_CHANGE_TTL: Keep the existing record ttl when the record is updated.</li>
836 * </ul>
837 */
838 uint32_t ttl;
839
840 /**
841 * Determine how record TTL (time to live) is affected on reads. When enabled, the server can
842 * efficiently operate as a read-based LRU cache where the least recently used records are expired.
843 * The value is expressed as a percentage of the TTL sent on the most recent write such that a read
844 * within this interval of the record’s end of life will generate a touch.
845 *
846 * For example, if the most recent write had a TTL of 10 hours and read_touch_ttl_percent is set to
847 * 80, the next read within 8 hours of the record's end of life (equivalent to 2 hours after the most
848 * recent write) will result in a touch, resetting the TTL to another 10 hours.
849 *
850 * Values:
851 * <ul>
852 * <li> 0 : Use server config default-read-touch-ttl-pct for the record's namespace/set.</li>
853 * <li>-1 : Do not reset record TTL on reads.</li>
854 * <li>1 - 100 : Reset record TTL on reads when within this percentage of the most recent write TTL.</li>
855 * </ul>
856 *
857 * Default: 0
858 */
860
861 /**
862 * Should raw bytes representing a list or map be deserialized to as_list or as_map.
863 * Set to false for backup programs that just need access to raw bytes.
864 *
865 * Default: true
866 */
868
869 /**
870 * If the command results in a record deletion, leave a tombstone for the record.
871 * This prevents deleted records from reappearing after node failures.
872 * Valid for Aerospike Server Enterprise Edition only.
873 *
874 * Default: false (do not tombstone deleted records).
875 */
877
878 /**
879 * Execute the write command only if the record is not already locked by this transaction.
880 * If this field is true and the record is already locked by this transaction, the command will
881 * return AEROSPIKE_MRT_ALREADY_LOCKED.
882 *
883 * This field is useful for safely retrying non-idempotent writes as an alternative to simply
884 * aborting the transaction.
885 *
886 * Default: false.
887 */
889
890 /**
891 * Should as_record instance be allocated on the heap before user listener is called in
892 * async commands. If true, the user is responsible for calling as_record_destroy() when done
893 * with the record. If false, as_record_destroy() is automatically called by the client after
894 * the user listener function completes. This field is ignored for sync commands.
895 *
896 * Default: false
897 */
899
900 /**
901 * Should the client return a result for every operation.
902 *
903 * Some operations do not return a result by default. This can make it difficult to determine the
904 * result offset in the returned bin's result list. Setting this field to true makes it easier to identify
905 * the desired result offset.
906 *
907 * This field defaults to false for older operations (basic read/write/incr/touch and list) to
908 * preserve legacy behavior. Newer operations (map, expression, bit or HLL and batch
909 * write operations) force respond_all_ops to be true regardless of it's initial setting.
910 */
912
914
915/**
916 * Remove Policy
917 *
918 * @ingroup client_policies
919 */
920typedef struct as_policy_remove_s {
921
922 /**
923 * Generic policy fields.
924 */
926
927 /**
928 * Specifies the behavior for the key.
929 */
931
932 /**
933 * Algorithm used to determine target node.
934 */
936
937 /**
938 * Specifies the number of replicas required to be committed successfully when writing
939 * before returning command succeeded.
940 */
942
943 /**
944 * Specifies the behavior for the generation value.
945 */
947
948 /**
949 * The generation of the record.
950 */
951 uint16_t generation;
952
953 /**
954 * If the command results in a record deletion, leave a tombstone for the record.
955 * This prevents deleted records from reappearing after node failures.
956 * Valid for Aerospike Server Enterprise Edition only.
957 *
958 * Default: false (do not tombstone deleted records).
959 */
961
963
964/**
965 * Batch parent policy.
966 *
967 * @ingroup client_policies
968 */
969typedef struct as_policy_batch_s {
970
971 /**
972 * Generic policy fields.
973 */
975
976 /**
977 * Algorithm used to determine target node.
978 */
980
981 /**
982 * Read policy for AP (availability) namespaces.
983 * Default: AS_POLICY_READ_MODE_AP_ONE
984 */
986
987 /**
988 * Read policy for SC (strong consistency) namespaces.
989 * Default: AS_POLICY_READ_MODE_SC_SESSION
990 */
992
993 /**
994 * Determine how record TTL (time to live) is affected on reads. When enabled, the server can
995 * efficiently operate as a read-based LRU cache where the least recently used records are expired.
996 * The value is expressed as a percentage of the TTL sent on the most recent write such that a read
997 * within this interval of the record’s end of life will generate a touch.
998 *
999 * For example, if the most recent write had a TTL of 10 hours and read_touch_ttl_percent is set to
1000 * 80, the next read within 8 hours of the record's end of life (equivalent to 2 hours after the most
1001 * recent write) will result in a touch, resetting the TTL to another 10 hours.
1002 *
1003 * Values:
1004 * <ul>
1005 * <li> 0 : Use server config default-read-touch-ttl-pct for the record's namespace/set.</li>
1006 * <li>-1 : Do not reset record TTL on reads.</li>
1007 * <li>1 - 100 : Reset record TTL on reads when within this percentage of the most recent write TTL.</li>
1008 * </ul>
1009 *
1010 * Default: 0
1011 */
1013
1014 /**
1015 * Determine if batch commands to each server are run in parallel threads.
1016 *
1017 * Values:
1018 * <ul>
1019 * <li>
1020 * false: Issue batch commands sequentially. This mode has a performance advantage for small
1021 * to medium sized batch sizes because commands can be issued in the main command thread.
1022 * This is the default.
1023 * </li>
1024 * <li>
1025 * true: Issue batch commands in parallel threads. This mode has a performance
1026 * advantage for large batch sizes because each node can process the command immediately.
1027 * The downside is extra threads will need to be created (or taken from
1028 * a thread pool).
1029 * </li>
1030 * </ul>
1031 */
1033
1034 /**
1035 * Allow batch to be processed immediately in the server's receiving thread for in-memory
1036 * namespaces. If false, the batch will always be processed in separate service threads.
1037 *
1038 * For batch commands with smaller sized records (&lt;= 1K per record), inline
1039 * processing will be significantly faster on in-memory namespaces.
1040 *
1041 * Inline processing can introduce the possibility of unfairness because the server
1042 * can process the entire batch before moving onto the next command.
1043 *
1044 * Default: true
1045 */
1047
1048 /**
1049 * Allow batch to be processed immediately in the server's receiving thread for SSD
1050 * namespaces. If false, the batch will always be processed in separate service threads.
1051 * Server versions &lt; 6.0 ignore this field.
1052 *
1053 * Inline processing can introduce the possibility of unfairness because the server
1054 * can process the entire batch before moving onto the next command.
1055 *
1056 * Default: false
1057 */
1059
1060 /**
1061 * Should all batch keys be attempted regardless of errors. This field is used on both
1062 * the client and server. The client handles node specific errors and the server handles
1063 * key specific errors.
1064 *
1065 * If true, every batch key is attempted regardless of previous key specific errors.
1066 * Node specific errors such as timeouts stop keys to that node, but keys directed at
1067 * other nodes will continue to be processed.
1068 *
1069 * If false, the server will stop the batch to its node on most key specific errors.
1070 * The exceptions are AEROSPIKE_ERR_RECORD_NOT_FOUND and AEROSPIKE_FILTERED_OUT
1071 * which never stop the batch. The client will stop the entire batch on node specific
1072 * errors for sync commands that are run in sequence (concurrent == false). The client
1073 * will not stop the entire batch for async commands or sync commands run in parallel.
1074 *
1075 * Server versions &lt; 6.0 do not support this field and treat this value as false
1076 * for key specific errors.
1077 *
1078 * Default: true
1079 */
1081
1082 /**
1083 * This method is deprecated and will eventually be removed.
1084 * The set name is now always sent for every distinct namespace/set in the batch.
1085 *
1086 * Send set name field to server for every key in the batch for batch index protocol.
1087 * This is necessary for batch writes and batch reads when authentication is enabled and
1088 * security roles are defined on a per set basis.
1089 *
1090 * @deprecated Set name always sent.
1091 */
1093
1094 /**
1095 * Should raw bytes be deserialized to as_list or as_map. Set to false for backup programs that
1096 * just need access to raw bytes.
1097 *
1098 * Default: true
1099 */
1101
1103
1104/**
1105 * Policy attributes used in batch read commands.
1106 * @ingroup client_policies
1107 */
1108typedef struct as_policy_batch_read_s {
1109 /**
1110 * Optional expression filter. If filter_exp exists and evaluates to false, the
1111 * command is ignored. This can be used to eliminate a client/server roundtrip
1112 * in some cases.
1113 *
1114 * aerospike_destroy() automatically calls as_exp_destroy() on all global default
1115 * policy filter expression instances. The user is responsible for calling as_exp_destroy()
1116 * on filter expressions when setting temporary command policies.
1117 *
1118 * Default: NULL
1119 */
1121
1122 /**
1123 * Read policy for AP (availability) namespaces.
1124 * Default: AS_POLICY_READ_MODE_AP_ONE
1125 */
1127
1128 /**
1129 * Read policy for SC (strong consistency) namespaces.
1130 * Default: AS_POLICY_READ_MODE_SC_SESSION
1131 */
1133
1134 /**
1135 * Determine how record TTL (time to live) is affected on reads. When enabled, the server can
1136 * efficiently operate as a read-based LRU cache where the least recently used records are expired.
1137 * The value is expressed as a percentage of the TTL sent on the most recent write such that a read
1138 * within this interval of the record’s end of life will generate a touch.
1139 *
1140 * For example, if the most recent write had a TTL of 10 hours and read_touch_ttl_percent is set to
1141 * 80, the next read within 8 hours of the record's end of life (equivalent to 2 hours after the most
1142 * recent write) will result in a touch, resetting the TTL to another 10 hours.
1143 *
1144 * Values:
1145 * <ul>
1146 * <li> 0 : Use server config default-read-touch-ttl-pct for the record's namespace/set.</li>
1147 * <li>-1 : Do not reset record TTL on reads.</li>
1148 * <li>1 - 100 : Reset record TTL on reads when within this percentage of the most recent write TTL.</li>
1149 * </ul>
1150 *
1151 * Default: 0
1152 */
1154
1156
1157/**
1158 * Policy attributes used in batch write commands.
1159 * @ingroup client_policies
1160 */
1161typedef struct as_policy_batch_write_s {
1162 /**
1163 * Optional expression filter. If filter_exp exists and evaluates to false, the
1164 * command is ignored. This can be used to eliminate a client/server roundtrip
1165 * in some cases.
1166 *
1167 * aerospike_destroy() automatically calls as_exp_destroy() on all global default
1168 * policy filter expression instances. The user is responsible for calling as_exp_destroy()
1169 * on filter expressions when setting temporary command policies.
1170 *
1171 * Default: NULL
1172 */
1174
1175 /**
1176 * Specifies the behavior for the key.
1177 */
1179
1180 /**
1181 * Specifies the number of replicas required to be committed successfully when writing
1182 * before returning command succeeded.
1183 */
1185
1186 /**
1187 * Specifies the behavior for the generation value.
1188 */
1190
1191 /**
1192 * Specifies the behavior for the existence of the record.
1193 */
1195
1196 /**
1197 * The default time-to-live (expiration) of the record in seconds. This field will only be
1198 * used if "as_operations.ttl" is set to AS_RECORD_CLIENT_DEFAULT_TTL. The as_operations
1199 * instance is passed in to batch write functions along with as_policy_batch_write.
1200 *
1201 * There are also special values that can be set in the record ttl:
1202 * <ul>
1203 * <li>AS_RECORD_DEFAULT_TTL: Use the server default ttl from the namespace.</li>
1204 * <li>AS_RECORD_NO_EXPIRE_TTL: Do not expire the record.</li>
1205 * <li>AS_RECORD_NO_CHANGE_TTL: Keep the existing record ttl when the record is updated.</li>
1206 * </ul>
1207 */
1208 uint32_t ttl;
1209
1210 /**
1211 * If the command results in a record deletion, leave a tombstone for the record.
1212 * This prevents deleted records from reappearing after node failures.
1213 * Valid for Aerospike Server Enterprise Edition only.
1214 *
1215 * Default: false (do not tombstone deleted records).
1216 */
1218
1219 /**
1220 * Execute the write command only if the record is not already locked by this transaction.
1221 * If this field is true and the record is already locked by this transaction, the command will
1222 * return AEROSPIKE_MRT_ALREADY_LOCKED.
1223 *
1224 * This field is useful for safely retrying non-idempotent writes as an alternative to simply
1225 * aborting the transaction.
1226 *
1227 * Default: false.
1228 */
1230
1232
1233/**
1234 * Policy attributes used in batch UDF apply commands.
1235 * @ingroup client_policies
1236 */
1237typedef struct as_policy_batch_apply_s {
1238 /**
1239 * Optional expression filter. If filter_exp exists and evaluates to false, the
1240 * command is ignored. This can be used to eliminate a client/server roundtrip
1241 * in some cases.
1242 *
1243 * aerospike_destroy() automatically calls as_exp_destroy() on all global default
1244 * policy filter expression instances. The user is responsible for calling as_exp_destroy()
1245 * on filter expressions when setting temporary command policies.
1246 *
1247 * Default: NULL
1248 */
1250
1251 /**
1252 * Specifies the behavior for the key.
1253 */
1255
1256 /**
1257 * Specifies the number of replicas required to be committed successfully when writing
1258 * before returning command succeeded.
1259 */
1261
1262 /**
1263 * The time-to-live (expiration) of the record in seconds. Note that ttl
1264 * is only used on write/update calls.
1265 *
1266 * There are also special values that can be set in the record ttl:
1267 * <ul>
1268 * <li>AS_RECORD_DEFAULT_TTL: Use the server default ttl from the namespace.</li>
1269 * <li>AS_RECORD_NO_EXPIRE_TTL: Do not expire the record.</li>
1270 * <li>AS_RECORD_NO_CHANGE_TTL: Keep the existing record ttl when the record is updated.</li>
1271 * </ul>
1272 */
1273 uint32_t ttl;
1274
1275 /**
1276 * If the command results in a record deletion, leave a tombstone for the record.
1277 * This prevents deleted records from reappearing after node failures.
1278 * Valid for Aerospike Server Enterprise Edition only.
1279 *
1280 * Default: false (do not tombstone deleted records).
1281 */
1283
1284 /**
1285 * Execute the write command only if the record is not already locked by this transaction.
1286 * If this field is true and the record is already locked by this transaction, the command will
1287 * return AEROSPIKE_MRT_ALREADY_LOCKED.
1288 *
1289 * This field is useful for safely retrying non-idempotent writes as an alternative to simply
1290 * aborting the transaction.
1291 *
1292 * Default: false.
1293 */
1295
1297
1298/**
1299 * Policy attributes used in batch remove commands.
1300 * @ingroup client_policies
1301 */
1302typedef struct as_policy_batch_remove_s {
1303 /**
1304 * Optional expression filter. If filter_exp exists and evaluates to false, the
1305 * command is ignored. This can be used to eliminate a client/server roundtrip
1306 * in some cases.
1307 *
1308 * aerospike_destroy() automatically calls as_exp_destroy() on all global default
1309 * policy filter expression instances. The user is responsible for calling as_exp_destroy()
1310 * on filter expressions when setting temporary command policies.
1311 *
1312 * Default: NULL
1313 */
1315
1316 /**
1317 * Specifies the behavior for the key.
1318 */
1320
1321 /**
1322 * Specifies the number of replicas required to be committed successfully when writing
1323 * before returning command succeeded.
1324 */
1326
1327 /**
1328 * Specifies the behavior for the generation value.
1329 */
1331
1332 /**
1333 * The generation of the record.
1334 */
1335 uint16_t generation;
1336
1337 /**
1338 * If the command results in a record deletion, leave a tombstone for the record.
1339 * This prevents deleted records from reappearing after node failures.
1340 * Valid for Aerospike Server Enterprise Edition only.
1341 *
1342 * Default: false (do not tombstone deleted records).
1343 */
1345
1347
1348/**
1349 * Query Policy
1350 *
1351 * @ingroup client_policies
1352 */
1353typedef struct as_policy_query_s {
1354
1355 /**
1356 * Generic policy fields.
1357 */
1359
1360 /**
1361 * Timeout used when info command is used that checks for cluster changes before and
1362 * after the query. This timeout is only used when fail_on_cluster_change is enabled.
1363 *
1364 * Default: 10000 ms
1365 */
1367
1368 /**
1369 * Algorithm used to determine target node.
1370 */
1372
1373 /**
1374 * Expected query duration. The server treats the query in different ways depending on the expected duration.
1375 * This field is ignored for aggregation queries, background queries and server versions &lt; 6.0.
1376 *
1377 * Default: AS_QUERY_DURATION_LONG
1378 */
1380
1381 /**
1382 * Terminate query if cluster is in migration state. If the server supports partition
1383 * queries or the query filter is null (scan), this field is ignored.
1384 *
1385 * Default: false
1386 */
1388
1389 /**
1390 * Should raw bytes representing a list or map be deserialized to as_list or as_map.
1391 * Set to false for backup programs that just need access to raw bytes.
1392 *
1393 * Default: true
1394 */
1396
1397 /**
1398 * This field is deprecated and will eventually be removed. Use expected_duration instead.
1399 *
1400 * For backwards compatibility: If short_query is true, the query is treated as a short query and
1401 * expected_duration is ignored. If short_query is false, expected_duration is used
1402 * and defaults to AS_QUERY_DURATION_LONG.
1403 *
1404 * Is query expected to return less than 100 records per node.
1405 * If true, the server will optimize the query for a small record set.
1406 * This field is ignored for aggregation queries, background queries
1407 * and server versions &lt; 6.0.
1408 *
1409 * Default: false
1410 *
1411 * @deprecated Use expected_duration instead.
1412 */
1414
1416
1417/**
1418 * Scan Policy
1419 *
1420 * @ingroup client_policies
1421 */
1422typedef struct as_policy_scan_s {
1423
1424 /**
1425 * Generic policy fields.
1426 */
1428
1429 /**
1430 * Approximate number of records to return to client. This number is divided by the
1431 * number of nodes involved in the scan. The actual number of records returned
1432 * may be less than max_records if node record counts are small and unbalanced across
1433 * nodes.
1434 *
1435 * Default: 0 (do not limit record count)
1436 */
1437 uint64_t max_records;
1438
1439 /**
1440 * Limit returned records per second (rps) rate for each server.
1441 * Do not apply rps limit if records_per_second is zero.
1442 *
1443 * Default: 0
1444 */
1446
1447 /**
1448 * Algorithm used to determine target node.
1449 */
1451
1452 /**
1453 * The default time-to-live (expiration) of the record in seconds. This field will only be
1454 * used on background scan writes if "as_scan.ttl" is set to AS_RECORD_CLIENT_DEFAULT_TTL.
1455 *
1456 * There are also special values that can be set in the record ttl:
1457 * <ul>
1458 * <li>AS_RECORD_DEFAULT_TTL: Use the server default ttl from the namespace.</li>
1459 * <li>AS_RECORD_NO_EXPIRE_TTL: Do not expire the record.</li>
1460 * <li>AS_RECORD_NO_CHANGE_TTL: Keep the existing record ttl when the record is updated.</li>
1461 * </ul>
1462 */
1463 uint32_t ttl;
1464
1465 /**
1466 * If the command results in a record deletion, leave a tombstone for the record.
1467 * This prevents deleted records from reappearing after node failures.
1468 * Valid for Aerospike Server Enterprise Edition only.
1469 *
1470 * Default: false (do not tombstone deleted records).
1471 */
1473
1475
1476/**
1477 * Info Policy
1478 *
1479 * @ingroup client_policies
1480 */
1481typedef struct as_policy_info_s {
1482
1483 /**
1484 * Maximum time in milliseconds to wait for the operation to complete.
1485 */
1486 uint32_t timeout;
1487
1488 /**
1489 * Send request without any further processing.
1490 */
1492
1493 /**
1494 * Ensure the request is within allowable size limits.
1495 */
1497
1499
1500/**
1501 * Administration Policy
1502 *
1503 * @ingroup client_policies
1504 */
1505typedef struct as_policy_admin_s {
1506
1507 /**
1508 * Maximum time in milliseconds to wait for the operation to complete.
1509 */
1510 uint32_t timeout;
1511
1513
1514/**
1515 * Transaction policy fields used to batch verify record versions on commit.
1516 * Used a placeholder for now as there are no additional fields beyond as_policy_batch.
1517 */
1519
1520/**
1521 * Transaction policy fields used to batch roll forward/backward records on
1522 * commit or abort. Used a placeholder for now as there are no additional fields beyond as_policy_batch.
1523 */
1525
1526/**
1527 * Struct of all policy values and operation policies.
1528 *
1529 * This is utilized by as_config to define default values for policies.
1530 *
1531 * @ingroup client_policies
1532 */
1533typedef struct as_policies_s {
1534
1535 /**
1536 * Default read policy.
1537 */
1539
1540 /**
1541 * Default write policy.
1542 */
1544
1545 /**
1546 * Default operate policy.
1547 */
1549
1550 /**
1551 * Default remove policy.
1552 */
1554
1555 /**
1556 * Default apply policy.
1557 */
1559
1560 /**
1561 * Default parent policy used in batch read commands.
1562 */
1564
1565 /**
1566 * Default parent policy used in batch write commands.
1567 */
1569
1570 /**
1571 * Default write policy used in batch operate commands.
1572 */
1574
1575 /**
1576 * Default user defined function policy used in batch UDF apply commands.
1577 */
1579
1580 /**
1581 * Default delete policy used in batch remove commands.
1582 */
1584
1585 /**
1586 * Default scan policy.
1587 */
1589
1590 /**
1591 * Default query policy.
1592 */
1594
1595 /**
1596 * Default info policy.
1597 */
1599
1600 /**
1601 * Default administration policy.
1602 */
1604
1605 /**
1606 * Default transaction policy when verifying record versions in a batch.
1607 */
1609
1610 /**
1611 * Default transaction policy when rolling the transaction records forward (commit)
1612 * or back (abort) in a batch.
1613 */
1615
1616} as_policies;
1617
1618//---------------------------------
1619// Functions
1620//---------------------------------
1621
1622/**
1623 * Initialize base defaults for reads.
1624 */
1625static inline void
1627{
1630 p->max_retries = 2;
1631 p->sleep_between_retries = 0;
1632 p->filter_exp = NULL;
1633 p->txn = NULL;
1634 p->compress = false;
1635}
1636
1637/**
1638 * Initialize base defaults for writes.
1639 */
1640static inline void
1651
1652/**
1653 * Initialize base defaults for scan/query.
1654 *
1655 * Set max_retries for scans and non-aggregation queries with a null filter.
1656 * All other queries are not retried.
1657 *
1658 * The latest servers support retries on individual data partitions.
1659 * This feature is useful when a cluster is migrating and partition(s)
1660 * are missed or incomplete on the first query (with null filter) attempt.
1661 *
1662 * If the first query attempt misses 2 of 4096 partitions, then only
1663 * those 2 partitions are retried in the next query attempt from the
1664 * last key digest received for each respective partition. A higher
1665 * default max_retries is used because it's wasteful to invalidate
1666 * all query results because a single partition was missed.
1667 */
1668static inline void
1670{
1672 p->total_timeout = 0;
1673 p->max_retries = 5;
1674 p->sleep_between_retries = 0;
1675 p->filter_exp = NULL;
1676 p->txn = NULL;
1677 p->compress = false;
1678}
1679
1680/**
1681 * Initialize as_policy_read to default values.
1682 *
1683 * @param p The policy to initialize.
1684 * @return The initialized policy.
1685 *
1686 * @relates as_policy_read
1687 */
1688static inline as_policy_read*
1701
1702/**
1703 * Shallow copy as_policy_read values.
1704 *
1705 * @param src The source policy.
1706 * @param trg The target policy.
1707 *
1708 * @relates as_policy_read
1709 */
1710static inline void
1712{
1713 *trg = *src;
1714}
1715
1716/**
1717 * Initialize as_policy_write to default values.
1718 *
1719 * @param p The policy to initialize.
1720 * @return The initialized policy.
1721 *
1722 * @relates as_policy_write
1723 */
1724static inline as_policy_write*
1739
1740/**
1741 * Shallow copy as_policy_write values.
1742 *
1743 * @param src The source policy.
1744 * @param trg The target policy.
1745 *
1746 * @relates as_policy_write
1747 */
1748static inline void
1750{
1751 *trg = *src;
1752}
1753
1754/**
1755 * Initialize as_policy_operate to default values.
1756 *
1757 * @param p The policy to initialize.
1758 * @return The initialized policy.
1759 *
1760 * @relates as_policy_operate
1761 */
1762static inline as_policy_operate*
1764{
1773 p->ttl = 0; // AS_RECORD_DEFAULT_TTL
1775 p->deserialize = true;
1776 p->durable_delete = false;
1777 p->on_locking_only = false;
1778 p->async_heap_rec = false;
1779 p->respond_all_ops = false;
1780 return p;
1781}
1782
1783/**
1784 * Shallow copy as_policy_operate values.
1785 *
1786 * @param src The source policy.
1787 * @param trg The target policy.
1788 *
1789 * @relates as_policy_operate
1790 */
1791static inline void
1793{
1794 *trg = *src;
1795}
1796
1797/**
1798 * Initialize as_policy_remove to default values.
1799 *
1800 * @param p The policy to initialize.
1801 * @return The initialized policy.
1802 *
1803 * @relates as_policy_remove
1804 */
1805static inline as_policy_remove*
1817
1818/**
1819 * Shallow copy as_policy_remove values.
1820 *
1821 * @param src The source policy.
1822 * @param trg The target policy.
1823 *
1824 * @relates as_policy_remove
1825 */
1826static inline void
1828{
1829 *trg = *src;
1830}
1831
1832/**
1833 * Initialize as_policy_apply to default values.
1834 *
1835 * @param p The policy to initialize.
1836 * @return The initialized policy.
1837 *
1838 * @relates as_policy_apply
1839 */
1840static inline as_policy_apply*
1842{
1847 p->ttl = 0; // AS_RECORD_DEFAULT_TTL
1848 p->durable_delete = false;
1849 p->on_locking_only = false;
1850 return p;
1851}
1852
1853/**
1854 * Shallow copy as_policy_apply values.
1855 *
1856 * @param src The source policy.
1857 * @param trg The target policy.
1858 *
1859 * @relates as_policy_apply
1860 */
1861static inline void
1863{
1864 *trg = *src;
1865}
1866
1867/**
1868 * Initialize as_policy_batch to default values.
1869 *
1870 * @param p The policy to initialize.
1871 * @return The initialized policy.
1872 *
1873 * @relates as_policy_batch
1874 */
1875static inline as_policy_batch*
1877{
1883 p->concurrent = false;
1884 p->allow_inline = true;
1885 p->allow_inline_ssd = false;
1886 p->respond_all_keys = true;
1887 p->send_set_name = true;
1888 p->deserialize = true;
1889 return p;
1890}
1891
1892/**
1893 * Initialize as_policy_batch to default values when writes may occur.
1894 *
1895 * @param p The policy to initialize.
1896 * @return The initialized policy.
1897 *
1898 * @relates as_policy_batch
1899 */
1900static inline as_policy_batch*
1902{
1903 as_policy_batch_init(p);
1904 p->base.max_retries = 0;
1905 return p;
1906}
1907
1908/**
1909 * Shallow copy as_policy_batch values.
1910 *
1911 * @param src The source policy.
1912 * @param trg The target policy.
1913 *
1914 * @relates as_policy_batch
1915 */
1916static inline void
1918{
1919 *trg = *src;
1920}
1921
1922/**
1923 * Initialize as_policy_batch_read to default values.
1924 * @relates as_policy_batch_read
1925 */
1926static inline as_policy_batch_read*
1935
1936/**
1937 * Initialize as_policy_batch_write to default values.
1938 * @relates as_policy_batch_write
1939 */
1940static inline as_policy_batch_write*
1942{
1943 p->filter_exp = NULL;
1948 p->ttl = 0; // AS_RECORD_DEFAULT_TTL
1949 p->durable_delete = false;
1950 p->on_locking_only = false;
1951 return p;
1952}
1953
1954/**
1955 * Initialize as_policy_batch_apply to default values.
1956 * @relates as_policy_batch_apply
1957 */
1958static inline as_policy_batch_apply*
1960{
1961 p->filter_exp = NULL;
1964 p->ttl = 0; // AS_RECORD_DEFAULT_TTL
1965 p->durable_delete = false;
1966 p->on_locking_only = false;
1967 return p;
1968}
1969
1970/**
1971 * Initialize as_policy_batch_remove to default values.
1972 * @relates as_policy_batch_remove
1973 */
1974static inline as_policy_batch_remove*
1976{
1977 p->filter_exp = NULL;
1981 p->generation = 0;
1982 p->durable_delete = false;
1983 return p;
1984}
1985
1986/**
1987 * Initialize as_policy_scan to default values.
1988 *
1989 * @param p The policy to initialize.
1990 * @return The initialized policy.
1991 *
1992 * @relates as_policy_scan
1993 */
1994static inline as_policy_scan*
1996{
1998 p->max_records = 0;
1999 p->records_per_second = 0;
2001 p->ttl = 0; // AS_RECORD_DEFAULT_TTL
2002 p->durable_delete = false;
2003 return p;
2004}
2005
2006/**
2007 * Shallow copy as_policy_scan values.
2008 *
2009 * @param src The source policy.
2010 * @param trg The target policy.
2011 *
2012 * @relates as_policy_scan
2013 */
2014static inline void
2016{
2017 *trg = *src;
2018}
2019
2020/**
2021 * Initialize as_policy_query to default values.
2022 *
2023 * @param p The policy to initialize.
2024 * @return The initialized policy.
2025 *
2026 * @relates as_policy_query
2027 */
2028static inline as_policy_query*
2030{
2032 p->info_timeout = 10000;
2035 p->fail_on_cluster_change = false;
2036 p->deserialize = true;
2037 p->short_query = false;
2038 return p;
2039}
2040
2041/**
2042 * Shallow copy as_policy_query values.
2043 *
2044 * @param src The source policy.
2045 * @param trg The target policy.
2046 *
2047 * @relates as_policy_query
2048 */
2049static inline void
2051{
2052 *trg = *src;
2053}
2054
2055/**
2056 * Initialize as_policy_info to default values.
2057 *
2058 * @param p The policy to initialize.
2059 * @return The initialized policy.
2060 *
2061 * @relates as_policy_info
2062 */
2063static inline as_policy_info*
2065{
2067 p->send_as_is = true;
2068 p->check_bounds = true;
2069 return p;
2070}
2071
2072/**
2073 * Copy as_policy_info values.
2074 *
2075 * @param src The source policy.
2076 * @param trg The target policy.
2077 *
2078 * @relates as_policy_info
2079 */
2080static inline void
2082{
2083 *trg = *src;
2084}
2085
2086/**
2087 * Initialize as_policy_admin to default values.
2088 *
2089 * @param p The policy to initialize.
2090 * @return The initialized policy.
2091 *
2092 * @relates as_policy_admin
2093 */
2094static inline as_policy_admin*
2100
2101/**
2102 * Copy as_policy_admin values.
2103 *
2104 * @param src The source policy.
2105 * @param trg The target policy.
2106 *
2107 * @relates as_policy_admin
2108 */
2109static inline void
2111{
2112 *trg = *src;
2113}
2114
2115/**
2116 * Initialize as_policy_txn_verify to default values.
2117 *
2118 * @param p The policy to initialize.
2119 * @return The initialized policy.
2120 *
2121 * @relates as_policy_txn_verify
2122 */
2123static inline as_policy_txn_verify*
2124as_policy_txn_verify_init(as_policy_txn_verify* p)
2125{
2126 p->base.socket_timeout = 3000;
2127 p->base.total_timeout = 10000;
2128 p->base.max_retries = 5;
2129 p->base.sleep_between_retries = 1000;
2130 p->base.filter_exp = NULL;
2131 p->base.txn = NULL;
2132 p->base.compress = false;
2137 p->concurrent = false;
2138 p->allow_inline = true;
2139 p->allow_inline_ssd = false;
2140 p->respond_all_keys = true;
2141 p->send_set_name = true;
2142 p->deserialize = true;
2143 return p;
2144}
2145
2146/**
2147 * Copy as_policy_txn_verify values.
2148 *
2149 * @param src The source policy.
2150 * @param trg The target policy.
2151 *
2152 * @relates as_policy_txn_verify
2153 */
2154static inline void
2155as_policy_txn_verify_copy(const as_policy_txn_verify* src, as_policy_txn_verify* trg)
2156{
2157 *trg = *src;
2158}
2159
2160/**
2161 * Initialize as_policy_txn_roll_ to default values.
2162 *
2163 * @param p The policy to initialize.
2164 * @return The initialized policy.
2165 *
2166 * @relates as_policy_txn_roll_
2167 */
2168static inline as_policy_txn_roll*
2169as_policy_txn_roll_init(as_policy_txn_roll* p)
2170{
2171 p->base.socket_timeout = 3000;
2172 p->base.total_timeout = 10000;
2173 p->base.max_retries = 5;
2174 p->base.sleep_between_retries = 1000;
2175 p->base.filter_exp = NULL;
2176 p->base.txn = NULL;
2177 p->base.compress = false;
2182 p->concurrent = false;
2183 p->allow_inline = true;
2184 p->allow_inline_ssd = false;
2185 p->respond_all_keys = true;
2186 p->send_set_name = true;
2187 p->deserialize = true;
2188 return p;
2189}
2190
2191/**
2192 * Copy as_policy_txn_roll values.
2193 *
2194 * @param src The source policy.
2195 * @param trg The target policy.
2196 *
2197 * @relates as_policy_txn_roll
2198 */
2199static inline void
2200as_policy_txn_roll_copy(const as_policy_txn_roll* src, as_policy_txn_roll* trg)
2201{
2202 *trg = *src;
2203}
2204
2205/**
2206 * @private
2207 * Initialize as_policies.
2208 *
2209 * @relates as_policies
2210 */
2213
2214/**
2215 * @private
2216 * Destroy as_policies.
2217 *
2218 * @relates as_policies
2219 */
2220void
2222
2223#ifdef __cplusplus
2224} // end extern "C"
2225#endif
as_policy_batch as_policy_txn_roll
Definition as_policy.h:1524
static void as_policy_base_query_init(as_policy_base *p)
Definition as_policy.h:1669
static void as_policy_base_read_init(as_policy_base *p)
Definition as_policy.h:1626
as_policy_batch as_policy_txn_verify
Definition as_policy.h:1518
static void as_policy_base_write_init(as_policy_base *p)
Definition as_policy.h:1641
as_policy_commit_level
Definition as_policy.h:371
#define AS_POLICY_READ_MODE_AP_DEFAULT
Definition as_policy.h:120
as_policy_gen
Definition as_policy.h:173
#define AS_POLICY_COMPRESSION_THRESHOLD_DEFAULT
Definition as_policy.h:85
as_policy_read_mode_sc
Definition as_policy.h:334
as_policy_exists
Definition as_policy.h:237
#define AS_POLICY_EXISTS_DEFAULT
Definition as_policy.h:106
as_query_duration
Definition as_policy.h:391
#define AS_POLICY_READ_MODE_SC_DEFAULT
Definition as_policy.h:127
as_policy_retry
Definition as_policy.h:150
as_policy_key
Definition as_policy.h:201
#define AS_POLICY_TOTAL_TIMEOUT_DEFAULT
Definition as_policy.h:78
#define AS_POLICY_REPLICA_DEFAULT
Definition as_policy.h:113
as_policy_replica
Definition as_policy.h:273
#define AS_POLICY_COMMIT_LEVEL_DEFAULT
Definition as_policy.h:134
as_policy_read_mode_ap
Definition as_policy.h:313
#define AS_POLICY_GEN_DEFAULT
Definition as_policy.h:92
#define AS_POLICY_SOCKET_TIMEOUT_DEFAULT
Definition as_policy.h:71
#define AS_POLICY_KEY_DEFAULT
Definition as_policy.h:99
@ AS_POLICY_COMMIT_LEVEL_MASTER
Definition as_policy.h:381
@ AS_POLICY_COMMIT_LEVEL_ALL
Definition as_policy.h:376
@ AS_POLICY_GEN_EQ
Definition as_policy.h:183
@ AS_POLICY_GEN_IGNORE
Definition as_policy.h:178
@ AS_POLICY_GEN_GT
Definition as_policy.h:189
@ AS_POLICY_READ_MODE_SC_ALLOW_REPLICA
Definition as_policy.h:352
@ AS_POLICY_READ_MODE_SC_SESSION
Definition as_policy.h:340
@ AS_POLICY_READ_MODE_SC_ALLOW_UNAVAILABLE
Definition as_policy.h:358
@ AS_POLICY_READ_MODE_SC_LINEARIZE
Definition as_policy.h:346
@ AS_POLICY_EXISTS_UPDATE
Definition as_policy.h:252
@ AS_POLICY_EXISTS_IGNORE
Definition as_policy.h:242
@ AS_POLICY_EXISTS_REPLACE
Definition as_policy.h:257
@ AS_POLICY_EXISTS_CREATE
Definition as_policy.h:247
@ AS_POLICY_EXISTS_CREATE_OR_REPLACE
Definition as_policy.h:262
@ AS_QUERY_DURATION_LONG
Definition as_policy.h:404
@ AS_QUERY_DURATION_LONG_RELAX_AP
Definition as_policy.h:424
@ AS_QUERY_DURATION_SHORT
Definition as_policy.h:418
@ AS_POLICY_RETRY_ONCE
Definition as_policy.h:161
@ AS_POLICY_RETRY_NONE
Definition as_policy.h:155
@ AS_POLICY_KEY_SEND
Definition as_policy.h:225
@ AS_POLICY_KEY_DIGEST
Definition as_policy.h:210
@ AS_POLICY_REPLICA_PREFER_RACK
Definition as_policy.h:301
@ AS_POLICY_REPLICA_ANY
Definition as_policy.h:284
@ AS_POLICY_REPLICA_MASTER
Definition as_policy.h:278
@ AS_POLICY_REPLICA_SEQUENCE
Definition as_policy.h:292
@ AS_POLICY_READ_MODE_AP_ONE
Definition as_policy.h:318
@ AS_POLICY_READ_MODE_AP_ALL
Definition as_policy.h:323
as_policy_scan scan
Definition as_policy.h:1588
as_policy_admin admin
Definition as_policy.h:1603
as_policies * as_policies_init(as_policies *p)
void as_policies_destroy(as_policies *p)
as_policy_batch batch
Definition as_policy.h:1563
as_policy_write write
Definition as_policy.h:1543
as_policy_batch batch_parent_write
Definition as_policy.h:1568
as_policy_remove remove
Definition as_policy.h:1553
as_policy_apply apply
Definition as_policy.h:1558
as_policy_query query
Definition as_policy.h:1593
as_policy_batch_apply batch_apply
Definition as_policy.h:1578
as_policy_txn_roll txn_roll
Definition as_policy.h:1614
as_policy_operate operate
Definition as_policy.h:1548
as_policy_txn_verify txn_verify
Definition as_policy.h:1608
as_policy_info info
Definition as_policy.h:1598
as_policy_batch_remove batch_remove
Definition as_policy.h:1583
as_policy_read read
Definition as_policy.h:1538
as_policy_batch_write batch_write
Definition as_policy.h:1573
static void as_policy_admin_copy(const as_policy_admin *src, as_policy_admin *trg)
Definition as_policy.h:2110
static as_policy_admin * as_policy_admin_init(as_policy_admin *p)
Definition as_policy.h:2095
uint32_t timeout
Definition as_policy.h:1510
as_policy_base base
Definition as_policy.h:721
static as_policy_apply * as_policy_apply_init(as_policy_apply *p)
Definition as_policy.h:1841
as_policy_key key
Definition as_policy.h:726
static void as_policy_apply_copy(const as_policy_apply *src, as_policy_apply *trg)
Definition as_policy.h:1862
as_policy_commit_level commit_level
Definition as_policy.h:737
as_policy_replica replica
Definition as_policy.h:731
uint32_t socket_timeout
Definition as_policy.h:449
struct as_exp * filter_exp
Definition as_policy.h:530
uint32_t total_timeout
Definition as_policy.h:464
uint32_t sleep_between_retries
Definition as_policy.h:506
struct as_txn * txn
Definition as_policy.h:538
uint32_t max_retries
Definition as_policy.h:486
struct as_exp * filter_exp
Definition as_policy.h:1249
static as_policy_batch_apply * as_policy_batch_apply_init(as_policy_batch_apply *p)
Definition as_policy.h:1959
as_policy_commit_level commit_level
Definition as_policy.h:1260
as_policy_key key
Definition as_policy.h:1254
as_policy_read_mode_ap read_mode_ap
Definition as_policy.h:1126
struct as_exp * filter_exp
Definition as_policy.h:1120
as_policy_read_mode_sc read_mode_sc
Definition as_policy.h:1132
static as_policy_batch_read * as_policy_batch_read_init(as_policy_batch_read *p)
Definition as_policy.h:1927
struct as_exp * filter_exp
Definition as_policy.h:1314
as_policy_commit_level commit_level
Definition as_policy.h:1325
static as_policy_batch_remove * as_policy_batch_remove_init(as_policy_batch_remove *p)
Definition as_policy.h:1975
static as_policy_batch_write * as_policy_batch_write_init(as_policy_batch_write *p)
Definition as_policy.h:1941
as_policy_exists exists
Definition as_policy.h:1194
as_policy_commit_level commit_level
Definition as_policy.h:1184
as_policy_key key
Definition as_policy.h:1178
as_policy_gen gen
Definition as_policy.h:1189
struct as_exp * filter_exp
Definition as_policy.h:1173
static as_policy_batch * as_policy_batch_parent_write_init(as_policy_batch *p)
Definition as_policy.h:1901
as_policy_read_mode_ap read_mode_ap
Definition as_policy.h:985
as_policy_replica replica
Definition as_policy.h:979
as_policy_base base
Definition as_policy.h:974
as_policy_read_mode_sc read_mode_sc
Definition as_policy.h:991
int read_touch_ttl_percent
Definition as_policy.h:1012
static void as_policy_batch_copy(const as_policy_batch *src, as_policy_batch *trg)
Definition as_policy.h:1917
static as_policy_batch * as_policy_batch_init(as_policy_batch *p)
Definition as_policy.h:1876
static as_policy_info * as_policy_info_init(as_policy_info *p)
Definition as_policy.h:2064
uint32_t timeout
Definition as_policy.h:1486
static void as_policy_info_copy(const as_policy_info *src, as_policy_info *trg)
Definition as_policy.h:2081
as_policy_gen gen
Definition as_policy.h:818
as_policy_replica replica
Definition as_policy.h:795
static void as_policy_operate_copy(const as_policy_operate *src, as_policy_operate *trg)
Definition as_policy.h:1792
as_policy_read_mode_ap read_mode_ap
Definition as_policy.h:801
as_policy_base base
Definition as_policy.h:785
as_policy_read_mode_sc read_mode_sc
Definition as_policy.h:807
as_policy_commit_level commit_level
Definition as_policy.h:813
as_policy_key key
Definition as_policy.h:790
as_policy_exists exists
Definition as_policy.h:823
static as_policy_operate * as_policy_operate_init(as_policy_operate *p)
Definition as_policy.h:1763
as_query_duration expected_duration
Definition as_policy.h:1379
uint32_t info_timeout
Definition as_policy.h:1366
static void as_policy_query_copy(const as_policy_query *src, as_policy_query *trg)
Definition as_policy.h:2050
static as_policy_query * as_policy_query_init(as_policy_query *p)
Definition as_policy.h:2029
as_policy_replica replica
Definition as_policy.h:1371
as_policy_base base
Definition as_policy.h:1358
bool fail_on_cluster_change
Definition as_policy.h:1387
as_policy_key key
Definition as_policy.h:571
static as_policy_read * as_policy_read_init(as_policy_read *p)
Definition as_policy.h:1689
bool async_heap_rec
Definition as_policy.h:627
as_policy_read_mode_sc read_mode_sc
Definition as_policy.h:588
static void as_policy_read_copy(const as_policy_read *src, as_policy_read *trg)
Definition as_policy.h:1711
int read_touch_ttl_percent
Definition as_policy.h:609
as_policy_read_mode_ap read_mode_ap
Definition as_policy.h:582
as_policy_replica replica
Definition as_policy.h:576
as_policy_base base
Definition as_policy.h:566
static void as_policy_remove_copy(const as_policy_remove *src, as_policy_remove *trg)
Definition as_policy.h:1827
uint16_t generation
Definition as_policy.h:951
as_policy_base base
Definition as_policy.h:925
as_policy_commit_level commit_level
Definition as_policy.h:941
static as_policy_remove * as_policy_remove_init(as_policy_remove *p)
Definition as_policy.h:1806
as_policy_gen gen
Definition as_policy.h:946
as_policy_replica replica
Definition as_policy.h:935
as_policy_key key
Definition as_policy.h:930
as_policy_base base
Definition as_policy.h:1427
static as_policy_scan * as_policy_scan_init(as_policy_scan *p)
Definition as_policy.h:1995
uint64_t max_records
Definition as_policy.h:1437
uint32_t records_per_second
Definition as_policy.h:1445
as_policy_replica replica
Definition as_policy.h:1450
static void as_policy_scan_copy(const as_policy_scan *src, as_policy_scan *trg)
Definition as_policy.h:2015
as_policy_gen gen
Definition as_policy.h:662
as_policy_exists exists
Definition as_policy.h:667
uint32_t compression_threshold
Definition as_policy.h:686
static as_policy_write * as_policy_write_init(as_policy_write *p)
Definition as_policy.h:1725
as_policy_key key
Definition as_policy.h:646
as_policy_base base
Definition as_policy.h:641
static void as_policy_write_copy(const as_policy_write *src, as_policy_write *trg)
Definition as_policy.h:1749
as_policy_replica replica
Definition as_policy.h:651
as_policy_commit_level commit_level
Definition as_policy.h:657