0

StoredMap 値を更新したいのですが、古い値は気にしません。以前の値が読み込まれないようにする方法が見つかりません。

StoredMap<Integer, SyntaxDocument> tsCol = new StoredMap<Integer, SyntaxDocument>(tsdb, new IntegerBinding(), new PassageBinding(), true);
tsCol.put(1, doc); // insert value => ok
tsCol.put(1, doc); // <- load previous value but I don't care. I want to avoid the "heavy" PassageBinding process.
tsCol.putAll(Collections.singletonMap(1, doc)); // Even this one load the old value

コードを最適化し、既存の値をロードせずに更新する方法はありますか (または、少なくとも古い DatabaseEntry バイトを処理するバインディングを防止する方法はありますか)?

注: remove を呼び出してから put を呼び出すと、処理が遅くなります。

4

1 に答える 1

0

解決策は、低レベルのデータベース API を使用することです。

Database tsdb = environment.openDatabase(null, "tsdb", dbconfig);
PassageBinding binding = new PassageBinding();
DatabaseEntry idDbEntry = new DatabaseEntry();

IntegerBinding.intToEntry(id, idDbEntry);
DatabaseEntry dbEntry = new DatabaseEntry();
pb.objectToEntry(data, dbEntry);

tsdb.put(null, idDbEntry, dbEntry); // <-- replace existing value without loading it.
于 2014-04-22T09:17:21.137 に答える