Skip to content

Commit 93cbc06

Browse files
author
Senthil Nathan
committed
Changes done for v4.1.5.
1 parent 6053e90 commit 93cbc06

26 files changed

+925
-320
lines changed

com.ibm.streamsx.dps/com.ibm.streamsx/store/distributed/native.function/function.xml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,16 @@ it does safety checks and is therefore slower.</description>
434434
<prototype>public stateful void dpsEndIteration(uint64 store, uint64 iterator, mutable uint64 err)</prototype>
435435
</function>
436436
<function>
437-
<description>This function can be called to get all the keys present in a given store.
438-
@param store the handle of the store.
439-
@param keys a user provided mutable list variable. This list must be suitable for storing the data type of the keys.
440-
@param err Contains the error code. Will be '0' if no error occurs, and a non-zero value otherwise.
437+
<description>This function can be called to get multiple keys present in a given store.
438+
@param store The handle of the store.
439+
@param keys User provided mutable list variable. This list must be suitable for storing multiple keys found in a given store and it must be made of a given store's key data type.
440+
@param keyStartPosition User can indicate a start position from where keys should be fetched and returned. It must be greater than or equal to zero. If not, this API will return back with an empty list of keys.
441+
@param numberOfKeysNeeded User can indicate the total number of keys to be returned as available from the given key start position. It must be greater than or equal to 0 and less than or equal to 50000. If it is set to 0, then all the available keys upto a maximum of 50000 keys from the given key start position will be returned.
442+
@param keyExpression User can provide an expression made of the attributes from the key's data type. This expression will be evaluated in determining which matching keys to be returned. Due to very high logic complexity, this feature is not implemented at this time.
443+
@param valueExpression User can provide an expression made of the attributes from the value's data type. This expression will be evaluated in determining which matching keys to be returned. Due to very high logic complexity, this feature is not implemented at this time.
444+
@param err Contains the error code. Will be '0' if no error occurs, and a non-zero value otherwise.
441445
</description>
442-
<prototype>&lt;any T1> public stateful void dpsGetAllKeys(uint64 store, mutable list&lt;T1&gt; keys, mutable uint64 err)</prototype>
446+
<prototype>&lt;any T1> public stateful void dpsGetKeys(uint64 store, mutable list&lt;T1&gt; keys, int32 keyStartPosition, int32 numberOfKeysNeeded, rstring keyExpression, rstring valueExpression, mutable uint64 err)</prototype>
443447
</function>
444448
<function>
445449
<description> This function serializes all the key-value pairs in a given store id into a blob. The blob can be used to recreate all the key-value pairs into another store. This is a useful technique for copying an entire store into a different store. See `dpsDeserialize()` for a detailed example on how to use the serialization functions to copy a store.

com.ibm.streamsx.dps/impl/include/CassandraDBLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ namespace distributed
158158
bool acquireLock(uint64_t lock, double leaseTime, double maxWaitTimeToAcquireLock, PersistenceError & lkError);
159159
bool removeLock(uint64_t lock, PersistenceError & lkError);
160160
uint32_t getPidForLock(std::string const & name, PersistenceError & lkError);
161-
void getAllKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, PersistenceError & dbError);
161+
void getKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, int32_t keyStartPosition, int32_t numberOfKeysNeeded, PersistenceError & dbError);
162162

163163
};
164164
} } } } }

com.ibm.streamsx.dps/impl/include/CloudantDBLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ namespace distributed
197197
bool acquireLock(uint64_t lock, double leaseTime, double maxWaitTimeToAcquireLock, PersistenceError & lkError);
198198
bool removeLock(uint64_t lock, PersistenceError & lkError);
199199
uint32_t getPidForLock(std::string const & name, PersistenceError & lkError);
200-
void getAllKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, PersistenceError & dbError);
200+
void getKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, int32_t keyStartPosition, int32_t numberOfKeysNeeded, PersistenceError & dbError);
201201

202202
};
203203
} } } } }

