https://github.com/dajudge/buql
A Bulk Query Library
https://github.com/dajudge/buql
Last synced: 9 months ago
JSON representation
A Bulk Query Library
- Host: GitHub
- URL: https://github.com/dajudge/buql
- Owner: dajudge
- Created: 2019-08-28T17:21:42.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-30T21:20:33.000Z (over 6 years ago)
- Last Synced: 2025-03-17T05:17:03.922Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 328 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BuQL - A Bulk Query Library
Modern streaming applications often process thousands of messages per second. Classical RDMBS implementations
can easily become a bottleneck in your architecture when DB access is performed on a per-message basis.
BuQL uses a specialized SQL generation engine that can retrieve a large number of result sets in a streamlined
fashion to greatly reduce the communication overhead found in systems that hit the database once (or even
multiple times!) for each processed message.
## Compatibility
BuQL has automated tests verifying proper functionality with the following databases:
* H2
* PostgreSQL (with PostGIS extension)
* MariaDB
## Running a bulk query with BuQL (concept)
In order to simplify data retrieval, BuQL uses reflection to simplify implementation of the data access logic
you want to execute. All you need to do is provide some Java Beans for passing in query parameters / getting
out results and an interface you use to describe the queries you want to execute.
Example:
```java
// Provide a result object
public class Person {
private Long id;
private String firstName;
private String lastName;
private String street;
private String zip;
private String country;
[... getters / setters ...]
}
// Define the repository interface
@Table("person")
public interface PersonRepository {
// This is a traditional one-by-one data access method (still
// supported in BuQL)
Person findById(Long ids);
// This is a bulk data access method. The Strings in the Map types
// correlate the returned results to the query objects you passed in.
Map getById(Map ids);
// Queries can also be more complex objects. Even sophisticated
// hierarchical predicates can be formulated.
Map> findByFilter(Map ids);
}
// In your business logic:
PersonRepository repo = buql.up(PersonRepository.class);
Map ids = new HashMap<>();
ids.put("ID0", 42);
ids.put("ID1", 7);
ids.put("ID2", 10);
Map result = repo.getById(ids);
System.out.println("Hello, 42. Your name is: " + result.get("ID0").getFirstName());
```