A Powerful Tool for Data Analytics: Introduction to ClickHouse
ClickHouse is an open-source database for real-time data analytics developed by Yandex, initially used in multiple data analytics projects internally at Yandex. To introduce ClickHouse, we first need to introduce Yandex. ClickHouse’s emergence is closely related to Yandex’s business needs. Yandex is Russia’s largest search engine, with many data analytics projects. The largest of these by data volume is Yandex.Metrica, a website analytics service similar to Baidu Analytics, with data volume s...
Converting Between Uppercase and Lowercase Using Bitwise Operations
Bitwise operations are among the most fundamental and efficient operations in computer science. Today, let’s explore a classic application: converting between uppercase and lowercase letters with a single line of code. Why Use Bitwise Operations for Case Conversion?Your first reaction might be: doesn’t Java already have Character.toUpperCase() and Character.toLowerCase()? Why reinvent the wheel? Indeed, 99% of the time you should use the standard library. But understanding this trick has se...
ActiveMQ Multi-threaded Consumption - Different Approaches
Problem ScenarioIn a previous article, I introduced the basic syntax for using ActiveMQ on the client side. It is worth noting the consumer side: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 public void consume() throws JMSException { ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(); cf.setBrokerURL("tcp://localhost:61616"); Connection connection = cf.createConnection(); connection.start(...
Some Experience with Balance Deduction Under High Concurrency
Recently, I participated in optimizing an older billing system and learned some common techniques for balance deduction under high concurrency. I also tried some approaches, so I’m summarizing my findings here. Problem DescriptionFor a billing system, concurrency issues are actually divided into two categories. The first is high application concurrency—essentially a large number of users and high access volume. This type of problem is no different from general high concurrency problems and ...
Java Details: Ternary Operator and Autoboxing
Problem IntroductionI encountered an interesting problem today while scanning code with FindBugs — it’s about the ternary operator. Let me record it here. It’s about code like this: 12boolean b = true; Long a = b ? 0l : Long.valueOf(2); FindBugs gave the warning: “Boxed value is unboxed and then immediately reboxed” — meaning a boxed object is unboxed and then immediately reboxed. This problem is actually quite common. I didn’t pay much attention to it at first, and just habitually change...
Designing an Open-Source Beijing Subway Route Planner (Java Version)
OverviewI’ve been looking for an apartment recently, and I wanted to find a location that’s relatively convenient to get to several places. Checking the map manually was quite troublesome, so I decided to build a small tool for planning Beijing subway routes. This article briefly introduces the implementation process. The current functionality is relatively simple — the main method takes an input starting station and lists the routes with the minimum number of stops from all other stations to...
Redis Cluster Data Migration
In a previous article Understanding Redis Cluster Principles Through Hands-on Practice, we briefly introduced the design principles of Redis Cluster. Data in Redis Cluster is distributed across 16384 slots according to certain rules, and these slots are mapped to different nodes based on the configuration. We know that after the cluster is running stably, data can still be transferred at the slot level. However, I’ve never been entirely sure about the specific transfer process, including clus...
JStorm Source Code Analysis: The Loop Task AsyncLoopThread
OverviewAsyncLoopThread is a custom loop task execution utility in JStorm. The implementation is not complex, and on its own may not warrant a dedicated article. However, it is so widely used in JStorm — for features such as supervisor/nimbus heartbeat, fetching new topologies, updating worker status, and many more — that it’s worth introducing here, as it will also help with reading other parts of the codebase. UsageAsyncLoopThread can actually be extracted and used in your own projec...
ActiveMQ Feature - Persistence
IntroductionData persistence is a concern that many systems deal with, especially for systems like Redis and ActiveMQ where data is primarily stored in memory. Since data is stored in memory, there is a risk of data loss when the system crashes. The solution to this problem is to write data to disk through some mechanism — that is, persistence. ActiveMQ provides three persistence methods, based on JDBC, KahaDB, and LevelDB respectively. Currently, the officially recommended method is KahaDB-b...
ActiveMQ Installation and Basic Usage
InstallationDownload the latest version from the official website, extract it, and the only prerequisite is to install JDK. Starting from ActiveMQ 5.14, only JDK 8 is supported. ConfigurationThe core configuration file is activemq.xml in the conf directory. The default configuration can be used without modification. Other configuration details will be introduced in subsequent articles when discussing the various features of ActiveMQ. StartingRun activemq start in the bin directory. After star...