com.ibm.streamsx.dps/impl/include/CouchbaseDBLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ namespace distributed
203203
bool acquireLock(uint64_t lock, double leaseTime, double maxWaitTimeToAcquireLock, PersistenceError & lkError);
204204
bool removeLock(uint64_t lock, PersistenceError & lkError);
205205
uint32_t getPidForLock(std::string const & name, PersistenceError & lkError);
206-
void getAllKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, PersistenceError & dbError);
206+
void getKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, int32_t keyStartPosition, int32_t numberOfKeysNeeded, PersistenceError & dbError);
207207

208208
};
209209
} } } } }

com.ibm.streamsx.dps/impl/include/DBLayer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ namespace store {
285285
/// @return true if connection is active or false if connection is inactive.
286286
virtual bool reconnect(std::set<std::string> & dbServers, PersistenceError & dbError) = 0;
287287

288-
/// Get all the keys present in a given store.
289-
/// @return a list containing all the keys of a given data type.
290-
virtual void getAllKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, PersistenceError & dbError) = 0;
288+
/// Get multiple keys present in a given store.
289+
/// @return a list containing multiple keys of a given data type.
290+
virtual void getKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, int32_t keyStartPosition, int32_t numberOfKeysNeeded, PersistenceError & dbError) = 0;
291291

292292
/// A store iterator
293293
class Iterator

com.ibm.streamsx.dps/impl/include/DistributedProcessStore.h

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,17 @@ namespace distributed
218218
/// @param err PersistentStore error code
219219
void endIteration(SPL::uint64 store, SPL::uint64 iterator, SPL::uint64 & err);
220220

221-
/// Get all the keys in a given store.
222-
/// @param store store handle
223-
/// @param List (vector) of a specific key type
224-
/// @param err store error code
225-
template<class T1>
226-
void getAllKeysHelper(SPL::uint64 store, SPL::list<T1> & keys, SPL::uint64 & err);
221+
/// Get multiple keys present in a given store.
222+
/// @param store The handle of the store.
223+
/// @param keys User provided mutable list variable. This list must be suitable for storing multiple keys found in a given store and it must be made of a given store's key data type.
224+
/// @param keyStartPosition User can indicate a start position from where keys should be fetched and returned. It must be greater than or equal to zero. If not, this API will return back with an empty list of keys.
225+
/// @param numberOfKeysNeeded User can indicate the total number of keys to be returned as available from the given key start position. It must be greater than or equal to 0 and less than or equal to 50000. If it is set to 0, then all the available keys upto a maximum of 50000 keys from the given key start position will be returned.
226+
/// @param keyExpression User can provide an expression made of the attributes from the key's data type. This expression will be evaluated in determining which matching keys to be returned. [This feature is not implemented at this time.]
227+
/// @param valueExpression User can provide an expression made of the attributes from the value's data type. This expression will be evaluated in determining which matching keys to be returned. [This feature is not implemented at this time.]
228+
/// @param err Contains the error code. Will be '0' if no error occurs, and a non-zero value otherwise.
229+
///
230+
template<class T1>
231+
void getKeys(SPL::uint64 store, SPL::list<T1> & keys, SPL::int32 const & keyStartPosition, SPL::int32 const & numberOfKeysNeeded, SPL::rstring const & keyExpression, SPL::rstring const & valueExpression, SPL::uint64 & err);
227232

228233
/// Serialize the items from the serialized store
229234
/// @param store store handle
@@ -865,17 +870,24 @@ namespace distributed
865870
return res;
866871
}
867872

