Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 213:7da9056e9357
delete List worning
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/benchMark/JungleBenchMark.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/benchMark/JungleBenchMark.java Tue Aug 04 23:07:43 2015 +0900 @@ -1,13 +1,13 @@ package jp.ac.u_ryukyu.ie.cr.jungle.benchMark; import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; -import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNodeAttributes; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; @@ -20,16 +20,19 @@ */ public class JungleBenchMark { public static void main(String args[]) { - Jungle jungle = new DefaultJungle(null, "hogehoge", new DefaultTreeEditor(new DefaultTraverser())); + DefaultJungle jungle = new DefaultJungle(null, "sample", new DefaultTreeEditor(new DefaultTraverser())); jungle.createNewTree("tree"); JungleTree tree = jungle.getTreeByName("tree"); JungleTreeEditor editor = tree.getTreeEditor(); - NodePath path = new DefaultNodePath().add(0); + NodePath path = new DefaultNodePath(); + path = path.add(0); for (int count = 1; count <= 10; count++) { for (int personCount = 0; personCount < 1000 * count; personCount++) { editor = editor.replaceNewRootNode().b(); - editor = editor.putAttribute(path, "personId", ByteBuffer.wrap(("p:" + personCount).getBytes())).b(); - editor = editor.putAttribute(path, "roleId", ByteBuffer.wrap(("r:" + personCount).getBytes())).b(); + ByteBuffer value = ByteBuffer.wrap(("p:" + personCount).getBytes()); + editor = editor.putAttribute(path, "personId", value).b(); + ByteBuffer value2 = ByteBuffer.wrap(("r:" + personCount).getBytes()); + editor = editor.putAttribute(path, "roleId", value2).b(); } editor.success(); long t1 = System.currentTimeMillis(); @@ -38,7 +41,8 @@ Iterator<TreeNode> it = traverser.find(null, "personId", "p:100"); if (it.hasNext()) { TreeNode targetNode = it.next(); - String targetRoleId = targetNode.getAttributes().getString("roleId"); + TreeNodeAttributes attribute = targetNode.getAttributes(); + String targetRoleId = attribute.getString("roleId"); if (targetRoleId.equals("r:100")) findCount++; } else {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/core/App.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/core/App.java Tue Aug 04 23:07:43 2015 +0900 @@ -1,22 +1,22 @@ package jp.ac.u_ryukyu.ie.cr.jungle.core; -import java.nio.ByteBuffer; - import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import java.nio.ByteBuffer; + /** * Hello world! * */ -public class App +public class App { public static void main( String[] args ) { @@ -25,15 +25,15 @@ JungleTree tree = jungle.getTreeByName("hoge"); JungleTreeEditor editor = tree.getTreeEditor(); DefaultNodePath path = new DefaultNodePath(); - + String key = "key"; ByteBuffer value = ByteBuffer.wrap(key.getBytes()); - + Either<Error,JungleTreeEditor> either = editor.putAttribute(path,"key",value); JungleTreeEditor e = either.b(); e.success(); - - + + TreeNode root = tree.getRootNode(); ByteBuffer v = root.getAttributes().get(key); String str = new String(v.array());
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/DefaultNode.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/DefaultNode.java Tue Aug 04 23:07:43 2015 +0900 @@ -1,31 +1,17 @@ package jp.ac.u_ryukyu.ie.cr.jungle.data.list; -/** - * Created by e115731 on 15/05/16. - */ + public class DefaultNode<T> implements Node<T> { private final T attribute; - private final Node next; - - //最終的に消す - int num = 0; + private final Node<T> next; - public DefaultNode(T attribute, int num, Node next) { - this.attribute = attribute; - this.next = next; - } -//ここまで - - public DefaultNode(T attribute, Node next) { + public DefaultNode(T attribute, Node<T> next) { this.attribute = attribute; this.next = next; } - public int getNum() { - return num; - } - public Node getNext() { + public Node<T> getNext() { return next; } @@ -35,46 +21,46 @@ public Node<T> addLast(T attribute) { Node<T> node = next.addLast(attribute); - return new DefaultNode<T>(this.attribute, node); + return new DefaultNode<>(this.attribute, node); } public Node<T> add(int currentNum, int num, T attribute) { if (currentNum == num) { - Node<T> newNode = new DefaultNode(attribute, num, this.next); - return new DefaultNode<T>(this.attribute, this.num + 1, newNode); + Node<T> newNode = new DefaultNode<>(attribute, this.next); + return new DefaultNode<>(this.attribute, newNode); } Node<T> newNode = next.add(currentNum + 1, num, attribute); if (newNode == null) return null; - return new DefaultNode(this.attribute, newNode); + return new DefaultNode<>(this.attribute, newNode); } @Override public Node<T> delete(int currentNum, int deleteNum) { if (currentNum == deleteNum) { - return new DefaultNode(this.attribute, this.next.getNext()); + return new DefaultNode<>(this.attribute, this.next.getNext()); } Node<T> newNode = next.delete(currentNum + 1, deleteNum); if (newNode == null) return null; - return new DefaultNode(this.attribute, newNode); + return new DefaultNode<>(this.attribute, newNode); } @Override public Node<T> replaceNode(int currentNum, int num, T attribute) { if (currentNum == num) { - return new DefaultNode(attribute, this.getNext()); + return new DefaultNode<>(attribute, this.getNext()); } Node<T> newNode = next.replaceNode(currentNum + 1, num, attribute); if (newNode == null) return null; - return new DefaultNode(this.attribute, newNode); + return new DefaultNode<>(this.attribute, newNode); } @Override
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/List.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/List.java Tue Aug 04 23:07:43 2015 +0900 @@ -9,11 +9,13 @@ final private Node<T> head; public List() { - this.head = new headNode<T>(); + this.head = new headNode<>(); } + + @SafeVarargs public List(T... attributes) { - List<T> list = new List(); + List<T> list = new List<>(); for (T attribute : attributes) { list = list.addLast(attribute); } @@ -32,12 +34,12 @@ Node<T> newHead = head.add(0, num, attribute); if (newHead == null) return this; - return new List<T>(newHead); + return new List<>(newHead); } public List<T> addLast(T attribute) { Node<T> newHead = head.addLast(attribute); - return new List<T>(newHead); + return new List<>(newHead); } @@ -59,7 +61,7 @@ @Override public boolean hasNext() { - return currentNode.getNum() != -1; + return currentNode.getNext().getAttribute() != null; } @Override @@ -73,8 +75,8 @@ public Iterator<T> reverseIterator() { Node<T> currentNode = head.getNext(); - Stack<T> stack = new Stack(); - while (currentNode.getNum() != -1) { + Stack<T> stack = new Stack<>(); + while (currentNode.getNext().getAttribute() != null) { stack.push(currentNode.getAttribute()); currentNode = currentNode.getNext(); } @@ -97,14 +99,14 @@ Node<T> newNode = head.delete(0, num); if (newNode == null) return this; - return new List<T>(newNode); + return new List<>(newNode); } public List<T> replace(int num, T attribute) { Node<T> newHead = head.replaceNode(0, num, attribute); if (newHead == null) return this; - return new List<T>(newHead); + return new List<>(newHead); } public T tail() {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/Node.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/Node.java Tue Aug 04 23:07:43 2015 +0900 @@ -1,10 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.jungle.data.list; -/** - * Created by e115731 on 15/05/18. - */ + public interface Node<T> { - public int getNum(); public Node<T> getNext();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/TailNode.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/TailNode.java Tue Aug 04 23:07:43 2015 +0900 @@ -1,15 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.jungle.data.list; -/** - * Created by e115731 on 15/05/19. - */ + public class TailNode<T> implements Node<T> { - - @Override - public int getNum() { - return -1; - } - @Override public Node<T> getNext() { return null; @@ -37,11 +29,11 @@ @Override public Node<T> addLast(T attribute) { - return new DefaultNode<T>(attribute, this); + return new DefaultNode<>(attribute, this); } @Override public int length() { return 0; } -} +} \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/headNode.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/headNode.java Tue Aug 04 23:07:43 2015 +0900 @@ -1,25 +1,18 @@ package jp.ac.u_ryukyu.ie.cr.jungle.data.list; -/** - * Created by e115731 on 15/05/18. - */ public class headNode<T> implements Node<T> { - private final Node next; + private final Node<T> next; public headNode() { - this.next = new TailNode<T>(); + this.next = new TailNode<>(); } - public headNode(Node next) { + public headNode(Node<T> next) { this.next = next; } - public int getNum() { - return -1; - } - - public Node getNext() { + public Node<T> getNext() { return next; } @@ -30,28 +23,28 @@ public Node<T> add(int currentNum, int num, T attribute) { if (num == 0) { Node<T> newNode = new DefaultNode<>(attribute, next); - return new headNode<T>(newNode); + return new headNode<>(newNode); } Node<T> newNode = next.add(currentNum + 1, num, attribute); if (newNode == null) return this; - return new headNode(newNode); + return new headNode<>(newNode); } public Node<T> addLast(T attribute) { Node<T> node = next.addLast(attribute); - return new headNode<T>(node); + return new headNode<>(node); } public Node<T> delete(int currentNum, int deleteNum) { if (currentNum == deleteNum) { - return new headNode(this.next.getNext()); + return new headNode<>(this.next.getNext()); } Node<T> newNode = next.delete(currentNum + 1, deleteNum); if (newNode == null) return this; - return new headNode(newNode); + return new headNode<>(newNode); } @Override @@ -60,7 +53,7 @@ Node<T> newNode = nextNode.replaceNode(currentNum, num, attribute); if (newNode == null) return this; - return new headNode(newNode); + return new headNode<>(newNode); } @Override
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/Node.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/Node.java Tue Aug 04 23:07:43 2015 +0900 @@ -5,9 +5,6 @@ import java.util.Optional; -/** - * Created by e115731 on 15/03/23. - */ public abstract class Node<K, V> { protected K key; @@ -223,14 +220,14 @@ if (side == Rotate.L) { Node<K, V> rightNode; if (parent.right().isNotEmpty()) - rightNode = new RedNode<K, V>(parent.right().getKey(), parent.right().getValue(), parent.right().left(), parent.right().right()); // check + rightNode = new RedNode<>(parent.right().getKey(), parent.right().getValue(), parent.right().left(), parent.right().right()); // check else rightNode = new EmptyNode<>(); return parent.createNode(parent.getKey(), parent.getValue(), this, rightNode); } else { Node<K, V> leftNode; if (parent.left().isNotEmpty()) - leftNode = new RedNode<K, V>(parent.left().getKey(), parent.left().getValue(), parent.left().left(), parent.left().right()); // check + leftNode = new RedNode<>(parent.left().getKey(), parent.left().getValue(), parent.left().left(), parent.left().right()); // check else leftNode = new EmptyNode<>(); return parent.createNode(parent.getKey(), parent.getValue(), leftNode, this); @@ -239,25 +236,25 @@ protected Node rebuildFour(Node<K, V> parent, Rotate side) { //case 4 if (side == Rotate.R) { - Node<K, V> leftNode = new RedNode<K, V>(parent.left().getKey(), parent.left().getValue(), parent.left().left(), parent.left().right()); - return new BlackNode<K, V>(parent.getKey(), parent.getValue(), leftNode, this); + Node<K, V> leftNode = new RedNode<>(parent.left().getKey(), parent.left().getValue(), parent.left().left(), parent.left().right()); + return new BlackNode<>(parent.getKey(), parent.getValue(), leftNode, this); } else { - Node<K, V> rightNode = new RedNode<K, V>(parent.right().getKey(), parent.right().getValue(), parent.right().left(), parent.right().right()); - return new BlackNode<K, V>(parent.getKey(), parent.getValue(), this, rightNode); + Node<K, V> rightNode = new RedNode<>(parent.right().getKey(), parent.right().getValue(), parent.right().left(), parent.right().right()); + return new BlackNode<>(parent.getKey(), parent.getValue(), this, rightNode); } } protected Node rebuildfive(Node<K, V> parent, Rotate side) { //case5 if (side == Rotate.R) { // rotate Left - Node<K, V> leftChild = new RedNode<K, V>(parent.left().getKey(), parent.left().getValue(), parent.left().left(), parent.left().right().left()); + Node<K, V> leftChild = new RedNode<>(parent.left().getKey(), parent.left().getValue(), parent.left().left(), parent.left().right().left()); Node<K, V> rightChild = parent.left().right().right(); - Node<K, V> leftSubTreeRoot = new BlackNode<K, V>(parent.left().right().getKey(), parent.left().right().getValue(), leftChild, rightChild); + Node<K, V> leftSubTreeRoot = new BlackNode<>(parent.left().right().getKey(), parent.left().right().getValue(), leftChild, rightChild); Node<K, V> newParent = parent.createNode(parent.getKey(), parent.getValue(), leftSubTreeRoot, this); return this.rebuildsix(newParent, Rotate.R); } else { // rotate Right 修正済み Node<K, V> leftChild = parent.right().left().left(); - Node<K, V> rightChild = new RedNode<K, V>(parent.right().getKey(), parent.right().getValue(), parent.right().left().right(), parent.right().right()); - Node<K, V> rightSubTreeRoot = new BlackNode<K, V>(parent.right().left().getKey(), parent.right().left().getValue(), leftChild, rightChild); + Node<K, V> rightChild = new RedNode<>(parent.right().getKey(), parent.right().getValue(), parent.right().left().right(), parent.right().right()); + Node<K, V> rightSubTreeRoot = new BlackNode<>(parent.right().left().getKey(), parent.right().left().getValue(), leftChild, rightChild); Node<K, V> newParent = parent.createNode(parent.getKey(), parent.getValue(), this, rightSubTreeRoot); return this.rebuildsix(newParent, Rotate.L); } @@ -266,10 +263,10 @@ protected Node rebuildsix(Node<K, V> parent, Rotate side) { //case6 if (side == Rotate.L) { // rotate Left Node<K, V> leftChild = parent.right().createNode(parent.getKey(), parent.getValue(), this, parent.right().left()); //check - Node<K, V> rightChild = new BlackNode<K, V>(parent.right().right().getKey(), parent.right().right().getValue(), parent.right().right().left(), parent.right().right().right()); + Node<K, V> rightChild = new BlackNode<>(parent.right().right().getKey(), parent.right().right().getValue(), parent.right().right().left(), parent.right().right().right()); return parent.createNode(parent.right().getKey(), parent.right().getValue(), leftChild, rightChild); } else { // rotate Right - Node<K, V> leftChild = new BlackNode<K, V>(parent.left().left().getKey(), parent.left().left().getValue(), parent.left().left().left(), parent.left().left().right()); + Node<K, V> leftChild = new BlackNode<>(parent.left().left().getKey(), parent.left().left().getValue(), parent.left().left().left(), parent.left().left().right()); Node<K, V> rightChild = parent.left().createNode(parent.getKey(), parent.getValue(), parent.left().right(), this); return parent.createNode(parent.left().getKey(), parent.left().getValue(), leftChild, rightChild); } @@ -291,5 +288,6 @@ protected abstract Node deleteNode() throws RotateParent; @Test - protected abstract int checkDepth (int count , int minCount); // test method + // test method + protected abstract int checkDepth (int count , int minCount); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/TreeMap.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/TreeMap.java Tue Aug 04 23:07:43 2015 +0900 @@ -8,15 +8,13 @@ import java.util.Stack; -/** - * Created by e115731 on 15/03/23. - */ + public class TreeMap<K, V> { final Node<K, V> root; final int size; public TreeMap() { - this.root = new EmptyNode(); + this.root = new EmptyNode<>(); this.size = 0; } @@ -40,13 +38,13 @@ throw new NullPointerException(); if (isEmpty()) { - Node<K, V> newRoot = new BlackNode(key, value, new EmptyNode(), new EmptyNode()); + Node<K, V> newRoot = new BlackNode<>(key, value, new EmptyNode<>(), new EmptyNode<>()); return new TreeMap<K, V>(newRoot, size + 1); } Node<K, V> newEntry = root.put((Comparable<? super K>) key, value); - Node<K, V> newRoot = new BlackNode(newEntry.getKey(), newEntry.getValue(), newEntry.left(), newEntry.right()); - return new TreeMap(newRoot, 0); + Node<K, V> newRoot = new BlackNode<>(newEntry.getKey(), newEntry.getValue(), newEntry.left(), newEntry.right()); + return new TreeMap<>(newRoot, 0); } @@ -64,14 +62,14 @@ if (node == null) return this; // not key if (!node.isNotEmpty()) - return new TreeMap(new EmptyNode<>(), 0); - Node newRoot = new BlackNode(node.getKey(), node.getValue(), node.left(), node.right()); - return new TreeMap(newRoot, 0); + return new TreeMap<>(new EmptyNode<>(), 0); + Node newRoot = new BlackNode<>(node.getKey(), node.getValue(), node.left(), node.right()); + return new TreeMap<>(newRoot, 0); } public Iterator<K> keys() { return new Iterator<K>() { - Stack<Node> nodeStack = new Stack(); + Stack<Node> nodeStack = new Stack<>(); Node currentNode = root; @Override
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/persistent/DefaultChangeListReader.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/persistent/DefaultChangeListReader.java Tue Aug 04 23:07:43 2015 +0900 @@ -1,49 +1,46 @@ package jp.ac.u_ryukyu.ie.cr.jungle.persistent; +import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.TreeOperation; + import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.util.Iterator; import java.util.LinkedList; -import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.TreeOperation; +// not thread safe +public class DefaultChangeListReader implements ChangeListReader { + private long pos; + private ByteBuffer buf; + private FileChannel ch; -// not thread safe -public class DefaultChangeListReader implements ChangeListReader -{ - private long pos; - private ByteBuffer buf; - private FileChannel ch; - - DefaultChangeListReader(FileChannel ch,ByteBuffer buf,long pos) - { - this.pos = pos; - this.buf = buf; - this.ch = ch; - } + DefaultChangeListReader(FileChannel ch, ByteBuffer buf, long pos) { + this.pos = pos; + this.buf = buf; + this.ch = ch; + } + + @Override + public ChangeListReader newReader() { + ByteBuffer readByteBuffer = buf.asReadOnlyBuffer(); + return new DefaultChangeListReader(ch, readByteBuffer, pos); + } - @Override - public ChangeListReader newReader() - { - return new DefaultChangeListReader(ch,buf.asReadOnlyBuffer(),pos); - } + @Override + public ChangeList read() { + LinkedList<TreeOperation> list = new LinkedList<TreeOperation>(); + + int size = buf.getInt(); + if (size == 0) { + + } - @Override - public ChangeList read() - { - LinkedList<TreeOperation> list = new LinkedList<TreeOperation>(); - - int size = buf.getInt(); - if(size == 0){ - - } - - return null; - } + return null; + } - @Override - public Iterator<ChangeList> iterator() { - return null; - } - - + @Override + public Iterator<ChangeList> iterator() { + return null; + } + + }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/DefaultNodePath.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/DefaultNodePath.java Tue Aug 04 23:07:43 2015 +0900 @@ -39,14 +39,14 @@ public Pair<Integer, NodePath> pop() { Integer head = path.head(); List<Integer> tail = path.deleteHead(); - return new Pair<Integer, NodePath>(head, new DefaultNodePath(tail)); + return new Pair<>(head, new DefaultNodePath(tail)); } @Override public Pair<Integer, NodePath> last() { Integer last = path.head(); List<Integer> list = path.deleteHead(); - return new Pair<Integer, NodePath>(last, new DefaultNodePath(list)); + return new Pair<>(last, new DefaultNodePath(list)); } @Override @@ -69,11 +69,10 @@ } public List<DefaultNodePath> inits() { - List<DefaultNodePath> paths = new List(); - List<Integer> coursePath = new List(); - Iterator<Integer> iterator = path.iterator(); - while (iterator.hasNext()) { - List<Integer> tmp = coursePath.addLast(iterator.next()); + List<DefaultNodePath> paths = new List<>(); + List<Integer> coursePath = new List<>(); + for (Integer tmpPath : path) { + List<Integer> tmp = coursePath.addLast(tmpPath); paths = paths.addLast(new DefaultNodePath(tmp)); coursePath = tmp; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/DefaultTreeEditor.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/DefaultTreeEditor.java Tue Aug 04 23:07:43 2015 +0900 @@ -31,18 +31,15 @@ if(either.isA()){ return DefaultEither.newA(either.a()); } - Traversal t = either.b(); - Either<Error,LoggingNode> ret = clone(t,editor); - - return ret; + return clone(t,editor); } private Either<Error,LoggingNode> clone(Traversal t,NodeEditor editor) { // copying nodes from bottom to root - List<Direction<TreeNode>> path = new List(); + List<Direction<TreeNode>> path = new List<>(); for(Direction<TreeNode> direction : t){ path = path.addLast(direction); } @@ -70,9 +67,8 @@ if(ret.isA()){ return DefaultEither.newA(ret.a()); } - - TreeNode newParent = ret.b(); - child = newParent; + + child = ret.b(); pos = parentDirection.getPosition(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/TreeNode.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/TreeNode.java Tue Aug 04 23:07:43 2015 +0900 @@ -12,6 +12,4 @@ public TreeNode createNewNode(); public Either<Error, TreeNode> appendRootNode(); - - public String getNodeId(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/logger/LoggingAttributes.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/logger/LoggingAttributes.java Tue Aug 04 23:07:43 2015 +0900 @@ -1,15 +1,15 @@ package jp.ac.u_ryukyu.ie.cr.jungle.store.impl.logger; -import java.nio.ByteBuffer; - +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNodeAttributes; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.DeleteAttributeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.PutAttributeOperation; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; -import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNodeAttributes; import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultEither; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; + +import java.nio.ByteBuffer; public class LoggingAttributes //implements EditableAttributes { @@ -30,7 +30,7 @@ private Either<Error,LoggingNode> edit(NodeOperation _op) { - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error,TreeNode> either = _op.invoke(wrap); + Either<Error,TreeNode> either = _op.invoke(wrap); if(either.isA()){ return DefaultEither.newA(either.a()); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/logger/LoggingChildren.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/logger/LoggingChildren.java Tue Aug 04 23:07:43 2015 +0900 @@ -29,7 +29,7 @@ public Either<Error,LoggingNode> edit(NodeOperation _op) { - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error,TreeNode> either = _op.invoke(wrap); + Either<Error,TreeNode> either = _op.invoke(wrap); if(either.isA()){ return DefaultEither.newA(either.a()); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/logger/LoggingNode.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/logger/LoggingNode.java Tue Aug 04 23:07:43 2015 +0900 @@ -47,7 +47,7 @@ return edit(replaceRootNode); } - public Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error, LoggingNode> edit(NodeOperation op){ + public Either<Error, LoggingNode> edit(NodeOperation op){ Either<Error,TreeNode> either = op.invoke(wrap); if(either.isA()){ return DefaultEither.newA(either.a());
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/index/IndexCreater.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/index/IndexCreater.java Tue Aug 04 23:07:43 2015 +0900 @@ -12,22 +12,20 @@ public class IndexCreater { - TreeNode root; TreeNode node; int childNumber; private TreeNodeChildren children; - private Stack<TreeNode> nodeStack = new Stack<TreeNode>(); - private Stack<Integer> searchStack = new Stack<Integer>(); ParentIndex parentIndex = new ParentIndex(); - TreeMap<String, TreeMap<String, List<TreeNode>>> indexList = new TreeMap(); + TreeMap<String, TreeMap<String, List<TreeNode>>> indexList = new TreeMap<>(); public IndexCreater(TreeNode rootNode) { - this.root = rootNode; + Stack<TreeNode> nodeStack = new Stack<>(); + Stack<Integer> searchStack = new Stack<>(); this.node = rootNode; while (node != null) { TreeNode targetNode = node; Iterator<String> keys = targetNode.getAttributes().getKeys(); - for (;keys.hasNext();) { + for (; keys.hasNext(); ) { String key = keys.next(); String value = targetNode.getAttributes().getString(key); if (value != null) @@ -41,7 +39,7 @@ parentIndex.set(parent, node); childNumber = 1; searchStack.push(childNumber); - } else if (node == root) { + } else if (node == rootNode) { node = null; // no more node children = null; return; @@ -57,7 +55,7 @@ children = node.getChildren(); childNumber = searchStack.pop(); for (; children.size() == childNumber; ) { - if (node == root) { + if (node == rootNode) { node = null; // no more node children = null; return; @@ -78,14 +76,14 @@ } public TreeMap<String, TreeMap<String, List<TreeNode>>> set(String key, String value, TreeNode node) { - if (key == null ) + if (key == null) System.out.println(""); Optional<TreeMap<String, List<TreeNode>>> indexOp = indexList.get(key); if (!indexOp.isPresent()) { - TreeMap<String, List<TreeNode>> index = new TreeMap(); - List<TreeNode> nodeList = new List(); + TreeMap<String, List<TreeNode>> index = new TreeMap<>(); + List<TreeNode> nodeList = new List<>(); nodeList = nodeList.addLast(node); - TreeMap<String, List<TreeNode>> newIndex = index.put(value, nodeList); + TreeMap newIndex = index.put(value, nodeList); indexList = indexList.put(key, newIndex); return indexList; } @@ -99,11 +97,11 @@ newNodeList = nodeListOp.get().addLast(node); } else { - List<TreeNode> nodeList = new List(); + List<TreeNode> nodeList = new List<>(); newNodeList = nodeList.addLast(node); } - TreeMap<String, List<TreeNode>> newIndex = index.put(value, newNodeList); + TreeMap newIndex = index.put(value, newNodeList); indexList = indexList.put(key, newIndex); return indexList;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/DefaultEvaluator.java Tue Aug 04 09:54:01 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/DefaultEvaluator.java Tue Aug 04 23:07:43 2015 +0900 @@ -27,9 +27,6 @@ if (head == _pos) { result = Result.ACCEPT; nextEvaluator = new DefaultEvaluator(pop.right()); - } else if (_pos > _current.getChildren().size() - 1) { - result = Result.BREAK; - nextEvaluator = null; } else { result = Result.CONTINUE; nextEvaluator = null;