ideawu / ssdb

SSDB - A fast NoSQL database, an alternative to Redis
http://ssdb.io/
BSD 3-Clause "New" or "Revised" License
8.19k stars 1.4k forks source link

multiHset序列化有些问题 #1378

Open darkice1 opened 4 years ago

darkice1 commented 4 years ago

写入代码

ArrayList<KeyValue> kvlist = new ArrayList<>();
byte[] bs = Tool.kryoSerializeToCompressBytes(oldmap);
Log.OutLog("#### %s %d", skey, bs.length);
kvlist.add(new KeyValue(skey,bs, Charset.defaultCharset()));
ssdb.multiHset(ExprivateSql.REALBIGDATA,kvlist);

读取代码

                val kvlist = ssdb.hscan(ExprivateSql.REALBIGDATA,"","",max)
                kvlist?.forEach { kv->
                    val json = JSONObject.parseObject(kv.keyString)
                    val name = json.getString("name")
                    var realdb = map[name]
                    if (realdb == null)
                    {
                        realdb = Class.forName(name).newInstance() as RealDb
                        map[name] = realdb
                        println("$name ${kv.keyString} ${kv.value.size}")
                        val datamap = Tool.kryoCompressBytesUnSerialize(kv.value) as ConcurrentHashMap<String, Row>
                        realdb.plus(datamap)
                    }
                }

发现写入时 byte 长度是167。读取时 bs 长度时270。导致无法正确序列化。 不知道是我哪里使用有问题,请帮看一下。

yiding-he commented 4 years ago

@darkice1 这个是我这边的问题,你提错项目了