Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 325:abd8e3cf9bfc
merge
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/EmptyNode.java Mon Apr 10 18:25:05 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/EmptyNode.java Sat Jul 08 20:16:31 2017 +0900 @@ -73,7 +73,7 @@ protected int checkDepth(int count, int minCount) { // test method if (count < minCount | minCount == 0) minCount = count; - System.out.println("depth = " + count); + //System.out.println("depth = " + count); Assert.assertTrue(count <= 2 * minCount); return minCount;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/TreeMap.java Mon Apr 10 18:25:05 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/TreeMap.java Sat Jul 08 20:16:31 2017 +0900 @@ -110,6 +110,6 @@ @Test public void checkDepth() { root.checkDepth(0, 0); - System.out.println("-----------------------------------"); + //System.out.println("-----------------------------------"); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/ColorlessTreeNode.java Mon Apr 10 18:25:05 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/ColorlessTreeNode.java Sat Jul 08 20:16:31 2017 +0900 @@ -110,14 +110,14 @@ */ public abstract int checkDepth(int count, int minCount); - public RebuildNode delete(String insertKey, ByteBuffer deleteValue, ColorlessTreeNode parent, Rotate side) { + public RebuildNode delete(String deleteKey, ByteBuffer deleteValue, ColorlessTreeNode parent, Rotate side) { if (!this.empty()) { RebuildNode rebuildNode; long result = this.compare(deleteValue); if (result > 0) { - rebuildNode = right().delete(insertKey, deleteValue, this, Rotate.R); + rebuildNode = right().delete(deleteKey, deleteValue, this, Rotate.R); } else if (result < 0) { - rebuildNode = left().delete(insertKey, deleteValue, this, Rotate.L); + rebuildNode = left().delete(deleteKey, deleteValue, this, Rotate.L); } else { rebuildNode = replaceNode(parent); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/RedBlackTreeEvaluator.java Mon Apr 10 18:25:05 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/RedBlackTreeEvaluator.java Sat Jul 08 20:16:31 2017 +0900 @@ -4,6 +4,8 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; +import java.nio.ByteBuffer; + /** * Created by e115731 on 2017/01/26. */ @@ -24,7 +26,11 @@ @Override public Evaluation evaluate(TreeNode current, int pos) { Attributes attribute = current.getAttributes(); - long value = attribute.get(key).hashCode(); + ByteBuffer k = attribute.get(key); + if (k == null) { + return new DefaultEvaluation(Result.GOAL, null); + } + long value = k.hashCode(); Result result = null; Evaluator nextEvaluator = null;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJournal.java Mon Apr 10 18:25:05 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJournal.java Sat Jul 08 20:16:31 2017 +0900 @@ -5,22 +5,39 @@ import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeListWriter; import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; public class PersistentJournal implements NetworkJournal { - private ChangeListWriter WRITER; + private ChangeListReader READER; private OutputStream out; private InputStream in; + public String logDirectory = "log"; private String logFileName; public PersistentJournal() { } + + public PersistentJournal(String logName) throws FileNotFoundException { + init(logDirectory,logName); + } - public PersistentJournal(File file) throws FileNotFoundException { + public PersistentJournal(String dirName, String logName) throws FileNotFoundException { + init(dirName, logName); + } + + public void init(String dirName, String logName) throws FileNotFoundException { + File dir = new File(dirName); + if (! (dir.exists())) { + dir.mkdir(); + } + logDirectory = dirName; + logFileName = logName; + File file = new File(logDirectory + "/" + logFileName); out = new FileOutputStream(file,true); in = new FileInputStream(file); - WRITER = new PersistentChangeListWriter(out); READER = new PersistentChangeListReader(in); } @@ -35,7 +52,7 @@ logFileName = timeStamp + ".log"; OutputStream outStream = null; try { - outStream = new FileOutputStream(new File("./log/"+logFileName)); + outStream = new FileOutputStream(new File(logDirectory+"/"+logFileName)); } catch (FileNotFoundException e) { e.printStackTrace(); } @@ -53,8 +70,7 @@ public void setOutputStream(OutputStream _out) { out = _out; - WRITER = new PersistentChangeListWriter(out); - } + } public OutputStream getOutputStream() { return out; @@ -70,7 +86,7 @@ } public String getLogName(){ - return logFileName; + return logDirectory+"/"+logFileName; } public void close() throws IOException {
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/data/MsgPack.java Mon Apr 10 18:25:05 2017 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/data/MsgPack.java Sat Jul 08 20:16:31 2017 +0900 @@ -13,8 +13,13 @@ @Test public void MsgPack() throws IOException { + String dirName = "log"; + File dir = new File(dirName); + if (! (dir.exists())) { + dir.mkdir(); + } String timeStamp = Long.toString(System.currentTimeMillis()); - File file = new File("./log/" + timeStamp + ".log"); + File file = new File(dirName +"/"+ timeStamp + ".log"); OutputStream out = new FileOutputStream(file,true); InputStream in = new FileInputStream(file); MessagePack msgpack = new MessagePack();