2222import picoded .core .common .ObjectToken ;
2323import picoded .dstack .*;
2424import picoded .dstack .core .*;
25+ import picoded .core .struct .query .*;
2526
2627// Redis imports
2728import org .redisson .Redisson ;
@@ -156,6 +157,21 @@ public void clear() {
156157 public void systemDestroy () {
157158 redisMap .delete ();
158159 }
160+
161+ /**
162+ * [Internal use, to be extended in future implementation]
163+ *
164+ * Removes the complete remote data map, for DataObject.
165+ * This is used to nuke an entire object
166+ *
167+ * @param Object ID to remove
168+ *
169+ * @return nothing
170+ **/
171+ public void DataObjectRemoteDataMap_remove (String _oid ) {
172+ // //redisson.getKeys().delete(_oid);
173+ redisMap .fastRemove (_oid );
174+ }
159175
160176 /**
161177 * Updates the actual backend storage of DataObject
@@ -171,12 +187,6 @@ public void DataObjectRemoteDataMap_update(String _oid, Map<String, Object> full
171187 // Get the full map value
172188 Object val = fullMap .get (key );
173189
174- // // Check for Map / List like objects
175- // if (val instanceof Map || val instanceof List) {
176- // // Clone it - by JSON serializing back and forth
177- // clonedMap.put(key, ConvertJSON.toObject(ConvertJSON.fromObject(val)));
178- // }
179-
180190 if (updateKeys .contains (key )) {
181191 clonedMap .put (key , val );
182192 }
@@ -235,127 +245,18 @@ public Map<String, Object> DataObjectRemoteDataMap_get(String _oid) {
235245 return ret ;
236246 }
237247
238- // /**
239- // * @return set of keys
240- // **/
241- // @Override
242- // public Set<String> keySet() {
243- // // The return hashset
244- // HashSet<String> ret = new HashSet<String>();
245-
246- // //Fetch everything in current db
247- // RKeys keySet = redisson.getKeys();
248- // if (value != null) {
249- // // Return key where value is matched
250- // keySet.getKeysByPattern(value).forEach(k -> ret.add(k));
251- // } else {
252- // // Return the full keyset
253- // keySet.getKeys().forEach(k -> ret.add(k));
254- // }
255- // return ret;
256- // }
257-
258248 /**
259- * [Internal use, to be extended in future implementation]
260- *
261- * Removes the complete remote data map, for DataObject.
262- * This is used to nuke an entire object
263- *
264- * @param Object ID to remove
265- *
266- * @return nothing
249+ * @return set of keys
267250 **/
268- public void DataObjectRemoteDataMap_remove (String _oid ) {
269- // //redisson.getKeys().delete(_oid);
270- redisMap .fastRemove (_oid );
271- }
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- }
304-
305- /**
306- * Performs a search query, and returns the respective DataObject keys.
307- *
308- * This is the GUID key varient of query, this is critical for stack lookup
309- *
310- * @param queryClause, of where query statement and value
311- * @param orderByStr string to sort the order by, use null to ignore
312- * @param offset of the result to display, use -1 to ignore
313- * @param number of objects to return max, use -1 to ignore
314- *
315- * @return The String[] array
316- **/
317- public String [] query_id (Query queryClause , String orderByStr , int offset , int limit ) {
318-
319- System .out .println ("QUERY: " +queryClause );
320- // The return list of DataObjects
251+ @ Override
252+ public Set <String > keySet () {
253+ // The return hashset
254+ HashSet <String > ret = new HashSet <String >();
255+ //Fetch everything in current db
321256 List <String > retList = null ;
322-
323- RMap <String , Object > myRedisMap = redisMap ;
324-
325- // Setup the query, if needed
326- if (queryClause == null ) {
327- // Null gets all
328- retList = new ArrayList <String >(myRedisMap .readAllKeySet ());
329- } else {
330-
331- // Get the list of _oid that passes the query
332- //Set<String> idSet = backendIMap().keySet(queryPredicate);
333- //String[] idArr = idSet.toArray(new String[0]);
334-
335- // DataObject[] from idArr
336- //DataObject[] doArr = getArrayFromID(idArr, true);
337-
338- // Converts to a list
339- //retList = new ArrayList(Arrays.asList(doArr));
340- retList = new ArrayList <String >(myRedisMap .readAllKeySet ());
341- }
342-
343- System .out .println ("QueryResult: " +retList );
344-
345- // Sort, offset, convert to array, and return
346- // ???
347-
348- // Prepare the actual return string array
349- int retLength = retList .size ();
350- String [] ret = new String [retLength ];
351- for (int a = 0 ; a < retLength ; ++a ) {
352- //._oid(); -> where is it coming from
353- //ret[a] = retList.get(a)._oid();
354- ret [a ] = String .valueOf (retList .get (a ));
355- }
356-
357- System .out .println ("Return: " +Arrays .toString (ret ));
358- // Returns sorted array of strings
257+ retList = new ArrayList <String >(redisMap .readAllKeySet ());
258+ // Return the full keyset
259+ retList .forEach (k -> ret .add (k ));
359260 return ret ;
360261 }
361262
0 commit comments