868-
/// Get all the keys in a given store.
869-
/// @param store store handle
870-
/// @param List (vector) of a specific key type
871-
/// @param err store error code
873+
/// Get multiple keys present in a given store.
874+
/// @param store The handle of the store.
875+
/// @param keys User provided mutable list variable. This list must be suitable for storing multiple keys found in a given store and it must be made of a given store's key data type.
876+
/// @param keyStartPosition User can indicate a start position from where keys should be fetched and returned. It must be greater than or equal to zero. If not, this API will return back with an empty list of keys.
877+
/// @param numberOfKeysNeeded User can indicate the total number of keys to be returned as available from the given key start position. It must be greater than or equal to 0 and less than or equal to 50000. If it is set to 0, then all the available keys upto a maximum of 50000 keys from the given key start position will be returned.
878+
/// @param keyExpression User can provide an expression made of the attributes from the key's data type. This expression will be evaluated in determining which matching keys to be returned. [This feature is not implemented at this time.]
879+
/// @param valueExpression User can provide an expression made of the attributes from the value's data type. This expression will be evaluated in determining which matching keys to be returned. [This feature is not implemented at this time.]
880+
/// @param err Contains the error code. Will be '0' if no error occurs, and a non-zero value otherwise.
881+
///
872882
template<class T1>
873-
void DistributedProcessStore::getAllKeysHelper(SPL::uint64 store, SPL::list<T1> & keys, SPL::uint64 & err) {
883+
void DistributedProcessStore::getKeys(SPL::uint64 store, SPL::list<T1> & keys, SPL::int32 const & keyStartPosition, SPL::int32 const & numberOfKeysNeeded, SPL::rstring const & keyExpression, SPL::rstring const & valueExpression, SPL::uint64 & err) {
874884
dbError_->reset();
875885
std::vector<unsigned char *> keysBuffer;
876886
std::vector<uint32_t> keysSize;
877-
// Call the underlying store implementation function to get all the keys in a given store.
878-
db_->getAllKeys(store, keysBuffer, keysSize, *dbError_);
887+
// Clear the user provided list now.
888+
keys.clear();
889+
// Call the underlying store implementation function to get multiple keys in a given store.
890+
db_->getKeys(store, keysBuffer, keysSize, keyStartPosition, numberOfKeysNeeded, *dbError_);
879891
err = dbError_->getErrorCode();
880892

881893
if(err != 0) {
@@ -892,11 +904,10 @@ namespace distributed
892904
return;
893905
}
894906

895-
// We got all the keys.
907+
// We got multiple keys.
896908
// Let us convert it to the proper key type and store them in
897909
// the user provided list (vector).
898-
keys.clear();
899-
910+
//
900911
// Populate the user provided list (vector) with the store keys.
901912
for (unsigned int i = 0; i < keysBuffer.size(); i++) {
902913
SPL::NativeByteBuffer nbf_key(keysBuffer.at(i), keysSize.at(i));

com.ibm.streamsx.dps/impl/include/DistributedProcessStoreWrappers.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,19 @@ namespace distributed
300300
return DistributedProcessStore::getGlobalStore().endIteration(store, iterator, err);
301301
}
302302

303-
/// Get all the keys in a given store.
304-
/// @param store store handle
305-
/// @param List (vector) of a specific key type
306-
/// @param err store error code
307-
template<class T1>
308-
void dpsGetAllKeys(SPL::uint64 store, SPL::list<T1> & keys, SPL::uint64 & err)
303+
/// Get multiple keys present in a given store.
304+
/// @param store The handle of the store.
305+
/// @param keys User provided mutable list variable. This list must be suitable for storing multiple keys found in a given store and it must be made of a given store's key data type.
306+
/// @param keyStartPosition User can indicate a start position from where keys should be fetched and returned. It must be greater than or equal to zero. If not, this API will return back with an empty list of keys.
307+
/// @param numberOfKeysNeeded User can indicate the total number of keys to be returned as available from the given key start position. It must be greater than or equal to 0 and less than or equal to 50000. If it is set to 0, then all the available keys upto a maximum of 50000 keys from the given key start position will be returned.
308+
/// @param keyExpression User can provide an expression made of the attributes from the key's data type. This expression will be evaluated in determining which matching keys to be returned. [This feature is not implemented at this time.]
309+
/// @param valueExpression User can provide an expression made of the attributes from the value's data type. This expression will be evaluated in determining which matching keys to be returned. [This feature is not implemented at this time.]
310+
/// @param err Contains the error code. Will be '0' if no error occurs, and a non-zero value otherwise.
311+
///
312+
template<class T1>
313+
void dpsGetKeys(SPL::uint64 store, SPL::list<T1> & keys, SPL::int32 const & keyStartPosition, SPL::int32 const & numberOfKeysNeeded, SPL::rstring const & keyExpression, SPL::rstring const & valueExpression, SPL::uint64 & err)
309314
{
310-
return DistributedProcessStore::getGlobalStore().getAllKeysHelper(store, keys, err);
315+
return DistributedProcessStore::getGlobalStore().getKeys(store, keys, keyStartPosition, numberOfKeysNeeded, keyExpression, valueExpression, err);
311316
}
312317

313318
/// Serialize the items from the serialized store

com.ibm.streamsx.dps/impl/include/DpsConstants.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ interface with many different back-end in-memory stores.
2323
#define DPS_STORE_ID_TRACKER_SET "dps_store_id_tracker" // Used in Aerospike
2424
#define DPS_STORE_NAME_TYPE "0"
2525
#define DPS_STORE_INFO_TYPE "1" // Used in memcached
26-
#define DPS_STORE_CONTENTS_HASH_TYPE "1" // Used in Redis
27-
#define DPS_STORE_CATALOG_TYPE "2" // Used only in memcached
28-
#define DPS_STORE_DATA_ITEM_TYPE "3"
26+
#define DPS_STORE_CONTENTS_HASH_TYPE "1" // Used in Redis
27+
#define DPS_STORE_CATALOG_TYPE "2" // Used only in memcached
28+
#define DPS_STORE_DATA_ITEM_TYPE "3"
29+
#define DPS_STORE_ORDERED_KEYS_SET_TYPE "101" // Used in Redis
2930
#define DPS_STORE_LOCK_TYPE "4"
3031
#define DL_LOCK_NAME_TYPE "5"
3132
#define DL_LOCK_INFO_TYPE "6"
@@ -77,6 +78,9 @@ interface with many different back-end in-memory stores.
7778
#define REDIS_HLEN_CMD "hlen "
7879
#define REDIS_HKEYS_CMD "hkeys "
7980
#define REDIS_AUTH_CMD "auth "
81+
#define REDIS_ZADD_CMD "zadd "
82+
#define REDIS_ZREM_CMD "zrem "
83+
#define REDIS_ZRANGE_CMD "zrange "
8084
#define CASSANDRA_DPS_KEYSPACE "com_ibm_streamsx_dps"
8185
#define CASSANDRA_DPS_MAIN_TABLE "t1"
8286
#define HBASE_DPS_MAIN_TABLE "dps_t1"
@@ -212,6 +216,8 @@ interface with many different back-end in-memory stores.
212216
#define DPS_STORE_FATAL_ERROR 156
213217
#define DPS_STORE_UNKNOWN_STATE_ERROR 157
214218
#define DPS_AUTHENTICATION_ERROR 158
219+
#define DPS_NEGATIVE_KEY_START_POS_ERROR 159
220+
#define DPS_INVALID_NUM_KEYS_NEEDED_ERROR 160
215221

216222
#define DL_CONNECTION_ERROR 501
217223
#define DL_GET_LOCK_ID_ERROR 502

com.ibm.streamsx.dps/impl/include/HBaseDBLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ namespace distributed
212212
bool acquireLock(uint64_t lock, double leaseTime, double maxWaitTimeToAcquireLock, PersistenceError & lkError);
213213
bool removeLock(uint64_t lock, PersistenceError & lkError);
214214
uint32_t getPidForLock(std::string const & name, PersistenceError & lkError);
215-
void getAllKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, PersistenceError & dbError);
215+
void getKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, int32_t keyStartPosition, int32_t numberOfKeysNeeded, PersistenceError & dbError);
216216

217217
};
218218
} } } } }

com.ibm.streamsx.dps/impl/include/MemcachedDBLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ namespace distributed
178178
bool acquireLock(uint64_t lock, double leaseTime, double maxWaitTimeToAcquireLock, PersistenceError & lkError);
179179
bool removeLock(uint64_t lock, PersistenceError & lkError);
180180
uint32_t getPidForLock(std::string const & name, PersistenceError & lkError);
181-
void getAllKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, PersistenceError & dbError);
181+
void getKeys(uint64_t store, std::vector<unsigned char *> & keysBuffer, std::vector<uint32_t> & keysSize, int32_t keyStartPosition, int32_t numberOfKeysNeeded, PersistenceError & dbError);
182182

183183
};
184184
} } } } }

0 commit comments

Comments
 (0)