@Test public void testSTAXShredder() throws Exception { XMLShredder.main(XML, PATHS.PATH2.getFile().getAbsolutePath()); final INodeWriteTrx expectedTrx = holder.getNWtx(); NodeElementTestHelper.createDocumentRootNode(expectedTrx); final IStorage database2 = CoreTestHelper.getStorage(PATHS.PATH2.getFile()); final ISession session = database2.getSession(new SessionConfiguration("shredded", StandardSettings.KEY)); final INodeReadTrx rtx = new NodeReadTrx(session.beginBucketRtx(session.getMostRecentVersion())); rtx.moveTo(ROOT_NODE); final Iterator<Long> expectedDescendants = new DescendantAxis(expectedTrx); final Iterator<Long> descendants = new DescendantAxis(rtx); while (expectedDescendants.hasNext() && descendants.hasNext()) { final ITreeStructData expDesc = ((ITreeStructData)expectedTrx.getNode()); final ITreeStructData desc = ((ITreeStructData)rtx.getNode()); AssertJUnit.assertEquals(expDesc.getDataKey(), desc.getDataKey()); AssertJUnit.assertEquals(expDesc.getParentKey(), desc.getParentKey()); AssertJUnit.assertEquals(expDesc.getFirstChildKey(), desc.getFirstChildKey()); AssertJUnit.assertEquals(expDesc.getLeftSiblingKey(), desc.getLeftSiblingKey()); AssertJUnit.assertEquals(expDesc.getRightSiblingKey(), desc.getRightSiblingKey()); AssertJUnit.assertEquals(expDesc.getChildCount(), desc.getChildCount()); if (expDesc.getKind() == IConstants.ELEMENT || desc.getKind() == IConstants.ELEMENT) { AssertJUnit.assertEquals(((ElementNode)expDesc).getAttributeCount(), ((ElementNode)desc) .getAttributeCount()); AssertJUnit.assertEquals(((ElementNode)expDesc).getNamespaceCount(), ((ElementNode)desc) .getNamespaceCount()); } AssertJUnit.assertEquals(expDesc.getKind(), desc.getKind()); AssertJUnit.assertEquals(expectedTrx.getQNameOfCurrentNode(), rtx.getQNameOfCurrentNode()); AssertJUnit .assertEquals(expectedTrx.getValueOfCurrentNode(), expectedTrx.getValueOfCurrentNode()); } rtx.close(); session.close(); }
public static void main(final String... paramArgs) throws Exception { checkArgument(paramArgs.length == 2, "Usage: XMLShredder input.xml output.tnk"); System.out.print("Shredding '" + paramArgs[0] + "' to '" + paramArgs[1] + "' ... "); final long time = System.currentTimeMillis(); Injector injector = Guice.createInjector(new ModuleSetter().setDataFacClass(TreeNodeFactory.class).setMetaFacClass( NodeMetaPageFactory.class).createModule()); IBackendFactory storage = injector.getInstance(IBackendFactory.class); IRevisioning revision = injector.getInstance(IRevisioning.class); final File target = new File(paramArgs[1]); final StorageConfiguration config = new StorageConfiguration(target); Storage.truncateStorage(config); Storage.createStorage(config); final IStorage db = Storage.openStorage(target); Properties props = StandardSettings.getProps(target.getAbsolutePath(), "shredded"); db.createResource(new ResourceConfiguration(props, storage, revision, new TreeNodeFactory(), new NodeMetaPageFactory())); final ISession session = db.getSession(new SessionConfiguration("shredded", StandardSettings.KEY)); final INodeWriteTrx wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); final NodeDelegate nodeDel = new NodeDelegate(wtx.getPageWtx().incrementDataKey(), NULL_NODE, 0); DocumentRootNode node = new DocumentRootNode(nodeDel, new StructNodeDelegate(nodeDel, NULL_NODE, NULL_NODE, NULL_NODE, 0)); wtx.getPageWtx().setData(node); wtx.moveTo(org.treetank.data.IConstants.ROOT_NODE); final XMLEventReader reader = createFileReader(new File(paramArgs[0])); final XMLShredder shredder = new XMLShredder(wtx, reader, EShredderInsert.ADDASFIRSTCHILD); shredder.call(); wtx.close(); session.close(); System.out.println(" done [" + (System.currentTimeMillis() - time) + "ms]."); }
XMLShredder implements Callable<Void> { public static void main(final String... paramArgs) throws Exception { checkArgument(paramArgs.length == 2, "Usage: XMLShredder input.xml output.tnk"); System.out.print("Shredding '" + paramArgs[0] + "' to '" + paramArgs[1] + "' ... "); final long time = System.currentTimeMillis(); Injector injector = Guice.createInjector(new ModuleSetter().setDataFacClass(TreeNodeFactory.class).setMetaFacClass( NodeMetaPageFactory.class).createModule()); IBackendFactory storage = injector.getInstance(IBackendFactory.class); IRevisioning revision = injector.getInstance(IRevisioning.class); final File target = new File(paramArgs[1]); final StorageConfiguration config = new StorageConfiguration(target); Storage.truncateStorage(config); Storage.createStorage(config); final IStorage db = Storage.openStorage(target); Properties props = StandardSettings.getProps(target.getAbsolutePath(), "shredded"); db.createResource(new ResourceConfiguration(props, storage, revision, new TreeNodeFactory(), new NodeMetaPageFactory())); final ISession session = db.getSession(new SessionConfiguration("shredded", StandardSettings.KEY)); final INodeWriteTrx wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); final NodeDelegate nodeDel = new NodeDelegate(wtx.getPageWtx().incrementDataKey(), NULL_NODE, 0); DocumentRootNode node = new DocumentRootNode(nodeDel, new StructNodeDelegate(nodeDel, NULL_NODE, NULL_NODE, NULL_NODE, 0)); wtx.getPageWtx().setData(node); wtx.moveTo(org.treetank.data.IConstants.ROOT_NODE); final XMLEventReader reader = createFileReader(new File(paramArgs[0])); final XMLShredder shredder = new XMLShredder(wtx, reader, EShredderInsert.ADDASFIRSTCHILD); shredder.call(); wtx.close(); session.close(); System.out.println(" done [" + (System.currentTimeMillis() - time) + "ms]."); } }
XMLShredder implements Callable<Void> { public static void main(final String... paramArgs) throws Exception { checkArgument(paramArgs.length == 2, "Usage: XMLShredder input.xml output.tnk"); System.out.print("Shredding '" + paramArgs[0] + "' to '" + paramArgs[1] + "' ... "); final long time = System.currentTimeMillis(); Injector injector = Guice.createInjector(new ModuleSetter().setDataFacClass(TreeNodeFactory.class).setMetaFacClass( NodeMetaPageFactory.class).createModule()); IBackendFactory storage = injector.getInstance(IBackendFactory.class); IRevisioning revision = injector.getInstance(IRevisioning.class); final File target = new File(paramArgs[1]); final StorageConfiguration config = new StorageConfiguration(target); Storage.truncateStorage(config); Storage.createStorage(config); final IStorage db = Storage.openStorage(target); Properties props = StandardSettings.getProps(target.getAbsolutePath(), "shredded"); db.createResource(new ResourceConfiguration(props, storage, revision, new TreeNodeFactory(), new NodeMetaPageFactory())); final ISession session = db.getSession(new SessionConfiguration("shredded", StandardSettings.KEY)); final INodeWriteTrx wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); final NodeDelegate nodeDel = new NodeDelegate(wtx.getPageWtx().incrementDataKey(), NULL_NODE, 0); DocumentRootNode node = new DocumentRootNode(nodeDel, new StructNodeDelegate(nodeDel, NULL_NODE, NULL_NODE, NULL_NODE, 0)); wtx.getPageWtx().setData(node); wtx.moveTo(org.treetank.data.IConstants.ROOT_NODE); final XMLEventReader reader = createFileReader(new File(paramArgs[0])); final XMLShredder shredder = new XMLShredder(wtx, reader, EShredderInsert.ADDASFIRSTCHILD); shredder.call(); wtx.close(); session.close(); System.out.println(" done [" + (System.currentTimeMillis() - time) + "ms]."); } XMLShredder(final INodeWriteTrx paramWtx, final XMLEventReader paramReader,
        final EShredderInsert paramAddAsFirstChild);  XMLShredder(final INodeWriteTrx paramWtx, final XMLEventReader paramReader,
        final EShredderInsert paramAddAsFirstChild, final EShredderCommit paramCommit); }
