Mercurial > hg > Database > jungle-sharp
view Main/jungle-main/DefaultJungleTree.cs @ 41:bd44baa491a9 default tip
add TestJungleCore.cs
author | Kazuma Takeda |
---|---|
date | Thu, 23 Feb 2017 17:19:55 +0900 |
parents | 1466993c104c |
children |
line wrap: on
line source
namespace JungleDB { public class DefaultJungleTree : JungleTree { private AtomicReference<TreeContext> repository; private string uuid; private ChangeListWriter writer; private TreeEditor treeEditor; public DefaultJungleTree(TreeContext tc, string uuid, ChangeListWriter writer, TreeEditor editor) { this.repository = new AtomicReference<TreeContext>(tc); this.uuid = uuid; this.writer = writer; this.treeEditor = editor; } public JungleTreeEditor getTreeEditor() { TreeContext tc = repository.Get (); DefaultTransactionManager txManager = new DefaultTransactionManager(writer, tc, repository, uuid); TreeNode root = tc.getRoot(); return new DefaultJungleTreeEditor(root, txManager, treeEditor); } public JungleTreeEditor getLocalTreeEditor() { return getTreeEditor (); } public TreeNode getRootNode() { TreeContext tc = repository.Get(); return tc.getRoot(); // default jungle innner change list? } public InterfaceTraverser getTraverser(bool useIndex) { TreeContext tc = repository.Get(); return tc.getTraverser(); } public TreeMap<string, TreeMap<string, List<TreeNode>>> getIndex() { TreeContext tc = repository.Get(); return tc.getIndex(); } public long revision() { TreeContext tc = repository.Get(); return tc.getRevision(); } public Either<Error, JungleTree> getOldTree(long revision) { TreeContext tc = repository.Get(); for (; tc.getRevision() != revision; ) { tc = tc.prev(); if (tc == null) return DefaultEither<Error, JungleTree>.newA(GetOldTreeError.OLD_TREE_NOT_FOUND); } string oldTreeUuid = uuid + revision; JungleTree oldTree = new DefaultJungleTree(tc, oldTreeUuid, writer, treeEditor); return DefaultEither<Error, JungleTree>.newB(oldTree); } public Either<Error, TreeNode> getNodeOfPath(NodePath path) { //eitherはどちらのインターフェースをつかうか、みたいな TreeNode node = repository.Get().getRoot(); foreach (int num in path) { if (num == -1) continue; Either<Error, TreeNode> either = node.getChildren().at(num); if (either.isA()) return either; node = either.b(); } return DefaultEither<Error, TreeNode>.newB(node); } public void setBufferSize(int _bufferSize) { // not use } } }