-
Notifications
You must be signed in to change notification settings - Fork 288
/
Copy pathcassandra.h
10016 lines (9338 loc) · 275 KB
/
cassandra.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (c) 2014-2016 DataStax
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __CASSANDRA_H_INCLUDED__
#define __CASSANDRA_H_INCLUDED__
#include <stddef.h>
#if !defined(CASS_STATIC)
# if (defined(WIN32) || defined(_WIN32))
# if defined(CASS_BUILDING)
# define CASS_EXPORT __declspec(dllexport)
# else
# define CASS_EXPORT __declspec(dllexport)
# endif
# elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) && !defined(CASS_STATIC)
# define CASS_EXPORT __global
# elif (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER)
# define CASS_EXPORT __attribute__ ((visibility("default")))
# endif
#else
#define CASS_EXPORT
#endif
#if defined(_MSC_VER)
# define CASS_DEPRECATED(func) __declspec(deprecated) func
#elif defined(__GNUC__) || defined(__INTEL_COMPILER)
# define CASS_DEPRECATED(func) func __attribute__((deprecated))
#else
# define CASS_DEPRECATED(func) func
#endif
/**
* @file include/cassandra.h
*
* C/C++ driver for Apache Cassandra. Uses the Cassandra Query Language versions 3
* over the Cassandra Binary Protocol (versions 1, 2, or 3).
*/
#define CASS_VERSION_MAJOR 2
#define CASS_VERSION_MINOR 7
#define CASS_VERSION_PATCH 0
#define CASS_VERSION_SUFFIX ""
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { cass_false = 0, cass_true = 1 } cass_bool_t;
typedef float cass_float_t;
typedef double cass_double_t;
#if defined(__INT8_TYPE__) && defined(__UINT8_TYPE__)
typedef __INT8_TYPE__ cass_int8_t;
typedef __UINT8_TYPE__ cass_uint8_t;
#elif defined(__INT8_TYPE__)
typedef signed __INT8_TYPE__ cass_int8_t;
typedef unsigned __INT8_TYPE__ cass_uint8_t;
#else
typedef signed char cass_int8_t;
typedef unsigned char cass_uint8_t;
#endif
#if defined(__INT16_TYPE__) && defined(__UINT16_TYPE__)
typedef __INT16_TYPE__ cass_int16_t;
typedef __UINT16_TYPE__ cass_uint16_t;
#elif defined(__INT16_TYPE__)
typedef __INT16_TYPE__ cass_int16_t;
typedef unsigned __INT16_TYPE__ cass_uint16_t;
#else
typedef short cass_int16_t;
typedef unsigned short cass_uint16_t;
#endif
#if defined(__INT32_TYPE__) && defined(__UINT32_TYPE__)
typedef __INT32_TYPE__ cass_int32_t;
typedef __UINT32_TYPE__ cass_uint32_t;
#elif defined(__INT32_TYPE__)
typedef __INT32_TYPE__ cass_int32_t;
typedef unsigned __INT32_TYPE__ cass_uint32_t;
#else
typedef int cass_int32_t;
typedef unsigned int cass_uint32_t;
#endif
#if defined(__INT64_TYPE__) && defined(__UINT64_TYPE__)
typedef __INT64_TYPE__ cass_int64_t;
typedef __UINT64_TYPE__ cass_uint64_t;
#elif defined(__INT64_TYPE__)
typedef __INT64_TYPE__ cass_int64_t;
typedef unsigned __INT64_TYPE__ cass_uint64_t;
#elif defined(__GNUC__)
# if defined(__x86_64__)
typedef long int cass_int64_t;
typedef unsigned long int cass_uint64_t;
# else
typedef long long int cass_int64_t;
typedef unsigned long long int cass_uint64_t;
# endif
#else
typedef long long cass_int64_t;
typedef unsigned long long cass_uint64_t;
#endif
#define CASS_UINT64_MAX 18446744073709551615ULL
typedef cass_uint8_t cass_byte_t;
typedef cass_uint64_t cass_duration_t;
/**
* The size of an IPv4 address
*/
#define CASS_INET_V4_LENGTH 4
/**
* The size of an IPv6 address
*/
#define CASS_INET_V6_LENGTH 16
/**
* The size of an inet string including a null terminator.
*/
#define CASS_INET_STRING_LENGTH 46
/**
* IP address for either IPv4 or IPv6.
*
* @struct CassInet
*/
typedef struct CassInet_ {
/**
* Big-endian, binary representation of a IPv4 or IPv6 address
*/
cass_uint8_t address[CASS_INET_V6_LENGTH];
/**
* Number of address bytes. 4 bytes for IPv4 and 16 bytes for IPv6.
*/
cass_uint8_t address_length;
} CassInet;
/**
* The size of a hexadecimal UUID string including a null terminator.
*/
#define CASS_UUID_STRING_LENGTH 37
/**
* Version 1 (time-based) or version 4 (random) UUID.
*
* @struct CassUuid
*/
typedef struct CassUuid_ {
/**
* Represents the time and version part of a UUID. The most significant
* 4 bits represent the version and the bottom 60 bits representing the
* time part. For version 1 the time part represents the number of
* 100 nanosecond periods since 00:00:00 UTC, January 1, 1970 (the Epoch).
* For version 4 the time part is randomly generated.
*/
cass_uint64_t time_and_version;
/**
* Represents the clock sequence and the node part of a UUID. The most
* significant 16 bits represent the clock sequence (except for the most
* significant bit which is always set) and the bottom 48 bits represent
* the node part. For version 1 (time-based) the clock sequence part is randomly
* generated and the node part can be explicitly set, otherwise, it's generated
* from node unique information. For version 4 both the clock sequence and the node
* parts are randomly generated.
*/
cass_uint64_t clock_seq_and_node;
} CassUuid;
/**
* A cluster object describes the configuration of the Cassandra cluster and is used
* to construct a session instance. Unlike other DataStax drivers the cluster object
* does not maintain the control connection.
*
* @struct CassCluster
*/
typedef struct CassCluster_ CassCluster;
/**
* A session object is used to execute queries and maintains cluster state through
* the control connection. The control connection is used to auto-discover nodes and
* monitor cluster changes (topology and schema). Each session also maintains multiple
* pools of connections to cluster nodes which are used to query the cluster.
*
* Instances of the session object are thread-safe to execute queries.
*
* @struct CassSession
*/
typedef struct CassSession_ CassSession;
/**
* A statement object is an executable query. It represents either a regular
* (adhoc) statement or a prepared statement. It maintains the queries' parameter
* values along with query options (consistency level, paging state, etc.)
*
* <b>Note:</b> Parameters for regular queries are not supported by the binary protocol
* version 1.
*
* @struct CassStatement
*/
typedef struct CassStatement_ CassStatement;
/**
* A group of statements that are executed as a single batch.
*
* <b>Note:</b> Batches are not supported by the binary protocol version 1.
*
* @cassandra{2.0+}
*
* @struct CassBatch
*/
typedef struct CassBatch_ CassBatch;
/**
* The future result of an operation.
*
* It can represent a result if the operation completed successfully or an
* error if the operation failed. It can be waited on, polled or a callback
* can be attached.
*
* @struct CassFuture
*/
typedef struct CassFuture_ CassFuture;
/**
* A statement that has been prepared cluster-side (It has been pre-parsed
* and cached).
*
* A prepared statement is read-only and it is thread-safe to concurrently
* bind new statements.
*
* @struct CassPrepared
*/
typedef struct CassPrepared_ CassPrepared;
/**
* The result of a query.
*
* A result object is read-only and is thread-safe to read or iterate over
* concurrently.
*
* @struct CassResult
*/
typedef struct CassResult_ CassResult;
/**
* A error result of a request
*
* @struct CassErrorResult
*/
typedef struct CassErrorResult_ CassErrorResult;
/**
* An object used to iterate over a group of rows, columns or collection values.
*
* @struct CassIterator
*/
typedef struct CassIterator_ CassIterator;
/**
* A collection of column values.
*
* @struct CassRow
*/
typedef struct CassRow_ CassRow;
/**
* A single primitive value or a collection of values.
*
* @struct CassValue
*/
typedef struct CassValue_ CassValue;
/**
* A data type used to describe a value, collection or
* user defined type.
*
* @struct CassDataType
*/
typedef struct CassDataType_ CassDataType;
/**
* @struct CassFunctionMeta
*
* @cassandra{2.2+}
*/
typedef struct CassFunctionMeta_ CassFunctionMeta;
/**
* @struct CassAggregateMeta
*
* @cassandra{2.2+}
*/
typedef struct CassAggregateMeta_ CassAggregateMeta;
/**
* A collection of values.
*
* @struct CassCollection
*/
typedef struct CassCollection_ CassCollection;
/**
* A tuple of values.
*
* @struct CassTuple
*
* @cassandra{2.1+}
*/
typedef struct CassTuple_ CassTuple;
/**
* A user defined type.
*
* @struct CassUserType
*
* @cassandra{2.1+}
*/
typedef struct CassUserType_ CassUserType;
/**
* Describes the SSL configuration of a cluster.
*
* @struct CassSsl
*/
typedef struct CassSsl_ CassSsl;
/**
* Describes the version of the connected Cassandra cluster.
*
* @struct CassVersion
*/
typedef struct CassVersion_ {
int major_version;
int minor_version;
int patch_version;
} CassVersion;
/**
* A snapshot of the schema's metadata.
*
* @struct CassSchemaMeta
*/
typedef struct CassSchemaMeta_ CassSchemaMeta;
/**
* Keyspace metadata
*
* @struct CassKeyspaceMeta
*/
typedef struct CassKeyspaceMeta_ CassKeyspaceMeta;
/**
* Table metadata
*
* @struct CassTableMeta
*/
typedef struct CassTableMeta_ CassTableMeta;
/**
* MaterializedView metadata
*
* @struct CassMaterializedViewMeta
*
* @cassandra{3.0+}
*/
typedef struct CassMaterializedViewMeta_ CassMaterializedViewMeta;
/**
* Column metadata
*
* @struct CassColumnMeta
*/
typedef struct CassColumnMeta_ CassColumnMeta;
/**
* Index metadata
*
* @struct CassIndexMeta
*/
typedef struct CassIndexMeta_ CassIndexMeta;
/**
* A UUID generator object.
*
* Instances of the UUID generator object are thread-safe to generate UUIDs.
*
* @struct CassUuidGen
*/
typedef struct CassUuidGen_ CassUuidGen;
/**
* Policies that defined the behavior of a request when a server-side
* read/write timeout or unavailable error occurs.
*
* Generators of client-side, microsecond-precision timestamps.
*
* @struct CassTimestampGen
*
* @cassandra{2.1+}
*/
typedef struct CassTimestampGen_ CassTimestampGen;
/**
* @struct CassRetryPolicy
*/
typedef struct CassRetryPolicy_ CassRetryPolicy;
/**
* @struct CassCustomPayload
*
* @cassandra{2.2+}
*/
typedef struct CassCustomPayload_ CassCustomPayload;
/**
* A snapshot of the session's performance/diagnostic metrics.
*
* @struct CassMetrics
*/
typedef struct CassMetrics_ {
struct {
cass_uint64_t min; /**< Minimum in microseconds */
cass_uint64_t max; /**< Maximum in microseconds */
cass_uint64_t mean; /**< Mean in microseconds */
cass_uint64_t stddev; /**< Standard deviation in microseconds */
cass_uint64_t median; /**< Median in microseconds */
cass_uint64_t percentile_75th; /**< 75th percentile in microseconds */
cass_uint64_t percentile_95th; /**< 95th percentile in microseconds */
cass_uint64_t percentile_98th; /**< 98th percentile in microseconds */
cass_uint64_t percentile_99th; /**< 99the percentile in microseconds */
cass_uint64_t percentile_999th; /**< 99.9th percentile in microseconds */
cass_double_t mean_rate; /**< Mean rate in requests per second*/
cass_double_t one_minute_rate; /**< 1 minute rate in requests per second */
cass_double_t five_minute_rate; /**< 5 minute rate in requests per second*/
cass_double_t fifteen_minute_rate; /**< 15 minute rate in requests per second*/
} requests;
struct {
cass_uint64_t total_connections; /**< The total number of connections */
cass_uint64_t available_connections; /**< The number of connections available to take requests */
cass_uint64_t exceeded_pending_requests_water_mark; /**< Occurrences when requests exceeded a pool's water mark */
cass_uint64_t exceeded_write_bytes_water_mark; /**< Occurrences when number of bytes exceeded a connection's water mark */
} stats;
struct {
cass_uint64_t connection_timeouts; /**< Occurrences of a connection timeout */
cass_uint64_t pending_request_timeouts; /** Occurrences of requests that timed out waiting for a connection */
cass_uint64_t request_timeouts; /** Occurrences of requests that timed out waiting for a request to finish */
} errors;
} CassMetrics;
typedef enum CassConsistency_ {
CASS_CONSISTENCY_UNKNOWN = 0xFFFF,
CASS_CONSISTENCY_ANY = 0x0000,
CASS_CONSISTENCY_ONE = 0x0001,
CASS_CONSISTENCY_TWO = 0x0002,
CASS_CONSISTENCY_THREE = 0x0003,
CASS_CONSISTENCY_QUORUM = 0x0004,
CASS_CONSISTENCY_ALL = 0x0005,
CASS_CONSISTENCY_LOCAL_QUORUM = 0x0006,
CASS_CONSISTENCY_EACH_QUORUM = 0x0007,
CASS_CONSISTENCY_SERIAL = 0x0008,
CASS_CONSISTENCY_LOCAL_SERIAL = 0x0009,
CASS_CONSISTENCY_LOCAL_ONE = 0x000A
} CassConsistency;
#define CASS_CONSISTENCY_MAPPING(XX) \
XX(CASS_CONSISTENCY_UNKNOWN, "UNKNOWN") \
XX(CASS_CONSISTENCY_ANY, "ANY") \
XX(CASS_CONSISTENCY_ONE, "ONE") \
XX(CASS_CONSISTENCY_TWO, "TWO") \
XX(CASS_CONSISTENCY_THREE, "THREE") \
XX(CASS_CONSISTENCY_QUORUM, "QUORUM") \
XX(CASS_CONSISTENCY_ALL, "ALL") \
XX(CASS_CONSISTENCY_LOCAL_QUORUM, "LOCAL_QUORUM") \
XX(CASS_CONSISTENCY_EACH_QUORUM, "EACH_QUORUM") \
XX(CASS_CONSISTENCY_SERIAL, "SERIAL") \
XX(CASS_CONSISTENCY_LOCAL_SERIAL, "LOCAL_SERIAL") \
XX(CASS_CONSISTENCY_LOCAL_ONE, "LOCAL_ONE")
/* @cond IGNORE */
#define CASS_CONSISTENCY_MAP CASS_CONSISTENCY_MAPPING /* Deprecated */
/* @endcond */
typedef enum CassWriteType_ {
CASS_WRITE_TYPE_UNKNOWN,
CASS_WRITE_TYPE_SIMPLE,
CASS_WRITE_TYPE_BATCH,
CASS_WRITE_TYPE_UNLOGGED_BATCH,
CASS_WRITE_TYPE_COUNTER,
CASS_WRITE_TYPE_BATCH_LOG,
CASS_WRITE_TYPE_CAS,
CASS_WRITE_TYPE_VIEW,
CASS_WRITE_TYPE_CDC
} CassWriteType;
#define CASS_WRITE_TYPE_MAPPING(XX) \
XX(CASS_WRITE_TYPE_SIMPLE, "SIMPLE") \
XX(CASS_WRITE_TYPE_BATCH, "BATCH") \
XX(CASS_WRITE_TYPE_UNLOGGED_BATCH, "UNLOGGED_BATCH") \
XX(CASS_WRITE_TYPE_COUNTER, "COUNTER") \
XX(CASS_WRITE_TYPE_BATCH_LOG, "BATCH_LOG") \
XX(CASS_WRITE_TYPE_CAS, "CAS") \
XX(CASS_WRITE_TYPE_VIEW, "VIEW") \
XX(CASS_WRITE_TYPE_CDC, "CDC")
/* @cond IGNORE */
#define CASS_WRITE_TYPE_MAP CASS_WRITE_TYPE_MAPPING /* Deprecated */
/* @endcond */
typedef enum CassColumnType_ {
CASS_COLUMN_TYPE_REGULAR,
CASS_COLUMN_TYPE_PARTITION_KEY,
CASS_COLUMN_TYPE_CLUSTERING_KEY,
CASS_COLUMN_TYPE_STATIC,
CASS_COLUMN_TYPE_COMPACT_VALUE
} CassColumnType;
typedef enum CassIndexType_ {
CASS_INDEX_TYPE_UNKNOWN,
CASS_INDEX_TYPE_KEYS,
CASS_INDEX_TYPE_CUSTOM,
CASS_INDEX_TYPE_COMPOSITES
} CassIndexType;
#define CASS_VALUE_TYPE_MAPPING(XX) \
XX(CASS_VALUE_TYPE_CUSTOM, 0x0000, "", "") \
XX(CASS_VALUE_TYPE_ASCII, 0x0001, "ascii", "org.apache.cassandra.db.marshal.AsciiType") \
XX(CASS_VALUE_TYPE_BIGINT, 0x0002, "bigint", "org.apache.cassandra.db.marshal.LongType") \
XX(CASS_VALUE_TYPE_BLOB, 0x0003, "blob", "org.apache.cassandra.db.marshal.BytesType") \
XX(CASS_VALUE_TYPE_BOOLEAN, 0x0004, "boolean", "org.apache.cassandra.db.marshal.BooleanType") \
XX(CASS_VALUE_TYPE_COUNTER, 0x0005, "counter", "org.apache.cassandra.db.marshal.CounterColumnType") \
XX(CASS_VALUE_TYPE_DECIMAL, 0x0006, "decimal", "org.apache.cassandra.db.marshal.DecimalType") \
XX(CASS_VALUE_TYPE_DOUBLE, 0x0007, "double", "org.apache.cassandra.db.marshal.DoubleType") \
XX(CASS_VALUE_TYPE_FLOAT, 0x0008, "float", "org.apache.cassandra.db.marshal.FloatType") \
XX(CASS_VALUE_TYPE_INT, 0x0009, "int", "org.apache.cassandra.db.marshal.Int32Type") \
XX(CASS_VALUE_TYPE_TEXT, 0x000A, "text", "org.apache.cassandra.db.marshal.UTF8Type") \
XX(CASS_VALUE_TYPE_TIMESTAMP, 0x000B, "timestamp", "org.apache.cassandra.db.marshal.TimestampType") \
XX(CASS_VALUE_TYPE_UUID, 0x000C, "uuid", "org.apache.cassandra.db.marshal.UUIDType") \
XX(CASS_VALUE_TYPE_VARCHAR, 0x000D, "varchar", "") \
XX(CASS_VALUE_TYPE_VARINT, 0x000E, "varint", "org.apache.cassandra.db.marshal.IntegerType") \
XX(CASS_VALUE_TYPE_TIMEUUID, 0x000F, "timeuuid", "org.apache.cassandra.db.marshal.TimeUUIDType") \
XX(CASS_VALUE_TYPE_INET, 0x0010, "inet", "org.apache.cassandra.db.marshal.InetAddressType") \
XX(CASS_VALUE_TYPE_DATE, 0x0011, "date", "org.apache.cassandra.db.marshal.SimpleDateType") \
XX(CASS_VALUE_TYPE_TIME, 0x0012, "time", "org.apache.cassandra.db.marshal.TimeType") \
XX(CASS_VALUE_TYPE_SMALL_INT, 0x0013, "smallint", "org.apache.cassandra.db.marshal.ShortType") \
XX(CASS_VALUE_TYPE_TINY_INT, 0x0014, "tinyint", "org.apache.cassandra.db.marshal.ByteType") \
XX(CASS_VALUE_TYPE_DURATION, 0x0015, "duration", "org.apache.cassandra.db.marshal.DurationType") \
XX(CASS_VALUE_TYPE_LIST, 0x0020, "list", "org.apache.cassandra.db.marshal.ListType") \
XX(CASS_VALUE_TYPE_MAP, 0x0021, "map", "org.apache.cassandra.db.marshal.MapType") \
XX(CASS_VALUE_TYPE_SET, 0x0022, "set", "org.apache.cassandra.db.marshal.SetType") \
XX(CASS_VALUE_TYPE_UDT, 0x0030, "", "") \
XX(CASS_VALUE_TYPE_TUPLE, 0x0031, "tuple", "org.apache.cassandra.db.marshal.TupleType")
typedef enum CassValueType_ {
CASS_VALUE_TYPE_UNKNOWN = 0xFFFF,
#define XX_VALUE_TYPE(name, type, cql, klass) name = type,
CASS_VALUE_TYPE_MAPPING(XX_VALUE_TYPE)
#undef XX_VALUE_TYPE
/* @cond IGNORE */
CASS_VALUE_TYPE_LAST_ENTRY
/* @endcond */
} CassValueType;
typedef enum CassClusteringOrder_ {
CASS_CLUSTERING_ORDER_NONE,
CASS_CLUSTERING_ORDER_ASC,
CASS_CLUSTERING_ORDER_DESC
} CassClusteringOrder;
typedef enum CassCollectionType_ {
CASS_COLLECTION_TYPE_LIST = CASS_VALUE_TYPE_LIST,
CASS_COLLECTION_TYPE_MAP = CASS_VALUE_TYPE_MAP,
CASS_COLLECTION_TYPE_SET = CASS_VALUE_TYPE_SET
} CassCollectionType;
typedef enum CassBatchType_ {
CASS_BATCH_TYPE_LOGGED = 0x00,
CASS_BATCH_TYPE_UNLOGGED = 0x01,
CASS_BATCH_TYPE_COUNTER = 0x02
} CassBatchType;
typedef enum CassIteratorType_ {
CASS_ITERATOR_TYPE_RESULT,
CASS_ITERATOR_TYPE_ROW,
CASS_ITERATOR_TYPE_COLLECTION,
CASS_ITERATOR_TYPE_MAP,
CASS_ITERATOR_TYPE_TUPLE,
CASS_ITERATOR_TYPE_USER_TYPE_FIELD,
CASS_ITERATOR_TYPE_META_FIELD,
CASS_ITERATOR_TYPE_KEYSPACE_META,
CASS_ITERATOR_TYPE_TABLE_META,
CASS_ITERATOR_TYPE_TYPE_META,
CASS_ITERATOR_TYPE_FUNCTION_META,
CASS_ITERATOR_TYPE_AGGREGATE_META,
CASS_ITERATOR_TYPE_COLUMN_META,
CASS_ITERATOR_TYPE_INDEX_META,
CASS_ITERATOR_TYPE_MATERIALIZED_VIEW_META
} CassIteratorType;
#define CASS_LOG_LEVEL_MAPPING(XX) \
XX(CASS_LOG_DISABLED, "") \
XX(CASS_LOG_CRITICAL, "CRITICAL") \
XX(CASS_LOG_ERROR, "ERROR") \
XX(CASS_LOG_WARN, "WARN") \
XX(CASS_LOG_INFO, "INFO") \
XX(CASS_LOG_DEBUG, "DEBUG") \
XX(CASS_LOG_TRACE, "TRACE")
/* @cond IGNORE */
#define CASS_LOG_LEVEL_MAP CASS_LOG_LEVEL_MAPPING /* Deprecated */
/* @endcond */
typedef enum CassLogLevel_ {
#define XX_LOG(log_level, _) log_level,
CASS_LOG_LEVEL_MAPPING(XX_LOG)
#undef XX_LOG
/* @cond IGNORE */
CASS_LOG_LAST_ENTRY
/* @endcond */
} CassLogLevel;
typedef enum CassSslVerifyFlags_ {
CASS_SSL_VERIFY_NONE = 0x00,
CASS_SSL_VERIFY_PEER_CERT = 0x01,
CASS_SSL_VERIFY_PEER_IDENTITY = 0x02,
CASS_SSL_VERIFY_PEER_IDENTITY_DNS = 0x04
} CassSslVerifyFlags;
typedef enum CassProtocolVersion_ {
CASS_PROTOCOL_VERSION_V1 = 0x01,
CASS_PROTOCOL_VERSION_V2 = 0x02,
CASS_PROTOCOL_VERSION_V3 = 0x03,
CASS_PROTOCOL_VERSION_V4 = 0x04
} CassProtocolVersion;
typedef enum CassErrorSource_ {
CASS_ERROR_SOURCE_NONE,
CASS_ERROR_SOURCE_LIB,
CASS_ERROR_SOURCE_SERVER,
CASS_ERROR_SOURCE_SSL,
CASS_ERROR_SOURCE_COMPRESSION
} CassErrorSource;
#define CASS_ERROR_MAPPING(XX) \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_BAD_PARAMS, 1, "Bad parameters") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_STREAMS, 2, "No streams available") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_INIT, 3, "Unable to initialize") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_MESSAGE_ENCODE, 4, "Unable to encode message") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_HOST_RESOLUTION, 5, "Unable to resolve host") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNEXPECTED_RESPONSE, 6, "Unexpected response from server") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_REQUEST_QUEUE_FULL, 7, "The request queue is full") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_AVAILABLE_IO_THREAD, 8, "No available IO threads") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_WRITE_ERROR, 9, "Write error") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_HOSTS_AVAILABLE, 10, "No hosts available") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INDEX_OUT_OF_BOUNDS, 11, "Index out of bounds") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_ITEM_COUNT, 12, "Invalid item count") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_VALUE_TYPE, 13, "Invalid value type") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_REQUEST_TIMED_OUT, 14, "Request timed out") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_SET_KEYSPACE, 15, "Unable to set keyspace") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_CALLBACK_ALREADY_SET, 16, "Callback already set") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_STATEMENT_TYPE, 17, "Invalid statement type") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NAME_DOES_NOT_EXIST, 18, "No value or column for name") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_DETERMINE_PROTOCOL, 19, "Unable to find supported protocol version") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NULL_VALUE, 20, "NULL value specified") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NOT_IMPLEMENTED, 21, "Not implemented") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_CONNECT, 22, "Unable to connect") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_CLOSE, 23, "Unable to close") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_PAGING_STATE, 24, "No paging state") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_PARAMETER_UNSET, 25, "Parameter unset") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_ERROR_RESULT_TYPE, 26, "Invalid error result type") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_FUTURE_TYPE, 27, "Invalid future type") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INTERNAL_ERROR, 28, "Internal error") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_CUSTOM_TYPE, 29, "Invalid custom type") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_DATA, 30, "Invalid data") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NOT_ENOUGH_DATA, 31, "Not enough data") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_STATE, 32, "Invalid state") \
XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_CUSTOM_PAYLOAD, 33, "No custom payload") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_SERVER_ERROR, 0x0000, "Server error") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_PROTOCOL_ERROR, 0x000A, "Protocol error") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_BAD_CREDENTIALS, 0x0100, "Bad credentials") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_UNAVAILABLE, 0x1000, "Unavailable") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_OVERLOADED, 0x1001, "Overloaded") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_IS_BOOTSTRAPPING, 0x1002, "Is bootstrapping") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_TRUNCATE_ERROR, 0x1003, "Truncate error") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_WRITE_TIMEOUT, 0x1100, "Write timeout") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_READ_TIMEOUT, 0x1200, "Read timeout") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_READ_FAILURE, 0x1300, "Read failure") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_FUNCTION_FAILURE, 0x1400, "Function failure") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_WRITE_FAILURE, 0x1500, "Write failure") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_SYNTAX_ERROR, 0x2000, "Syntax error") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_UNAUTHORIZED, 0x2100, "Unauthorized") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_INVALID_QUERY, 0x2200, "Invalid query") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_CONFIG_ERROR, 0x2300, "Configuration error") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_ALREADY_EXISTS, 0x2400, "Already exists") \
XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_UNPREPARED, 0x2500, "Unprepared") \
XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_INVALID_CERT, 1, "Unable to load certificate") \
XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_INVALID_PRIVATE_KEY, 2, "Unable to load private key") \
XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_NO_PEER_CERT, 3, "No peer certificate") \
XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_INVALID_PEER_CERT, 4, "Invalid peer certificate") \
XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_IDENTITY_MISMATCH, 5, "Certificate does not match host or IP address") \
XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_PROTOCOL_ERROR, 6, "Protocol error")
/* @cond IGNORE */
#define CASS_ERROR_MAP CASS_ERROR_MAPPING /* Deprecated */
/* @endcond*/
#define CASS_ERROR(source, code) ((source << 24) | code)
typedef enum CassError_ {
CASS_OK = 0,
#define XX_ERROR(source, name, code, _) name = CASS_ERROR(source, code),
CASS_ERROR_MAPPING(XX_ERROR)
#undef XX_ERROR
/* @cond IGNORE */
CASS_ERROR_LAST_ENTRY
/* @endcond*/
} CassError;
/**
* A callback that's notified when the future is set.
*
* @param[in] message
* @param[in] data user defined data provided when the callback
* was registered.
*
* @see cass_future_set_callback()
*/
typedef void (*CassFutureCallback)(CassFuture* future,
void* data);
/**
* Maximum size of a log message
*/
#define CASS_LOG_MAX_MESSAGE_SIZE 1024
/**
* A log message.
*/
typedef struct CassLogMessage_ {
/**
* The millisecond timestamp (since the Epoch) when the message was logged
*/
cass_uint64_t time_ms;
CassLogLevel severity; /**< The severity of the log message */
const char* file; /**< The file where the message was logged */
int line; /**< The line in the file where the message was logged */
const char* function; /**< The function where the message was logged */
char message[CASS_LOG_MAX_MESSAGE_SIZE]; /**< The message */
} CassLogMessage;
/**
* A callback that's used to handle logging.
*
* @param[in] message
* @param[in] data user defined data provided when the callback
* was registered.
*
* @see cass_log_set_callback();
*/
typedef void (*CassLogCallback)(const CassLogMessage* message,
void* data);
/**
* An authenticator.
*
* @struct CassAuthenticator
*/
typedef struct CassAuthenticator_ CassAuthenticator;
/**
* A callback used to initiate an authentication exchange.
*
* Use cass_authenticator_set_response() to set the response token.
*
* Use cass_authenticator_set_error() if an error occured during initialization.
*
* @param[in] auth
* @param[in] data
*/
typedef void (*CassAuthenticatorInitialCallback)(CassAuthenticator* auth,
void* data);
/**
* A callback used when an authentication challenge initiated
* by the server.
*
* Use cass_authenticator_set_response() to set the response token.
*
* Use cass_authenticator_set_error() if an error occured during the challenge.
*
* @param[in] auth
* @param[in] data
* @param[in] token
* @param[in] token_size
*/
typedef void (*CassAuthenticatorChallengeCallback)(CassAuthenticator* auth,
void* data,
const char* token,
size_t token_size);
/**
* A callback used to indicate the success of the authentication
* exchange.
*
* Use cass_authenticator_set_error() if an error occured while evaluating
* the success token.
*
* @param[in] auth
* @param[in] data
* @param[in] token
* @param[in] token_size
*/
typedef void (*CassAuthenticatorSuccessCallback)(CassAuthenticator* auth,
void* data,
const char* token,
size_t token_size);
/**
* A callback used to cleanup resources that were acquired during
* the process of the authentication exchange. This is called after
* the termination of the exchange regardless of the outcome.
*
* @param[in] auth
* @param[in] data
*/
typedef void (*CassAuthenticatorCleanupCallback)(CassAuthenticator* auth,
void* data);
/**
* A callback used to cleanup resources.
*
* @param[in] data
*/
typedef void (*CassAuthenticatorDataCleanupCallback)(void* data);
/**
* Authenticator callbacks
*/
typedef struct CassAuthenticatorCallbacks_ {
CassAuthenticatorInitialCallback initial_callback;
CassAuthenticatorChallengeCallback challenge_callback;
CassAuthenticatorSuccessCallback success_callback;
CassAuthenticatorCleanupCallback cleanup_callback;
} CassAuthenticatorCallbacks;
/***********************************************************************************
*
* Cluster
*
***********************************************************************************/
/**
* Creates a new cluster.
*
* @public @memberof CassCluster
*
* @return Returns a cluster that must be freed.
*
* @see cass_cluster_free()
*/
CASS_EXPORT CassCluster*
cass_cluster_new();
/**
* Frees a cluster instance.
*
* @public @memberof CassCluster
*
* @param[in] cluster
*/
CASS_EXPORT void
cass_cluster_free(CassCluster* cluster);
/**
* Sets/Appends contact points. This *MUST* be set. The first call sets
* the contact points and any subsequent calls appends additional contact
* points. Passing an empty string will clear the contact points. White space
* is striped from the contact points.
*
* Examples: "127.0.0.1" "127.0.0.1,127.0.0.2", "server1.domain.com"
*
* @public @memberof CassCluster
*
* @param[in] cluster
* @param[in] contact_points A comma delimited list of addresses or
* names. An empty string will clear the contact points.
* The string is copied into the cluster configuration; the memory pointed
* to by this parameter can be freed after this call.
* @return CASS_OK if successful, otherwise an error occurred.
*/
CASS_EXPORT CassError
cass_cluster_set_contact_points(CassCluster* cluster,
const char* contact_points);
/**
* Same as cass_cluster_set_contact_points(), but with lengths for string
* parameters.
*
* @public @memberof CassCluster
*
* @param[in] cluster
* @param[in] contact_points
* @param[in] contact_points_length
* @return same as cass_cluster_set_contact_points()
*
* @see cass_cluster_set_contact_points()
*/
CASS_EXPORT CassError
cass_cluster_set_contact_points_n(CassCluster* cluster,
const char* contact_points,
size_t contact_points_length);
/**
* Sets the port.
*
* <b>Default:</b> 9042
*
* @public @memberof CassCluster
*
* @param[in] cluster
* @param[in] port
* @return CASS_OK if successful, otherwise an error occurred.
*/
CASS_EXPORT CassError
cass_cluster_set_port(CassCluster* cluster,
int port);
/**
* Sets the SSL context and enables SSL.
*
* @public @memberof CassCluster
*
* @param[in] cluster
* @param[in] ssl
*
* @see cass_ssl_new()
*/
CASS_EXPORT void
cass_cluster_set_ssl(CassCluster* cluster,
CassSsl* ssl);
/**
* Sets custom authenticator
*
* @public @memberof CassCluster
*
* @param[in] cluster
* @param[in] exchange_callbacks
* @param[in] cleanup_callback
* @param[in] data
* @return CASS_OK if successful, otherwise an error occurred.
*/
CASS_EXPORT CassError
cass_cluster_set_authenticator_callbacks(CassCluster* cluster,
const CassAuthenticatorCallbacks* exchange_callbacks,
CassAuthenticatorDataCleanupCallback cleanup_callback,
void* data);
/**
* Sets the protocol version. This will automatically downgrade to the lowest
* supported protocol version.
*
* <b>Default:</b> 4
*
* @public @memberof CassCluster
*
* @param[in] cluster
* @param[in] protocol_version
* @return CASS_OK if successful, otherwise an error occurred.
*
* @see cass_cluster_set_use_beta_protocol_version()
*/
CASS_EXPORT CassError
cass_cluster_set_protocol_version(CassCluster* cluster,
int protocol_version);
/**
* Use the newest beta protocol version. This currently enables the use of
* protocol version 5.
*