Mercurial > hg > Database > jungle-sharp
changeset 31:1466993c104c
byte[] to object Rewrite.
line wrap: on
line diff
--- a/.hgignore Wed Jan 18 21:54:26 2017 +0900 +++ b/.hgignore Fri Jan 20 07:08:03 2017 +0900 @@ -1,1 +1,2 @@ .DS_Store +.git
--- a/Main/jungle-main/DefaultJungleTree.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/DefaultJungleTree.cs Fri Jan 20 07:08:03 2017 +0900 @@ -43,7 +43,7 @@ } public long revision() { - TreeContext tc = repository.Get(); // 確かにnull どこから来てる? repositoryのインスタンスを生成してないからかも + TreeContext tc = repository.Get(); return tc.getRevision(); }
--- a/Main/jungle-main/JungleTreeEditor.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/JungleTreeEditor.cs Fri Jan 20 07:08:03 2017 +0900 @@ -4,10 +4,11 @@ void SetPrevPath (NodePath path); Either<Error,JungleTreeEditor> addNewChildAt(NodePath path,int pos); Either<Error,JungleTreeEditor> deleteChildAt(NodePath path,int pos); - Either<Error,JungleTreeEditor> putAttribute(NodePath path,string key, byte[] value); - Either<Error,JungleTreeEditor> putAttribute(string key, byte[] value); + Either<Error,JungleTreeEditor> putAttribute(NodePath path, string key, object value); + Either<Error,JungleTreeEditor> putAttribute(string key, object value); + Either<Error,JungleTreeEditor> putAttribute(object value); // add Method put Attribute (path, T?); - // Either<Error, JungleTreeEditor> putAttribute<T>(NodePath path, string Key, MultiAttributes<T> value); + // Either<Error, JungleTreeEditor> putAttribute(NodePath path, string Key, T value); Either<Error,JungleTreeEditor> deleteAttribute(NodePath path,string key); Either<Error, JungleTreeEditor> replaceNewRootNode(); Either<Error,JungleTreeEditor> edit(NodePath path, NodeEditor editor);
--- a/Main/jungle-main/core/Attributes.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/core/Attributes.cs Fri Jan 20 07:08:03 2017 +0900 @@ -1,5 +1,6 @@ using UnityEngine; public interface Attributes{ - byte[] get (string key); + object get (string key); + T get<T> (string key); string getString (string key); }
--- a/Main/jungle-main/store/impl/TreeNodeAttributes.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/store/impl/TreeNodeAttributes.cs Fri Jan 20 07:08:03 2017 +0900 @@ -2,9 +2,9 @@ namespace JungleDB { public interface TreeNodeAttributes : Attributes { Either<Error, TreeNode> delete(string key); - Either<Error, TreeNode> put(string key, byte[] value); + Either<Error, TreeNode> put(string key, object value); // Either<Error, TreeNode> put<T> (string key, MultiAttributes<T> value); - TreeMap<string, byte[]> getAttributesAsRawMap(); + TreeMap<string, object> getAttributesAsRawMap(); IEnumerator<string> getKeys(); } }
--- a/Main/jungle-main/store/impl/logger/LoggingAttributes.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/store/impl/logger/LoggingAttributes.cs Fri Jan 20 07:08:03 2017 +0900 @@ -11,7 +11,7 @@ log = _log; } - public byte[] get(string _key) + public object get(string _key) { TreeNodeAttributes attributes = wrap.getAttributes(); return attributes.get(_key); @@ -30,7 +30,7 @@ return DefaultEither<Error,LoggingNode>.newB(newLogNode); } - + public Either<Error,LoggingNode> delete(string _key) { @@ -38,10 +38,11 @@ return edit(deleteAttribute); } - public Either<Error,LoggingNode> put(string _key, byte[] _value) + public Either<Error,LoggingNode> put(string _key, object _value) { PutAttributeOperation putAttribute = new PutAttributeOperation(_key,_value); return edit(putAttribute); } + } }
--- a/Main/jungle-main/store/impl/logger/LoggingAttributes.cs.meta Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/store/impl/logger/LoggingAttributes.cs.meta Fri Jan 20 07:08:03 2017 +0900 @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: ffdd92c38e6228540835ba42bf3f22f5 -timeCreated: 1477164413 +guid: d186e0c089e634b018ea0762ef4769bd +timeCreated: 1484772179 licenseType: Free MonoImporter: serializedVersion: 2
--- a/Main/jungle-main/store/operations/AppendChildAtOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/store/operations/AppendChildAtOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -31,9 +31,9 @@ return null; } - public byte[] getValue() + public object getValue() { - return new byte[1]{0}; + return null; } }
--- a/Main/jungle-main/store/operations/DeleteAttributeOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/store/operations/DeleteAttributeOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -26,8 +26,8 @@ return key; } - public byte[] getValue() { - return new byte[1]{0}; + public object getValue() { + return null; } } }
--- a/Main/jungle-main/store/operations/DeleteChildAtOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/store/operations/DeleteChildAtOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -32,9 +32,9 @@ return null; } - public byte[] getValue() + public object getValue() { - return new byte[1]{0}; + return null; } }
--- a/Main/jungle-main/store/operations/NodeOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/store/operations/NodeOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -4,7 +4,7 @@ Either<Error,TreeNode> invoke (TreeNode _target); int getPosition(); string getKey(); - byte[] getValue(); + object getValue(); } public interface NodeOperation<T> {
--- a/Main/jungle-main/store/operations/PutAttributeOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/store/operations/PutAttributeOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -1,9 +1,9 @@ namespace JungleDB { public class PutAttributeOperation : NodeOperation { private string key; - private byte[] value; + private object value; - public PutAttributeOperation(string _key, byte[] _value) + public PutAttributeOperation(string _key, object _value) { key = _key; value = _value; @@ -29,7 +29,7 @@ return key; } - public byte[] getValue() + public object getValue() { return value; }
--- a/Main/jungle-main/store/operations/ReplaceRootNodeOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/store/operations/ReplaceRootNodeOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -21,8 +21,8 @@ return null; } - public byte[] getValue() { - return new byte[1]{0}; + public object getValue() { + return null; } } }
--- a/Main/jungle-main/store/transformer/PutAttribute.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/store/transformer/PutAttribute.cs Fri Jan 20 07:08:03 2017 +0900 @@ -4,14 +4,21 @@ namespace JungleDB { public class PutAttribute : NodeEditor { private string key; - private byte[] value; + private object value; - public PutAttribute(string _key, byte[] _value) + public PutAttribute(string _key, object _value) { key = _key; value = _value; } + public PutAttribute(object _value) + { + key = _value.ToString(); + Debug.Log (key); + value = _value; + } + public Either<Error,LoggingNode> _edit(LoggingNode _e) { Either<Error,LoggingNode> either = _e.getAttributes().put(key,value);
--- a/Main/jungle-main/transaction/DefaultJungleTreeEditor.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/transaction/DefaultJungleTreeEditor.cs Fri Jan 20 07:08:03 2017 +0900 @@ -70,24 +70,23 @@ DeleteChildAt deleteChildAt = new DeleteChildAt(_pos); return _edit(_path,deleteChildAt); } - - public Either<Error, JungleTreeEditor> putAttribute(NodePath _path, string _key, byte[] _value) { + + + public Either<Error, JungleTreeEditor> putAttribute(NodePath _path, string _key, object _value) { PutAttribute putAttribute = new PutAttribute (_key, _value); return _edit (_path, putAttribute); } - /// <summary> - /// When use path, before create path. - /// * Problem -> copy to path from root everytime. - /// </summary> - /// <returns>The attribute.</returns> - /// <param name="_key">Key.</param> - /// <param name="_value">Value.</param> - public Either<Error, JungleTreeEditor> putAttribute(string _key, byte[] _value) { + public Either<Error, JungleTreeEditor> putAttribute(string _key, object _value) { PutAttribute putAttribute = new PutAttribute (_key, _value); return _edit (prevPath, putAttribute); } + public Either<Error, JungleTreeEditor> putAttribute(object _value) { + PutAttribute putAttribute = new PutAttribute (_value); + return _edit (prevPath, putAttribute); + } + public Either<Error, JungleTreeEditor> deleteAttribute(NodePath _path, string _key) { DeleteAttribute deleteAttribute = new DeleteAttribute (_key); return _edit (_path, deleteAttribute); @@ -99,7 +98,6 @@ public Either<Error,JungleTreeEditor> commit() { Either<Error,TransactionManager> either = this.txManager.commit(this.root, this.log); - // このlogをサーバにpushする? if(either.isA()){ return DefaultEither<Error, JungleTreeEditor>.newA(either.a()); }
--- a/Main/jungle-main/transaction/DefaultTreeNode.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/transaction/DefaultTreeNode.cs Fri Jan 20 07:08:03 2017 +0900 @@ -4,15 +4,15 @@ public class DefaultTreeNode : TreeNode { private List<TreeNode> children; - private TreeMap<string,byte[]> attrs; + private TreeMap<string, object> attrs; private static readonly List<TreeNode> NIL_LIST = new List<TreeNode>(); public DefaultTreeNode() - : this (NIL_LIST, new TreeMap<string,byte[]> ()) + : this (NIL_LIST, new TreeMap<string, object> ()) { } - public DefaultTreeNode(List<TreeNode> _children, TreeMap<string, byte[]> _attrs) { + public DefaultTreeNode(List<TreeNode> _children, TreeMap<string, object> _attrs) { attrs = _attrs; children = _children; } @@ -34,7 +34,7 @@ } public Either<Error, TreeNode> appendRootNode() { - TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<string, byte[]>()); + TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<string, object>()); Either<Error, TreeNode> either = newRootChildren.addNewChildAt(0,this); return either; }
--- a/Main/jungle-main/transaction/DefaultTreeNodeAttribute.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/transaction/DefaultTreeNodeAttribute.cs Fri Jan 20 07:08:03 2017 +0900 @@ -7,14 +7,14 @@ namespace JungleDB { public class DefaultTreeNodeAttribute : TreeNodeAttributes { public List<TreeNode> children; - public TreeMap<string, byte[]> attrs; + public TreeMap<string, object> attrs; - public DefaultTreeNodeAttribute(List<TreeNode> _children, TreeMap<string, byte[]> _attrs){ + public DefaultTreeNodeAttribute(List<TreeNode> _children, TreeMap<string, object> _attrs){ children = _children; attrs = _attrs; } - public TreeMap<string, byte[]> getAttributesAsRawMap(){ + public TreeMap<string, object> getAttributesAsRawMap(){ return attrs; } @@ -27,35 +27,45 @@ return DefaultEither<Error,TreeNode>.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); } - TreeMap<string, byte[]> newMap = attrs.delete(_key); + TreeMap<string, object> newMap = attrs.delete(_key); TreeNode newNode = new DefaultTreeNode(children, newMap); return DefaultEither<Error,TreeNode>.newB(newNode); } - public Either<Error, TreeNode> put(string _key, byte[] _value){ + public Either<Error, TreeNode> put(string _key, object _value){ if (_key == null || _value == null) { return DefaultEither<Error, TreeNode>.newA (NodeEditorError.NULL_VALUE_NOT_ALLOWED); } - TreeMap<string, byte[]> newMap = attrs.put (_key, _value); + TreeMap<string, object> newMap = attrs.put (_key, _value); TreeNode newNode = new DefaultTreeNode (children, newMap); return DefaultEither<Error, TreeNode>.newB (newNode); } - public byte[] get(string _key) { + public object get(string _key) { if (_key == null) - return new byte[1]{0}; + return null; - byte[] op = attrs.get(_key); + object op = attrs.get(_key); if (op != null) return op; - return new byte[1]{0}; + return null; + } + + public T get<T> (string _key) { + if (_key == null) + return default(T); + + T op = (T)attrs.get (_key); + if (op != null) + return op; + return default(T); } public string getString(string key) { - return Encoding.UTF8.GetString (attrs.get (key)); + return attrs.get(key).ToString(); } public IEnumerator<string> getKeys(){
--- a/Main/jungle-main/transaction/DefaultTreeNodeChildren.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-main/transaction/DefaultTreeNodeChildren.cs Fri Jan 20 07:08:03 2017 +0900 @@ -5,9 +5,9 @@ public class DefaultTreeNodeChildren : TreeNodeChildren { private List<TreeNode> children; - private TreeMap<string, byte[]> attrs; + private TreeMap<string, object> attrs; - public DefaultTreeNodeChildren(List<TreeNode> _children, TreeMap<string, byte[]> _attrs){ + public DefaultTreeNodeChildren(List<TreeNode> _children, TreeMap<string, object> _attrs){ children = _children; attrs = _attrs; }
--- a/Main/jungle-network/operations/NetworkAppendChildAtOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-network/operations/NetworkAppendChildAtOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -30,7 +30,7 @@ return null; } - public byte[] getValue() { + public object getValue() { return null; } }
--- a/Main/jungle-network/operations/NetworkDeleteAttributeOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-network/operations/NetworkDeleteAttributeOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -30,7 +30,7 @@ return this.Key; } - public byte[] getValue() { + public object getValue() { return null; } }
--- a/Main/jungle-network/operations/NetworkDeleteChildAtOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-network/operations/NetworkDeleteChildAtOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -30,7 +30,7 @@ return null; } - public byte[] getValue () { + public object getValue () { return null; } }
--- a/Main/jungle-network/operations/NetworkNodeOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-network/operations/NetworkNodeOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -6,7 +6,7 @@ public int Position; public string Key; - public byte[] Value; + public object Value; public int commandType; // when switch use static readonly so, use const. @@ -75,7 +75,7 @@ return this.Key; } - public byte[] getValue() { + public object getValue() { return this.Value; }
--- a/Main/jungle-network/operations/NetworkPutAttributeOperation.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-network/operations/NetworkPutAttributeOperation.cs Fri Jan 20 07:08:03 2017 +0900 @@ -5,7 +5,7 @@ public class NetworkPutAttributeOperation : NodeOperation { public string Key; - public byte[] Value; + public object Value; public NetworkPutAttributeOperation() { this.Key = null; @@ -33,7 +33,7 @@ return -1; } - public byte[] getValue () { + public object getValue () { return this.Value; } }
--- a/Main/jungle-network/transaction/NetworkDefaultJungleTreeEditor.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Main/jungle-network/transaction/NetworkDefaultJungleTreeEditor.cs Fri Jan 20 07:08:03 2017 +0900 @@ -97,15 +97,21 @@ return this.TreeEditor(_path,deleteChildAt); } - public Either<Error,JungleTreeEditor> putAttribute(NodePath _path, string _key, byte[] _value) + public Either<Error,JungleTreeEditor> putAttribute(NodePath _path, string _key, object _value) { PutAttribute putAttribute = new PutAttribute(_key,_value); - return this.TreeEditor(_path,putAttribute); + return this.TreeEditor(_path, putAttribute); } - public Either<Error,JungleTreeEditor> putAttribute(string _key, byte[] _value) + public Either<Error,JungleTreeEditor> putAttribute(string _key, object _value) { - PutAttribute putAttribute = new PutAttribute(_key,_value); + PutAttribute putAttribute = new PutAttribute(_key, _value); + return this.TreeEditor(prevPath, putAttribute); + } + + public Either<Error,JungleTreeEditor> putAttribute(object _value) + { + PutAttribute putAttribute = new PutAttribute(_value.ToString() ,_value); return this.TreeEditor(prevPath, putAttribute); }
--- a/Test/junge-main/jungle/core/nodeeditor/PutAttributeTest.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Test/junge-main/jungle/core/nodeeditor/PutAttributeTest.cs Fri Jan 20 07:08:03 2017 +0900 @@ -18,7 +18,7 @@ } LoggingNode newnode = either.b (); Debug.Log (newnode); - byte[] ret = newnode.getAttributes ().get (key); + object ret = newnode.getAttributes ().get (key); Debug.Log ("insertしたものは" + ret); }
--- a/Test/jungle-network/operations/NetworkPutAttributeOperationTest.cs Wed Jan 18 21:54:26 2017 +0900 +++ b/Test/jungle-network/operations/NetworkPutAttributeOperationTest.cs Fri Jan 20 07:08:03 2017 +0900 @@ -17,7 +17,6 @@ ObjectPacker unpack = new ObjectPacker(); NetworkPutAttributeOperation nOp = unpack.Unpack<NetworkPutAttributeOperation>(packValue); - print(System.Text.ASCIIEncoding.UTF8.GetString(nOp.getValue())); print (nOp.getCommand()); } }