Mercurial > hg > Members > tatsuki > bench > jungle-core
changeset 55:4ff16d970ffc
added getter to operations
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/persistent/DefaultChangeListReader.java Fri Feb 08 17:08:42 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/persistent/DefaultChangeListReader.java Fri Feb 08 19:36:16 2013 +0900 @@ -2,6 +2,9 @@ import java.nio.ByteBuffer; import java.nio.channels.FileChannel; +import java.util.LinkedList; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; // not thread safe public class DefaultChangeListReader implements ChangeListReader @@ -26,6 +29,12 @@ @Override public ChangeList read() { + LinkedList<TreeOperation> list = new LinkedList<TreeOperation>(); + + int size = buf.getInt(); + if(size == 0){ + + } return null; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/persistent/DefaultChangeListWriter.java Fri Feb 08 17:08:42 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/persistent/DefaultChangeListWriter.java Fri Feb 08 19:36:16 2013 +0900 @@ -1,5 +1,17 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent; -public class DefaultChangeListWriter { +import java.nio.ByteBuffer; +public class DefaultChangeListWriter implements ChangeListWriter +{ + public DefaultChangeListWriter(ByteBuffer _buf) + { + + } + + @Override + public Result write(ChangeList _operations) + { + return null; + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/persistent/DefaultJournal.java Fri Feb 08 17:08:42 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/persistent/DefaultJournal.java Fri Feb 08 19:36:16 2013 +0900 @@ -56,14 +56,12 @@ public static void main(String _args[]) throws Exception { RandomAccessFile f = new RandomAccessFile("./miscs/1.dat","rw"); - f.setLength(20); - MappedByteBuffer a = f.getChannel().map(MapMode.READ_WRITE,0,10); + MappedByteBuffer a = f.getChannel().map(MapMode.READ_WRITE,10,10); MappedByteBuffer b = f.getChannel().map(MapMode.READ_WRITE,10,10); - f.setLength(30); MappedByteBuffer c = f.getChannel().map(MapMode.READ_WRITE,20,10); - a.putInt(1); - b.putInt(1); + a.putInt(5); + System.out.println(b.getInt()); c.putInt(2); a.force(); b.force(); @@ -94,10 +92,6 @@ ByteBuffer readBuf = ch.map(MapMode.READ_ONLY,0,READ_BUFFER_SIZE); ByteBuffer writeBuf = ch.map(MapMode.READ_WRITE,length,WRITE_BUFFER_SIZE); - // TODO : from here - //ChangeListReader reader = new DefaultChangeListReader(ch); - //ChangeListWriter writer = new DefaultChangeListWriter(ch); - }catch(FileNotFoundException _e){ _e.printStackTrace(); return null; // should return Error here.
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/AppendChildAtOperation.java Fri Feb 08 17:08:42 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/AppendChildAtOperation.java Fri Feb 08 19:36:16 2013 +0900 @@ -1,5 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations; +import java.nio.ByteBuffer; + import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.AppendChildAt; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; @@ -26,4 +28,22 @@ AppendChildAt appendChildAt = new AppendChildAt(pos); return appendChildAt.edit(_target); } + + @Override + public int getPosition() + { + return pos; + } + + @Override + public String getKey() + { + return null; + } + + @Override + public ByteBuffer getValue() + { + return null; + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/DeleteAttributeOperation.java Fri Feb 08 17:08:42 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/DeleteAttributeOperation.java Fri Feb 08 19:36:16 2013 +0900 @@ -1,5 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations; +import java.nio.ByteBuffer; + import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteAttribute; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; @@ -27,4 +29,22 @@ DeleteAttribute deleteAttribute = new DeleteAttribute(key); return deleteAttribute.edit(_target); } + + @Override + public int getPosition() + { + return -1; + } + + @Override + public String getKey() + { + return key; + } + + @Override + public ByteBuffer getValue() + { + return null; + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/DeleteChildAtOperation.java Fri Feb 08 17:08:42 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/DeleteChildAtOperation.java Fri Feb 08 19:36:16 2013 +0900 @@ -1,5 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations; +import java.nio.ByteBuffer; + import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteChildAt; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; @@ -27,4 +29,22 @@ DeleteChildAt deleteChildAt = new DeleteChildAt(pos); return deleteChildAt.edit(_target); } + + @Override + public int getPosition() + { + return pos; + } + + @Override + public String getKey() + { + return null; + } + + @Override + public ByteBuffer getValue() + { + return null; + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/NodeOperation.java Fri Feb 08 17:08:42 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/NodeOperation.java Fri Feb 08 19:36:16 2013 +0900 @@ -1,5 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations; +import java.nio.ByteBuffer; + import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; @@ -9,6 +11,10 @@ { public Command getCommand(); public <T extends EditableNode<T>> Either<Error,T> invoke(T _target); + + public int getPosition(); + public String getKey(); + public ByteBuffer getValue(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/PutAttributeOperation.java Fri Feb 08 17:08:42 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/PutAttributeOperation.java Fri Feb 08 19:36:16 2013 +0900 @@ -31,4 +31,22 @@ PutAttribute putAttribute = new PutAttribute(key,value); return putAttribute.edit(_target); } + + @Override + public int getPosition() + { + return -1; + } + + @Override + public String getKey() + { + return key; + } + + @Override + public ByteBuffer getValue() + { + return value; + } } \ No newline at end of file