XMLShredder implements Callable<Void> { public static void main(final String... paramArgs) throws Exception { checkArgument(paramArgs.length == 2, "Usage: XMLShredder input.xml output.tnk"); System.out.print("Shredding '" + paramArgs[0] + "' to '" + paramArgs[1] + "' ... "); final long time = System.currentTimeMillis(); Injector injector = Guice.createInjector(new ModuleSetter().setDataFacClass(TreeNodeFactory.class).setMetaFacClass( NodeMetaPageFactory.class).createModule()); IBackendFactory storage = injector.getInstance(IBackendFactory.class); IRevisioning revision = injector.getInstance(IRevisioning.class); final File target = new File(paramArgs[1]); final StorageConfiguration config = new StorageConfiguration(target); Storage.truncateStorage(config); Storage.createStorage(config); final IStorage db = Storage.openStorage(target); Properties props = StandardSettings.getProps(target.getAbsolutePath(), "shredded"); db.createResource(new ResourceConfiguration(props, storage, revision, new TreeNodeFactory(), new NodeMetaPageFactory())); final ISession session = db.getSession(new SessionConfiguration("shredded", StandardSettings.KEY)); final INodeWriteTrx wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); final NodeDelegate nodeDel = new NodeDelegate(wtx.getPageWtx().incrementDataKey(), NULL_NODE, 0); DocumentRootNode node = new DocumentRootNode(nodeDel, new StructNodeDelegate(nodeDel, NULL_NODE, NULL_NODE, NULL_NODE, 0)); wtx.getPageWtx().setData(node); wtx.moveTo(org.treetank.data.IConstants.ROOT_NODE); final XMLEventReader reader = createFileReader(new File(paramArgs[0])); final XMLShredder shredder = new XMLShredder(wtx, reader, EShredderInsert.ADDASFIRSTCHILD); shredder.call(); wtx.close(); session.close(); System.out.println(" done [" + (System.currentTimeMillis() - time) + "ms]."); } XMLShredder(final INodeWriteTrx paramWtx, final XMLEventReader paramReader,
        final EShredderInsert paramAddAsFirstChild);  XMLShredder(final INodeWriteTrx paramWtx, final XMLEventReader paramReader,
        final EShredderInsert paramAddAsFirstChild, final EShredderCommit paramCommit); @Override Void call(); static void main(final String... paramArgs); static synchronized XMLEventReader createFileReader(final File paramFile); static synchronized XMLEventReader createStringReader(final String paramString); static synchronized XMLEventReader createListReader(final List<XMLEvent> paramEvents); final CountDownLatch getLatch(); }
