Class: AerospikeNative::Scan
- Inherits:
-
Object
- Object
- AerospikeNative::Scan
- Defined in:
- ext/aerospike_native/scan.c
Constant Summary collapse
- STATUS_UNDEFINED =
INT2FIX(AS_SCAN_STATUS_UNDEF)
- STATUS_INPROGRESS =
INT2FIX(AS_SCAN_STATUS_INPROGRESS)
- STATUS_ABORTED =
INT2FIX(AS_SCAN_STATUS_ABORTED)
- STATUS_COMPLETED =
INT2FIX(AS_SCAN_STATUS_COMPLETED)
- PRIORITY_AUTO =
INT2FIX(AS_SCAN_PRIORITY_AUTO)
- PRIORITY_HIGH =
INT2FIX(AS_SCAN_PRIORITY_HIGH)
- PRIORITY_MEDIUM =
INT2FIX(AS_SCAN_PRIORITY_MEDIUM)
- PRIORITY_LOW =
INT2FIX(AS_SCAN_PRIORITY_LOW)
Instance Attribute Summary collapse
- #background ⇒ Object readonly
- #client ⇒ Object readonly
- #concurrent ⇒ Object readonly
- #no_bins ⇒ Object readonly
- #percent ⇒ Object readonly
- #priority ⇒ Object readonly
- #select_bins ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
- #exec(, vSelf) ⇒ Object
- #initialize(vClient, vNamespace, vSet) ⇒ Object constructor
- #select(, vSelf) ⇒ Object
- #set_concurrent(vValue) ⇒ Object
- #set_no_bins(vValue) ⇒ Object
- #set_percent(vValue) ⇒ Object
- #set_priority(vValue) ⇒ Object
Constructor Details
#initialize(vClient, vNamespace, vSet) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'ext/aerospike_native/scan.c', line 14 VALUE scan_initialize(VALUE vSelf, VALUE vClient, VALUE vNamespace, VALUE vSet) { Check_Type(vNamespace, T_STRING); Check_Type(vSet, T_STRING); check_aerospike_client(vClient); rb_iv_set(vSelf, "@client", vClient); rb_iv_set(vSelf, "@namespace", vNamespace); rb_iv_set(vSelf, "@set", vSet); return vSelf; } |
Instance Attribute Details
#background ⇒ Object (readonly)
#client ⇒ Object (readonly)
#concurrent ⇒ Object (readonly)
#no_bins ⇒ Object (readonly)
#percent ⇒ Object (readonly)
#priority ⇒ Object (readonly)
#select_bins ⇒ Object (readonly)
Class Method Details
.info(, vSelf) ⇒ Object
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 |
# File 'ext/aerospike_native/scan.c', line 203 VALUE scan_info(int argc, VALUE* vArgs, VALUE vSelf) { VALUE vClient, vHash; as_scan_info info; as_policy_scan policy; as_error err; aerospike* ptr; uint64_t scan_id; if (argc > 3 || argc < 2) { // there should only be 2 or 3 arguments rb_raise(rb_eArgError, "wrong number of arguments (%d for 2..3)", argc); } vClient = vArgs[0]; check_aerospike_client(vClient); Check_Type(vArgs[1], T_FIXNUM); scan_id = FIX2ULONG(vArgs[1]); as_policy_scan_init(&policy); if(argc == 3 && TYPE(vArgs[2]) != T_NIL) { SET_SCAN_POLICY(policy, vArgs[2]); } Data_Get_Struct(vClient, aerospike, ptr); if (aerospike_scan_info(ptr, &err, &policy, scan_id, &info) != AEROSPIKE_OK) { raise_aerospike_exception(err.code, err.); } vHash = rb_hash_new(); rb_hash_aset(vHash, rb_str_new2("progress_percent"), ULONG2NUM(info.progress_pct)); rb_hash_aset(vHash, rb_str_new2("records_scanned"), ULONG2NUM(info.records_scanned)); rb_hash_aset(vHash, rb_str_new2("status"), INT2NUM(info.status)); return vHash; } |
Instance Method Details
#exec(, vSelf) ⇒ Object
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 |
# File 'ext/aerospike_native/scan.c', line 108 VALUE scan_exec(int argc, VALUE* vArgs, VALUE vSelf) { VALUE vClient, vNamespace, vSet; VALUE vArray; VALUE vConcurrent, vPercent, vPriority, vBins, vNoBins, vBackground; as_scan scan; as_policy_scan policy; as_error err; aerospike* ptr; int n, idx = 0; bool is_background = false; if (argc > 1) { // there should only be 0 or 1 argument rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..1)", argc); } as_policy_scan_init(&policy); if(argc == 1) { SET_SCAN_POLICY(policy, vArgs[0]); } vClient = rb_iv_get(vSelf, "@client"); vNamespace = rb_iv_get(vSelf, "@namespace"); vSet = rb_iv_get(vSelf, "@set"); vConcurrent = rb_iv_get(vSelf, "@concurrent"); vPercent = rb_iv_get(vSelf, "@percent"); vPriority = rb_iv_get(vSelf, "@priority"); vNoBins = rb_iv_get(vSelf, "@no_bins"); vBins = rb_iv_get(vSelf, "@select_bins"); vBackground = rb_iv_get(vSelf, "@background"); as_scan_init(&scan, StringValueCStr(vNamespace), StringValueCStr(vSet)); if (TYPE(vPercent) == T_FIXNUM) { as_scan_set_percent(&scan, FIX2INT(vPercent)); } if (TYPE(vPriority) == T_FIXNUM) { as_scan_set_priority(&scan, FIX2INT(vPriority)); } if (TYPE(vConcurrent) != T_NIL) { as_scan_set_priority(&scan, RTEST(vConcurrent)); } if (TYPE(vNoBins) != T_NIL) { as_scan_set_nobins(&scan, RTEST(vNoBins)); } if (TYPE(vBackground) != T_NIL) { is_background = RTEST(vBackground); } if (TYPE(vBins) == T_ARRAY && (idx = RARRAY_LEN(vBins)) > 0) { as_scan_select_inita(&scan, idx); for(n = 0; n < idx; n++) { VALUE vEntry = rb_ary_entry(vBins, n); as_scan_select(&scan, StringValueCStr(vEntry)); } } Data_Get_Struct(vClient, aerospike, ptr); vArray = rb_ary_new(); if(is_background) { uint64_t scan_id = 0; if (aerospike_scan_background(ptr, &err, &policy, &scan, &scan_id) != AEROSPIKE_OK) { as_scan_destroy(&scan); raise_aerospike_exception(err.code, err.); } as_scan_destroy(&scan); return ULONG2NUM(scan_id); } if (aerospike_scan_foreach(ptr, &err, &policy, &scan, query_callback, &vArray) != AEROSPIKE_OK) { as_scan_destroy(&scan); raise_aerospike_exception(err.code, err.); } as_scan_destroy(&scan); if ( rb_block_given_p() ) { return Qnil; } return vArray; } |
#select(, vSelf) ⇒ Object
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 |
# File 'ext/aerospike_native/scan.c', line 34 VALUE scan_select(int argc, VALUE* vArgs, VALUE vSelf) { VALUE vBins; int i; if (argc == 0) { // there should be greater than 0 rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..n)", argc); } vBins = rb_iv_get(vSelf, "@select_bins"); if(TYPE(vBins) == T_NIL) { vBins = rb_ary_new(); } if (argc == 1) { int idx; VALUE vArray = vArgs[0]; Check_Type(vArray, T_ARRAY); idx = RARRAY_LEN(vArray); for(i = 0; i < idx; i++) { VALUE vString = rb_ary_entry(vArray, i); GET_STRING(vString); rb_ary_push(vBins, vString); } } else { for(i = 0; i < argc; i++) { VALUE vString = vArgs[i]; GET_STRING(vString); rb_ary_push(vBins, vString); } } rb_iv_set(vSelf, "@select_bins", vBins); return vSelf; } |
#set_concurrent(vValue) ⇒ Object
69 70 71 72 73 |
# File 'ext/aerospike_native/scan.c', line 69 VALUE scan_concurrent(VALUE vSelf, VALUE vValue) { rb_iv_set(vSelf, "@concurrent", vValue); return vSelf; } |
#set_no_bins(vValue) ⇒ Object
87 88 89 90 91 |
# File 'ext/aerospike_native/scan.c', line 87 VALUE scan_no_bins(VALUE vSelf, VALUE vValue) { rb_iv_set(vSelf, "@no_bins", vValue); return vSelf; } |
#set_percent(vValue) ⇒ Object
75 76 77 78 79 |
# File 'ext/aerospike_native/scan.c', line 75 VALUE scan_percent(VALUE vSelf, VALUE vValue) { rb_iv_set(vSelf, "@percent", vValue); return vSelf; } |
#set_priority(vValue) ⇒ Object
81 82 83 84 85 |
# File 'ext/aerospike_native/scan.c', line 81 VALUE scan_priority(VALUE vSelf, VALUE vValue) { rb_iv_set(vSelf, "@priority", vValue); return vSelf; } |