Skip to main content

Bulk loading files into Sedna XML DB

The problem is to upload plenty of files into Sedna XML DB. How would you do this? If it is a repeated action, it's logical to create an application for this. This is quite easy using Sedna XML:DB Java API. Actually we've already done so but this article addresses another case. There is a problem using Java API that is the performance. Using Java API always brings overhead compared to using embedded terminal utility (I got the performance of 2 seconds per file with the remote Sedna installation). Now I have several thousands of files and I want to upload them fast so let's turn to writing some useful scripts to automate it.

Generate bulk load file
First we need to generate an xquery file with LOAD instructions that are supported by Sedna terminal utility. Let's do this with another simple script. I had to do this under both Linux and Windows systems so you'll find two scripts below.
First comes the Linux shell script:
#!/bin/sh

OUTPUT_FILE=bulk_load.xquery
COLLECTION_NAME=products

echo "" > $OUTPUT_FILE

for file in /home/ilagunov/files/* 
do
  shortname=`echo $file | sed "s/.*\///"`
  echo "LOAD \"$file\" \"$shortname\" \"$COLLECTION_NAME\"&" >> $OUTPUT_FILE
done
Here is the Windows Batch script:
@echo off

set OUTPUT_FILE=bulk_load.xquery
set COLLECTION_NAME=products
set FILES_DIRECTORY=c:\files

del %OUTPUT_FILE%

for /f %%i in ('dir /b "%FILES_DIRECTORY%"') do (
  echo LOAD "%FILES_DIRECTORY%\%%i" "%%i" "%COLLECTION_NAME%"^& >>%OUTPUT_FILE%
)
So just specify correct values to internal variables and you'll get a nice bulk_load.xquery:
LOAD "c:\files\1075.xml" "1075.xml" "products"& 
LOAD "c:\files\1076.xml" "1076.xml" "products"& 
LOAD "c:\files\1078.xml" "1078.xml" "products"& 

Execute generated file
Now locate your Sedna terminal utility se_term and execute the following command (just specify absolute paths where needed):
se_term -file bulk_load.xquery -output bulk_load.log db-name

Comments

Post a Comment

Popular posts from this blog

DynamicReports and Spring MVC integration

This is a tutorial on how to exploit DynamicReports reporting library in an existing Spring MVC based web application. It's a continuation to the previous post where DynamicReports has been chosen as the most appropriate solution to implement an export feature in a web application (for my specific use case). The complete code won't be provided here but only the essential code snippets together with usage remarks. Also I've widely used this tutorial that describes a similar problem for an alternative reporting library.
So let's turn to the implementation description and start with a short plan of this how-to:
Adding project dependencies.Implementing the Controller part of the MVC pattern.Modifying the View part of the MVC pattern.Modifying web.xml.Adding project dependencies
I used to apply Maven Project Builder throughout my Java applications, thus the dependencies will be provided in the Maven format.

Maven project pom.xml file:
net.sourceforge.dynamicreportsdynamicrepo…

Choosing Java reporting tool - part 2

I've provided a general overview of possible solutions to get a reporting/exporting functionality in the previous post. This is the second overview of alternatives based on JasperReports reporting engine.

Since the previous part I've done the following:
Implemented a simple report using both DynamicJasper and DynamicReports to compare them from technical side.Investigated JasperServer features and tried to implement a simple report for JasperServer instance (it appeared we already have a ready licensed installation of JasperServer that makes it unreasonable to install a fresh one).
First, the comparison results of Java libraries (DynamicJasper and DynamicReports):
Both libraries suffer from poor-quality or missing Java docs but they look a bit better in DynamicJasper.Taking into account the point 1, a developer has to use online documentation and to review the code. Here the code looks definitely nicer and more readable for DynamicReports. With respect t…

Do It Yourself Java Profiling

This article is a free translation of the Russian one that is a transcript of the Russian video lecture done by Roman Elizarov at the Application Developer Days 2011 conference.
The lecturer talked about profiling of Java applications without any standalone tools. Instead, it's suggested to use internal JVM features (i.e. threaddumps, java agents, bytecode manipulation) to implement profiling quickly and efficiently. Moreover, it can be applied on Production environments with minimal overhead. This concept is called DIY or "Do It Yourself". Below the lecture's text and slides begin.
Today I'm giving a lecture "Do It Yourself Java Profiling". It's based on the real life experience that was gained during more than 10 years of developing high-loaded finance applications that work with huge amounts of data, millions currency rate changes per second and thousands of online users. As a result, we have to deal with profiling. Application profiling is an i…