Recently I was invited to review a book named “Pentaho Reporting 3.5 for Java Developer”. It was great because I was planning to use Pentaho for my project and hardly found the documents on Pentaho website sufficient. As a programmer, to be honest, I don’t like user guide. I am looking for developer guide. I need to know the API, the service interfaces, the features that can be ported and used to other projects, the design, the code samples, the extension points…etc. Although Pentaho is an open-source project but it approaches its customers as a blackbox solution. Deploy the war and follow the user guide to use it. What if I want to have reporting services as part of my project. How can I use pentaho as a jar and what services it provide? What if I want to plug-in caching service in the db layer and replace the straight JDBC calls via leveraging Hibernate to do my row-based filtering. In Pentaho, all query jobs are expressed as xaction and it does provide a way to output the resultset as xml. However, it is the only thing I found it provides you. What if I want to replace the reporting UI completely and how can I access the reporting scheduling service, security service, rendering service…etc. Don’t get me wrong. Pentaho is among the best open-source solution I can find on the Net. I just want to find out if I can use it like regular Apache libraries.
With high expectation, I started reading this book. It is well-organized and written in a cookbook format. To my dismay, its focus is to help users to get familiar with the Reporting Designer UI for report definition creation. It also shows you the code that runs the report definition you created and generates the report in different formats on the Net. Not bad! There are few chapters I want to highlight:
Installation and Setup Download BI Server 3.5 stable version from http://sourceforge.net/projects/pentaho. Note: Pentaho Reporting 3.5 is included in this release. Unzip the distribution and put it to any folder you want. Inside the zip folder, there are 2 main folders: bi-server-ce and administration-console. Before you start the server, you need to enable a publish password so that you can send reports from the Report Designer application to the server. Go to bi-server-ce/pentaho-solutions/system folder and edit publisher_config.xml such as <publisher-password>password</publisher-password> Start pentaho via running ./start-pentaho.sh (Mac) under bi-server-ce. Access the BI server via web browser: http://localhost:8080/pentaho (internally, Pentaho BI Server uses Tomcat as web server). The installation is easy! Isn’t it? To complete starting up the BI Server, go into the administration-console folder and run ./start-pac.sh. This starts the administration console application hosted within Jetty web server. It is accessible by visiting http://localhost:8099 in your browser. The default username and password is admin and password. Administration console is used for managing database connections and users for Pentaho BI Server.
Installation and Setup
The code segment below was taken from this book p.342.
//Boot the reporting engine. For servlet, this will be called in the init() method. ClassEngineBoot.getInstance().start(); //Load the report prpt file. For servelt, the path could be obtained from ServletContext instead ResourceManager manager = new ResourceManager(); manager.registerDefaults(); Resource res = manager.createDirectly(new URL(”file:data/metadata_table.prpt”), MasterReport.class); MasterReport report = (MasterReport) res.getResource(); //Predefined output like PDF response.setContentType(”application/pdf”); PdfReportUtil.createPDF(report, response.getOutputStream()); ExcelReportUtil.createXLS(report, response.getOutputStream()); RTFReportUtil.createRTF(report, response.getOutputStream(); OR //Generate output from a custom output processor List<PojoOutputProcessor.PojoObject> objs = PojoUtil.createPojoReport(report); //Write the PojoObject list to System.out for (PojoOutputProcessor.PojoObject obj: objs){ System.out.println(”"+obj.x+”, “+obj.y+”: “+obj.text); }
//Boot the reporting engine. For servlet, this will be called in the init() method. ClassEngineBoot.getInstance().start();
//Load the report prpt file. For servelt, the path could be obtained from ServletContext instead ResourceManager manager = new ResourceManager(); manager.registerDefaults(); Resource res = manager.createDirectly(new URL(”file:data/metadata_table.prpt”), MasterReport.class); MasterReport report = (MasterReport) res.getResource();
//Predefined output like PDF response.setContentType(”application/pdf”); PdfReportUtil.createPDF(report, response.getOutputStream()); ExcelReportUtil.createXLS(report, response.getOutputStream()); RTFReportUtil.createRTF(report, response.getOutputStream();
OR
//Generate output from a custom output processor List<PojoOutputProcessor.PojoObject> objs = PojoUtil.createPojoReport(report);
//Write the PojoObject list to System.out for (PojoOutputProcessor.PojoObject obj: objs){ System.out.println(”"+obj.x+”, “+obj.y+”: “+obj.text); }
As I mentioned in my last article, I was getting excited about the potential of Hive. Today, I decide to start my journey to learn this. I found a great introductory video that gives you a nice warm-up of using Hive (A basic knowledge of how hadoop and mapreduce work would be helpful for you to digest the material inside).
Hive is an SQL interface built on top of Hadoop. It supports Web access and JDBC. I am amazed how close the SQL syntax like the regular SQL for RDBMS. Below are some SQLs used in this tutorial.
//———- Set up your tables in HIVE —————– SHOW TABLES; CREATE TABLE shakespeare (freq INT, word STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t’ STORED AS TEXTFILE; DESCRIBE shakespeare; //———- Load data into Hive table from Hadoop HDFS ——————- LOAD DATA INPATH “shakespeare_freq” INTO TABLE shakespeare; //———- Query against the data using hive sql interface ————– select * from shakespeare limit 10; select * from sakespeare where freq > 100 sort by freq asc limit 10; select freq, count(1) as f2 from shakespeare group by freq sort by f2 desc limit 10; //show me the plan explain select freq, count(1) as f2 from shakespeare group by freq sort by f2 desc limit 10; //———- Create a merge table and populate it using dataset joining by 2 different tables insert overwrite table merged select s.word, s.freq, k.freq from shakespeare s join kjv k on (s.word = k.word); //———- Query the merge table ——————— select word, shake_f, kjv_f, (shake_f+kjv_f) as ss from merged sort by ss limit 20;
//———- Set up your tables in HIVE —————– SHOW TABLES;
CREATE TABLE shakespeare (freq INT, word STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t’ STORED AS TEXTFILE;
DESCRIBE shakespeare;
//———- Load data into Hive table from Hadoop HDFS ——————- LOAD DATA INPATH “shakespeare_freq” INTO TABLE shakespeare;
//———- Query against the data using hive sql interface ————– select * from shakespeare limit 10; select * from sakespeare where freq > 100 sort by freq asc limit 10; select freq, count(1) as f2 from shakespeare group by freq sort by f2 desc limit 10;
//show me the plan explain select freq, count(1) as f2 from shakespeare group by freq sort by f2 desc limit 10;
//———- Create a merge table and populate it using dataset joining by 2 different tables insert overwrite table merged select s.word, s.freq, k.freq from shakespeare s join kjv k on (s.word = k.word);
//———- Query the merge table ——————— select word, shake_f, kjv_f, (shake_f+kjv_f) as ss from merged sort by ss limit 20;
To prepare the data for Hive to load in, the demo uses another mapreduce job to achieve. Remember to delete the log before doing Hive table load.
hadoop jar $HADOOP_HOME/hadoop-*-examples.jar grep input shakespeare_freq ‘\w+’ //remove the mapreduce job log hadoop fs -rmr shakespeare_freq/_logs
hadoop jar $HADOOP_HOME/hadoop-*-examples.jar grep input shakespeare_freq ‘\w+’
//remove the mapreduce job log hadoop fs -rmr shakespeare_freq/_logs
Often time, large scale data processing system always IO bound. So for mapreduce job, your mapper is always waiting for data to load from disk. Hadoop mitigates the problem via during parallel load from lots of hard drives. However, a single hard drive is still max out at 75MB/s read as physical limit and nothing we can do about this. In order to achieve good speed, the key is to eliminate # of hadoop pass
Since Hive is on top of Hadoop’s HDFS, it will have the same restrictions as it. So, you cannot do UPDATE, DELETE and INSERT records as regular RDMS. However, you can do bulk load to add more new files (data) to the table and you can do delete a file from Hive.
Hive needs to store metadata of the tables out from the HDFS. You can use regular rdms to achieve the job. But when you start Hive locally, it will seek for the local metastore. So, in distributed environment, you may need to centralize the metastore in a remote location. There is wiki on the Hive site that documents how to set it up.
Cloudera Hadoop Training: Hive Tutorial Screencast from Cloudera on Vimeo.
I ever worked for a display ad network company that collects over 400 million of impression/ click logs per day. With this amount of data, my ex-company bought a supercomputer and cross their fingers that it can handle the grow in both volume and analytic demand of the data. It is obviously not a scalable solution. However, what is the best solution?
Although I haven’t worked for this company anymore, it is still an interesting problem to solve. I have a great friend who proposed a shared nothing solution for this company. The solution is to partition the data across a set of Postgresql databases and put Greenplum on top of them to parallelize the query —there is no disk-level sharing or contention to be concerned with (i.e. it is a ’shared-nothing’ architecture). I like this approach. The only thing is that Greenplum is not free and it may be difficult for a startup to face this upfront cost. Apart from that, this setting requires all the databases are running on the same network that hindered us to move this in the elastic cloud like Amazon EC2.
Later on, I joined a great company in the same industry that seeks for a solution in the cloud to host its data warehouse. So, I got a chance to revisit this problem. During the research, I came across an interesting technology – column-based database (eg. infobright and lucid db). The idea of column-based data store is that traditional database stores and fetches data in row from data files into the memory. It is inefficient if your query only requires few columns for computation. So, column-based data stores your data in column with effective compression algorithm due to all values in it has the same data type. This solution is great but it doesn’t do MPP (ie. massive parallel processing) and it is also not ready for cloud yet.
Here comes another solution. That is Hive on top of Hadoop on top of Amazon cloud. It is an interesting idea. Check out this video to learn about this.
If you are not sure what Hadoop is and want to get some warm up in massive computing. I suggest you go through the following 5 excellent Google lectures.
I want to summarize some new and interesting Java 5 features in this article and how they change the way I code.
I use int constants to make my life easier b/c it can avoid typo. However, it has several drawbacks:
Use new enum type in Java 5:
public enum Apple {FUJI, PIPPIN, GRANNY_SMITH}
Enum is full-fledged final class that export one instance for each enumeration constant via a public static final field.
If elements of an enumerated types are used primarily in sets, it is traditional to use the int enum pattern, assigning a different power of 2 to each constant like READ = 1 << 2, WRITE = 1 <<1, EXECUTE = 1 << 0 to represent permissions per each entity in Unix. This representation lets you use the bitwise OR operation to combine several constants into a set, known as a bit field. The bit field representation also lets you perform set operations such as union and intersection efficiently using bitwise arithmetic. But bit fields have all the disadvantages of int enum mentioned above.
Now, java.util package provides the EnumSet to efficient represent sets of value drawn from single enum type. This class implements Set interface and internally use bit vector to represent set of values. For example, if you enum types has 64 values, the entire EnumSet can be represented as a single long, so its performance is comparable to the bit field.
The EnumSet class provides three benefits a normal set does not:
An annotation is a new language feature introduced in J2SE 5.0. Simply put, annotations allow developers to mark classes, methods, and members with secondary information that is not part of the operating code.You can see annotation is a way to extend Java language.
Before annotation from Java 5, you may use naming patterns to indicate that some program elements like method demanded special treatment by a tool or a framework. Like JUnit required its users to name the test methods with the pattern like testXXX(). It works but with some big disadvantages:
Annotation can solve this problem. To use it, you can:
Below are some related articles I feel useful:
Nowadays there are many tools available on the Net ranging from IM to cloud computing that certainly lowers the barrier for entrepreneurs like us. Today, I am going to list out the tools that helps me to run my company:
Recently, I am trying to build an interactive reporting tool that needs to deal with lots of data. The data is not dynamic because it is basically data from historical performance log files. However, the volume of the data is large (over few millions of rows) and I still want my clients to interact with large amount of data in ease. With this, I am looking into Adobe AIR as I heard that it comes with in-memory database “SQLite“. I believe it should have better performance than web-based application because data is local and SQLite is lightweight and fast. Apart from that, SQLite supports parameterized query, strongly-typed result, asynchronous/ synchonous processing, indexing, view, trigger, transaction and most of SQL92. On top of that, it is small footprint, cross-platform and open source. The tradeoff for SQLite is its weak support in concurrency because it is using table exclusive lock. However, it is totally fine for desktop application because it normally only serves one user. For more info of SQLite, check out my notes below.
Update
SQLite 3 is released that addressed some of its issues in version 2.
However, it still doesn’t support writeable view, nested transaction and foreign key.
Here is a nice presentation from Paul Roberson, look at it first.
Note from the video:
There are several things I want to find out:
Below are some SQLite tips and practices I obtained from different sources:
Below are some good links I have found:
ESB = Enterprise Service Bus. The definition is flexible, but in general it’s a conduit for messages of multiple, different formats, between application endpoints, over more than one protocol.
The video above can give you a good taste of Mule. But the example runs as standalone app. If you want to use Mule in your web application. I found this distributed raman amplifiervideo a good starting point.
Asynchronous messaging lets two or more applications send data to each other without having to wait for receipt confirmation. The infrastructure guarantees message delivery, even if the receiving application isn’t currently running or the network connection is interrupted. It sounds simple enough, but asynchronous messaging demands a new way of thinking about system architecture.
There are some interesting tips I found during the time I work on Flex Programming. I will cover Embedding, Binding, Event Handling, Function Pointer, Mixin and more. I hope these tips will make your life easier when you work on Flex.
Read the rest of this entry »
To make Flex datagrid completed, I would like to have the following featues. AutoCompleted Search – Locate the data I want quickly if there are too many rows in my grid. Internationalization – Handle currency, number and date format. Data Export – Output the data in csv format, so users can import to Excel. Pagination - If I give the total number of records, the subset of the data rows and the number of rows per page, the grid should be able to do pagination and fire the events when user clicks on other pages. This article I will show you how to make these happen. Read the rest of this entry »
In our daily life, we deal with lots of data. The data normally is stored in text format for the ease of human to read. With the large amount of data we have, we need ways to deal with it. There are several things we frequently do on the data: Search, Filter, Sort and Analysis. In Linux, there are some powerful commands that I can use: cat, grep, find, sort, unique and etc. I found those commands quite powerful. So, I decide to put these down as my reference. This tutorial I will go over the basic text processing commands and how we use them together to achieve the tasks we often encounter in our workplace.