Skip to content

Commit 440bc54

Browse files
committed
query_id() [WIP]
1 parent cac0674 commit 440bc54

1 file changed

Lines changed: 61 additions & 12 deletions

File tree

src/main/java/picoded/dstack/redis/Redis_DataObjectMap.java

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,15 @@ public void DataObjectRemoteDataMap_update(String _oid, Map<String, Object> full
176176
* @return null if not exists, else a map with the data
177177
**/
178178
public Map<String, Object> DataObjectRemoteDataMap_get(String _oid) {
179-
// Set<String> keys = new HashSet<String>();
180-
// keys.add(_oid);
181-
// Map<String, Object> res = redisMap.getAll(keys);
179+
182180
RMap<String, Object> res = redisMap;
183181

184-
//Input value myself
185-
// res.put("helloKey", "worldValue");
186-
System.out.println(res);
187-
System.out.println("RMap content:");
188-
// Where are you content ?
189-
// System.out.println(res.readAllKeySet());
190-
System.out.println(res.readAllMap());
191-
// System.out.println(res.readAllEntrySet());
192-
// System.out.println(res.readAllValues());
182+
// System.out.println("------------RMap content--------------:");
183+
// System.out.println(res.readAllMap()); // all map entries
184+
// System.out.println(res.readAllEntrySet()); // everything
185+
// System.out.println(res.readAllValues()); // all values
186+
// System.out.println(res.readAllKeySet()); // just keys
187+
// System.out.println("------------RMap END--------------:");
193188

194189
Map<String, Object> ret = new HashMap<>();
195190

@@ -240,5 +235,59 @@ public void DataObjectRemoteDataMap_remove(String _oid) {
240235
//redisson.getKeys().delete(_oid);
241236
redisMap.fastRemove(_oid);
242237
}
238+
239+
/**
240+
* Performs a search query, and returns the respective DataObject keys.
241+
*
242+
* This is the GUID key varient of query, this is critical for stack lookup
243+
*
244+
* @param queryClause, of where query statement and value
245+
* @param orderByStr string to sort the order by, use null to ignore
246+
* @param offset of the result to display, use -1 to ignore
247+
* @param number of objects to return max, use -1 to ignore
248+
*
249+
* @return The String[] array
250+
**/
251+
public String[] query_id(Query queryClause, String orderByStr, int offset, int limit) {
252+
253+
// The return list of DataObjects
254+
List<String> retList = null;
255+
256+
RMap<String, Object> myRedisMap = redisMap;
257+
258+
// Setup the query, if needed
259+
if (queryClause == null) {
260+
// Null gets all
261+
retList = new ArrayList<String>(myRedisMap.readAllKeySet());
262+
} else {
263+
264+
// Get the list of _oid that passes the query
265+
//Set<String> idSet = backendIMap().keySet(queryPredicate);
266+
//String[] idArr = idSet.toArray(new String[0]);
267+
268+
// DataObject[] from idArr
269+
//DataObject[] doArr = getArrayFromID(idArr, true);
270+
271+
// Converts to a list
272+
//retList = new ArrayList(Arrays.asList(doArr));
273+
retList = new ArrayList<String>(myRedisMap.readAllKeySet());
274+
}
275+
276+
// Sort, offset, convert to array, and return
277+
// ???
278+
279+
// Prepare the actual return string array
280+
int retLength = retList.size();
281+
String[] ret = new String[retLength];
282+
for (int a = 0; a < retLength; ++a) {
283+
//._oid(); -> where is it coming from
284+
//ret[a] = retList.get(a)._oid();
285+
ret[a] = String.valueOf(retList.get(a));
286+
}
287+
288+
System.out.println(ret);
289+
// Returns sorted array of strings
290+
return ret;
291+
}
243292

244293
}

0 commit comments

Comments
 (0)