Skip to content

Commit 99080de

Browse files
committed
DataObjectMap_Get works properly (9/32 tests failures)
1 parent f00288d commit 99080de

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

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

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
import java.util.concurrent.locks.ReentrantReadWriteLock;
1313
import java.util.Collection;
1414
import java.util.Iterator;
15-
import java.util.stream.Collectors;
16-
17-
1815

1916
// JavaCommons imports
2017
import picoded.core.conv.ConvertJSON;
@@ -33,8 +30,6 @@
3330
import org.redisson.api.RedissonClient;
3431
import org.redisson.api.RMap;
3532
import org.redisson.api.RKeys;
36-
import org.redisson.api.RSet;
37-
import org.redisson.api.RSetMultimap;
3833

3934
// Jackson library used
4035
import com.fasterxml.jackson.core.JsonParser;
@@ -159,7 +154,7 @@ public void clear() {
159154
* Teardown and delete the backend storage table, etc. If needed
160155
**/
161156
public void systemDestroy() {
162-
//redisMap.delete();
157+
redisMap.delete();
163158
}
164159

165160
/**
@@ -187,16 +182,12 @@ public void DataObjectRemoteDataMap_update(String _oid, Map<String, Object> full
187182
}
188183
}
189184

190-
//RSET test
191-
//check with SMEMBERS instead of HGETALL
192-
//set.add(clonedMap);
193-
194185
// call the default implementation, basically equal to redisMap.put(_oid,clonedMap)
195186
super.DataObjectRemoteDataMap_update(_oid, clonedMap, updateKeys);
196187
}
197188

198-
public Map<String,Object> ObjToMap(Object resObj) {
199-
if( resObj instanceof Map ) { return (Map<String,Object>) resObj; }
189+
public Map<String,Object> ObjToMap(Object obj) {
190+
if( obj instanceof Map ) { return (Map<String,Object>) obj; }
200191
else {return null;}
201192
}
202193

@@ -208,21 +199,25 @@ public Map<String, Object> DataObjectRemoteDataMap_get(String _oid) {
208199

209200
//Map Slicing
210201
Set<String> keys = new HashSet<String>();
211-
keys.add(_oid);
212-
Map<String, Object> mapSlice = redisMap.getAll(keys);
202+
Map<String, Object> mapSlice = new HashMap<String, Object>();
203+
Map.Entry<String,Object> res = null;
204+
Object tmpObj = null;
213205

214-
Map.Entry<String,Object> res = mapSlice.entrySet().iterator().next();
215-
Object tmpObj = res.getValue();
206+
keys.add(_oid);
207+
mapSlice = redisMap.getAll(keys);
208+
209+
Iterator<Map.Entry<String,Object>> it = mapSlice.entrySet().iterator();
210+
if(it.hasNext()){
211+
res = it.next();
212+
tmpObj = res.getValue();
213+
}
216214

217215
if (tmpObj == null) {
218216
return null;
219217
}
220218

221219
Map<String, Object> resObj = null;
222220
resObj = ObjToMap(tmpObj);
223-
224-
System.out.println(resObj);
225-
System.out.println(resObj instanceof Map);
226221

227222
Map<String, Object> ret = new HashMap<>();
228223

@@ -237,7 +232,7 @@ public Map<String, Object> DataObjectRemoteDataMap_get(String _oid) {
237232
ret.put(key, val);
238233
}
239234

240-
return ret = null;
235+
return ret;
241236
}
242237

243238
// /**

0 commit comments

Comments
 (0)