Skip to content

Commit 2d1a486

Browse files
committed
queryToRedis skeleton
1 parent 99080de commit 2d1a486

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ public Map<String, Object> DataObjectRemoteDataMap_get(String _oid) {
240240
// **/
241241
// @Override
242242
// public Set<String> keySet() {
243-
// System.out.println("KEYSET");
244243
// // The return hashset
245244
// HashSet<String> ret = new HashSet<String>();
246245

@@ -270,6 +269,38 @@ public void DataObjectRemoteDataMap_remove(String _oid) {
270269
// //redisson.getKeys().delete(_oid);
271270
redisMap.fastRemove(_oid);
272271
}
272+
273+
/**
274+
* Given the SQL style query, convert it to relevant Redis Object
275+
*/
276+
static protected void queryToRedis(Query inQuery) {
277+
QueryType type = inQuery.type();
278+
279+
// Handle the query according to its type
280+
// Basic operator
281+
if (type == QueryType.EQUALS) {
282+
//TODO
283+
}
284+
if (type == QueryType.NOT_EQUALS) {
285+
//TODO
286+
}
287+
if (type == QueryType.LESS_THAN) {
288+
//TODO
289+
}
290+
if (type == QueryType.LESS_THAN_OR_EQUALS) {
291+
//TODO
292+
}
293+
if (type == QueryType.MORE_THAN) {
294+
//TODO
295+
}
296+
if (type == QueryType.MORE_THAN_OR_EQUALS) {
297+
//TODO
298+
}
299+
if (type == QueryType.LIKE) {
300+
//TODO
301+
}
302+
throw new RuntimeException("Unkown query type : " + inQuery.type());
303+
}
273304

274305
/**
275306
* Performs a search query, and returns the respective DataObject keys.
@@ -285,6 +316,7 @@ public void DataObjectRemoteDataMap_remove(String _oid) {
285316
**/
286317
public String[] query_id(Query queryClause, String orderByStr, int offset, int limit) {
287318

319+
System.out.println("QUERY: "+queryClause);
288320
// The return list of DataObjects
289321
List<String> retList = null;
290322

@@ -307,6 +339,8 @@ public String[] query_id(Query queryClause, String orderByStr, int offset, int l
307339
//retList = new ArrayList(Arrays.asList(doArr));
308340
retList = new ArrayList<String>(myRedisMap.readAllKeySet());
309341
}
342+
343+
System.out.println("QueryResult: "+retList);
310344

311345
// Sort, offset, convert to array, and return
312346
// ???
@@ -320,7 +354,7 @@ public String[] query_id(Query queryClause, String orderByStr, int offset, int l
320354
ret[a] = String.valueOf(retList.get(a));
321355
}
322356

323-
System.out.println(Arrays.toString(ret));
357+
System.out.println("Return: "+Arrays.toString(ret));
324358
// Returns sorted array of strings
325359
return ret;
326360
}

0 commit comments

Comments
 (0)