Mercurial > hg > Members > tatsuki > jungle-bench
changeset 16:eed6235830c9
add timeMeasurementCreateIndex
author | one |
---|---|
date | Mon, 08 Dec 2014 19:11:19 +0900 |
parents | 89478f2ea07f |
children | 917ecf2c7350 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementCreateIndex.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementJuGrixFunction.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/extendXmlTree.java |
diffstat | 3 files changed, 117 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementCreateIndex.java Mon Dec 08 19:11:19 2014 +0900 @@ -0,0 +1,116 @@ +package jp.ac.u_ryukyu.ie.cr.tatsuki.xml; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.ByteBuffer; +import java.util.Iterator; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.xml.sax.SAXException; + +import fj.data.List; +import ac.jp.u_ryukyu.cr.ie.tatsuki.xmlReader.ReadXmlHandler; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.NullJournal; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultChangeSet; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeContext; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; +import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Index; +import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.ParentIndex; + +public class TimeMeasurementCreateIndex { + private static int personCount = 10; + + public static void main(String args[]) throws FileNotFoundException, + ParserConfigurationException, SAXException, IOException { + Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor( + new DefaultTraverser())); + + // JungleTree readXmlTree = readXml("Person", jungle); + JungleTree orgTree = readXml("Organization", jungle); + JungleTree roleTree = readXml("Role", jungle); + + File file = new File("./time/createParentIndexUntil"); + file.delete(); + + for (; personCount <= 300;) { + JungleTree tree = createJungleTree("Tree"); + JungleTreeEditor editor = tree.getTreeEditor(); + NodePath path = new DefaultNodePath(); + editor = editor.addNewChildAt(path, 0).b(); + editor = editor.putAttribute(path.add(0), "element", + ByteBuffer.wrap("Persons".getBytes())).b(); + + for (int count = 0; count < personCount; count++) { + editor = extendXmlTree.extendsTree(editor, orgTree, roleTree, + count); + } + editor.success(); + personCount = personCount + 10; + } + } + + private static JungleTree createJungleTree(String name) { + ChangeList list = new ChangeList() { + @Override + public Iterator<TreeOperation> iterator() { + List<TreeOperation> nil = List.nil(); + return nil.iterator(); + } + + @Override + public String uuid() { + return "hoge"; + } + + @Override + public String getTreeName() { + return name; + } + + }; + + DefaultTreeNode root = new DefaultTreeNode(); + Index index = new Index(); + ParentIndex parentIndex = new ParentIndex(); + ChangeSet set = new DefaultChangeSet(root, null, list, "hoge", name, 0, + index.getIndex(), parentIndex.getParentIndex()); + DefaultTreeContext tc = new DefaultTreeContext(root, set); + JungleTree newTree = new DefaultJungleTree(tc, "hoge", + new NullJournal().getWriter(), new DefaultTreeEditor( + new DefaultTraverser())); + return newTree; + } + + private static JungleTree readXml(String xml, Jungle jungle) + throws ParserConfigurationException, SAXException, IOException, + FileNotFoundException { + SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); + SAXParser saxParser = saxParserFactory.newSAXParser(); + JungleTree tree = jungle.createNewTree(xml); + ReadXmlHandler readXmlHandler = new ReadXmlHandler(tree); + saxParser.parse(new FileInputStream( + "/Users/one/Documents/workspace/JungleXMLReader/xml/" + xml + + ".xml"), readXmlHandler); + return readXmlHandler.getTree(); + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementJuGrixFunction.java Mon Dec 08 01:08:03 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementJuGrixFunction.java Mon Dec 08 19:11:19 2014 +0900 @@ -28,10 +28,7 @@ filterIds.add("r:5"); long t2; long t1; - t1 = System.currentTimeMillis(); JuGrix jugrix = extendXmlTree.createJuGrix(useIndex, personCount); - t2 = System.currentTimeMillis(); - System.out.println("create tree =" + (t2 - t1) + "s"); Random random = new Random(); functions(jugrix, orgId, personId, filterIds);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/extendXmlTree.java Mon Dec 08 01:08:03 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/extendXmlTree.java Mon Dec 08 19:11:19 2014 +0900 @@ -57,7 +57,7 @@ return jugrix; } - private static JungleTreeEditor extendsTree(JungleTreeEditor editor, JungleTree orgTree, JungleTree roleTree, + public static JungleTreeEditor extendsTree(JungleTreeEditor editor, JungleTree orgTree, JungleTree roleTree, int count) { Random rdm = new Random(); int orgNum = rdm.nextInt(30);