Skip to content

Commit b16dc02

Browse files
authored
Redis_DataObjectMap
1 parent 2d1a486 commit b16dc02

1 file changed

Lines changed: 24 additions & 135 deletions

File tree

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

Lines changed: 24 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@
2929
import org.redisson.codec.JsonJacksonCodec;
3030
import org.redisson.api.RedissonClient;
3131
import org.redisson.api.RMap;
32-
import org.redisson.api.RKeys;
33-
34-
// Jackson library used
35-
import com.fasterxml.jackson.core.JsonParser;
36-
import com.fasterxml.jackson.databind.ObjectMapper;
37-
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
38-
import com.fasterxml.jackson.core.util.DefaultIndenter;
39-
import com.fasterxml.jackson.databind.MapperFeature;
40-
41-
import org.hjson.*;
42-
4332

4433
/**
4534
* Redis implementation of DataObjectMap data structure.
@@ -156,6 +145,21 @@ public void clear() {
156145
public void systemDestroy() {
157146
redisMap.delete();
158147
}
148+
149+
/**
150+
* [Internal use, to be extended in future implementation]
151+
*
152+
* Removes the complete remote data map, for DataObject.
153+
* This is used to nuke an entire object
154+
*
155+
* @param Object ID to remove
156+
*
157+
* @return nothing
158+
**/
159+
public void DataObjectRemoteDataMap_remove(String _oid) {
160+
// //redisson.getKeys().delete(_oid);
161+
redisMap.fastRemove(_oid);
162+
}
159163

160164
/**
161165
* Updates the actual backend storage of DataObject
@@ -171,12 +175,6 @@ public void DataObjectRemoteDataMap_update(String _oid, Map<String, Object> full
171175
// Get the full map value
172176
Object val = fullMap.get(key);
173177

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-
180178
if (updateKeys.contains(key)) {
181179
clonedMap.put(key, val);
182180
}
@@ -235,127 +233,18 @@ public Map<String, Object> DataObjectRemoteDataMap_get(String _oid) {
235233
return ret;
236234
}
237235

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-
258-
/**
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
267-
**/
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-
305236
/**
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
237+
* @return set of keys
316238
**/
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
239+
@Override
240+
public Set<String> keySet() {
241+
// The return hashset
242+
HashSet<String> ret = new HashSet<String>();
243+
//Fetch everything in current db
321244
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
245+
retList = new ArrayList<String>(redisMap.readAllKeySet());
246+
// Return the full keyset
247+
retList.forEach(k -> ret.add(k));
359248
return ret;
360249
}
361250

0 commit comments

Comments
 (0)