XMLShredder implements Callable<Void> { public static void main(final String... paramArgs) throws Exception { checkArgument(paramArgs.length == 2, "Usage: XMLShredder input.xml output.tnk"); System.out.print("Shredding '" + paramArgs[0] + "' to '" + paramArgs[1] + "' ... "); final long time = System.currentTimeMillis(); Injector injector = Guice.createInjector(new ModuleSetter().setDataFacClass(TreeNodeFactory.class).setMetaFacClass( NodeMetaPageFactory.class).createModule()); IBackendFactory storage = injector.getInstance(IBackendFactory.class); IRevisioning revision = injector.getInstance(IRevisioning.class); final File target = new File(paramArgs[1]); final StorageConfiguration config = new StorageConfiguration(target); Storage.truncateStorage(config); Storage.createStorage(config); final IStorage db = Storage.openStorage(target); Properties props = StandardSettings.getProps(target.getAbsolutePath(), "shredded"); db.createResource(new ResourceConfiguration(props, storage, revision, new TreeNodeFactory(), new NodeMetaPageFactory())); final ISession session = db.getSession(new SessionConfiguration("shredded", StandardSettings.KEY)); final INodeWriteTrx wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); final NodeDelegate nodeDel = new NodeDelegate(wtx.getPageWtx().incrementDataKey(), NULL_NODE, 0); DocumentRootNode node = new DocumentRootNode(nodeDel, new StructNodeDelegate(nodeDel, NULL_NODE, NULL_NODE, NULL_NODE, 0)); wtx.getPageWtx().setData(node); wtx.moveTo(org.treetank.data.IConstants.ROOT_NODE); final XMLEventReader reader = createFileReader(new File(paramArgs[0])); final XMLShredder shredder = new XMLShredder(wtx, reader, EShredderInsert.ADDASFIRSTCHILD); shredder.call(); wtx.close(); session.close(); System.out.println(" done [" + (System.currentTimeMillis() - time) + "ms]."); } XMLShredder(final INodeWriteTrx paramWtx, final XMLEventReader paramReader,
        final EShredderInsert paramAddAsFirstChild);  XMLShredder(final INodeWriteTrx paramWtx, final XMLEventReader paramReader,
        final EShredderInsert paramAddAsFirstChild, final EShredderCommit paramCommit); @Override Void call(); static void main(final String... paramArgs); static synchronized XMLEventReader createFileReader(final File paramFile); static synchronized XMLEventReader createStringReader(final String paramString); static synchronized XMLEventReader createListReader(final List<XMLEvent> paramEvents); final CountDownLatch getLatch();  }