Tourism Data Analysis
Two questions about hotels
What does a hotel cost on average in each city, and which words do reviewers reach for most often? To answer both at once I built, in 2024, a batch pipeline in Java over hotel listings and their reviews, as a data-engineering coursework study. It collects pages with Jsoup, cleans them into structured records, stores them in HBase, aggregates them with MapReduce, and hands the results to ECharts and a word cloud.
The code is kept in the repository under the MIT license as a record of that Hadoop 2.7 and HBase 1.3 stack. No scraped data is committed.
Stages that meet only in storage
The pipeline runs in five stages: collection, cleaning, storage, analysis and presentation. Each lives in its own package, and the packages carry letter prefixes so that the directory listing reads in execution order.
No stage calls the next. Each one leaves its output in HBase or in a file, and the following stage picks it up from there. That hand-off is what makes the stages independent of one another: collection can run overnight, cleaning can be repeated against whatever was collected, and the analysis can run as often as I like without touching the network again.
Collection fetches a commercial travel platform's pages, and raw HTML never travels further than the parser. Each page is parsed once and reduced to three flat records: one for the city, one for the hotel listing, and one for each review. From there on, every stage works with named, typed fields rather than with a document, so a change in the source markup moves the parser and nothing else.
A row key shaped by the query
HBase sorts its rows lexicographically and offers no secondary index, which leaves the row key as the only access path a query gets for free. The hotel table therefore keys each hotel by its city id followed by its hotel id. Every question this pipeline asks is a per-city question, and with the city first, “every hotel in this city” becomes a contiguous range scan instead of a filter over the whole table. The key follows the query, not the record.
The columns split along the same line into a city family and a hotel family. City fields are written once and read on every scan; hotel fields are the wide part and change on their own schedule. Kept apart, a scan reads only the family it needs.
Every value, price and score included, is stored as a UTF-8 string. Each cell stays readable straight from the HBase shell, and type conversion happens in exactly one place, the mapper, where the aggregation happens anyway.
Two questions as MapReduce jobs
The average-price job has the simpler shape. Its mapper scans the hotel table, keys each price on the city id, and passes it on; the reducer averages. This is the job the row key was designed for, and it reads the table in the order the key already sorts it.
The word-frequency job reads each review's text from HBase, strips the emoji, segments the Chinese text with a dictionary-based segmenter, and emits every word with a count of one for the reducer to sum. Chinese writes no spaces between words, so segmentation is the real difficulty of the job. The emoji go first because review text is full of them, and left in, they would turn into spurious tokens.
The same count without Hadoop
The local version repeats that computation step for step as an ordinary loop, with the frameworks taken away.
The MapReduce version is the one built to carry a corpus of the size a cluster exists for. Its map step works on one review at a time and shares nothing, so the work spreads across as many nodes as there are region servers, and the reducer only ever sees the counts of a single word. On the reviews this project collected, the loop finishes before Hadoop has finished starting.
Holding both makes the cost of distribution visible rather than assumed, and that is the thing most worth knowing about a stack like this one.
What the pipeline draws
The presentation stage reads both results back out of HBase. Word frequencies become a word cloud masked by a silhouette, and the price aggregates become ECharts series on a single page. Nothing on that page is assembled by hand; the pipeline produces it from the collected listings, which here cover hotels in Hong Kong and Macau.