Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 309:f8e75ef7ac5d
RedBlackJungleTreeEditor delete Attribute bug fix
author | tatsuki |
---|---|
date | Thu, 26 Jan 2017 16:19:51 +0900 |
parents | 201cc75a9984 |
children | 474728dcfdb8 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/nodepath/RedBlackTreeNodePath.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/RedBlackJungleTreeEditor.java src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/treeeditor/RedBlack/RedBlackTreeEditorAttributeTest.java |
diffstat | 3 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/nodepath/RedBlackTreeNodePath.java Thu Jan 26 15:23:25 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/nodepath/RedBlackTreeNodePath.java Thu Jan 26 16:19:51 2017 +0900 @@ -25,9 +25,16 @@ */ private int flags; + public RedBlackTreeNodePath() { + this.key = "default"; + this.value = ByteBuffer.wrap("default".getBytes()); + this.flags = -2; + } + public RedBlackTreeNodePath(String key, ByteBuffer value) { this.key = key; this.value = value; + this.flags = -2; } private RedBlackTreeNodePath(String key, ByteBuffer value, int flags) {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/RedBlackJungleTreeEditor.java Thu Jan 26 15:23:25 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/RedBlackJungleTreeEditor.java Thu Jan 26 16:19:51 2017 +0900 @@ -5,7 +5,6 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.LoggingNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.OperationLog; import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.TreeOperationLog; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.PathType; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.DefaultTreeOperation; @@ -82,7 +81,6 @@ */ @Override public Either<Error, JungleTreeEditor> addNewChildAndPutAttribute(NodePath path, int pos, String key, ByteBuffer value) { - path = new DefaultNodePath(-2); AppendChildAndPutAttribute appendChildAndPutAttribute = new AppendChildAndPutAttribute(key, value, pos); return _edit(path, appendChildAndPutAttribute); } @@ -90,7 +88,6 @@ @Override public Either<Error, JungleTreeEditor> addNewChildAt(NodePath path, int _pos) { ByteBuffer value = ByteBuffer.wrap("defaultValue".getBytes()); - path = new DefaultNodePath(-2); return addNewChildAndPutAttribute(path, 0, balanceKey, value); } @@ -116,11 +113,12 @@ } @Override - public Either<Error, JungleTreeEditor> deleteAttribute(NodePath _path, String _key) { + public Either<Error, JungleTreeEditor> deleteAttribute(NodePath path, String _key) { if (_key.equals(balanceKey)) return DefaultEither.newA(INVALID_ARGUMENT); DeleteAttribute deleteAttribute = new DeleteAttribute(_key); - return _edit(_path, deleteAttribute); + NodePath newParh = path.add(-1); //回転処理を行わないで木の複製を行う設定のPathに変えている… ダサい… + return _edit(newParh, deleteAttribute); }
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/treeeditor/RedBlack/RedBlackTreeEditorAttributeTest.java Thu Jan 26 15:23:25 2017 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/treeeditor/RedBlack/RedBlackTreeEditorAttributeTest.java Thu Jan 26 16:19:51 2017 +0900 @@ -4,7 +4,6 @@ import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; import jp.ac.u_ryukyu.ie.cr.jungle.core.Attributes; import jp.ac.u_ryukyu.ie.cr.jungle.query.traverser.InterfaceTraverser; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.RedBlackTreeNodePath; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; @@ -26,7 +25,7 @@ ByteBuffer testPutValue = ByteBuffer.wrap("test".getBytes()); Jungle jungle = new DefaultJungle(null, "hogehoge"); JungleTree tree = jungle.createNewRedBlackTree("TreeName", "balanceKey"); - NodePath path = new DefaultNodePath(); + NodePath path = new RedBlackTreeNodePath(); for (int count = 1; count <= 10; count++) { //とりあえず木構造の構築 JungleTreeEditor editor = tree.getJungleTreeEditor();