greenrobot/essentials hiện có 1.3k sao trên GitHub, viết chủ yếu bằng Java. General purpose utilities and hash functions for Android and Java (aka java-common)
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Essentials are a collection of general-purpose classes we found useful in many occasions.
Beats standard Java API performance, e.g. LongHashMap can be twice as fast as HashMap<Long, Object>.
Adds missing pieces without pulling in heavy-weights like Guava
Improved convenience: do more with less code
Super lightweight: < 100k in size
Compatible with Android and Java
This project is bare bones compared to a rich menu offered by Guava or Apache Commons. Essentials is not a framework, it's rather a small set of utilities to make Java standard approaches more convenient or more efficient.
Website | JavaDoc | Changelog
Features
Hash set and map for primitive long keys outperform the generic versions of the Java Collection APIs
Multimaps provide a map of lists or sets to simplify storing multiple values for a single key
Object cache with powerful configuration options: soft/weak/strong references, maximum size, and time-based expiration
IO utilities help with streams (byte and character based)
File utilities simplify reading and writing strings/bytes/objects from or to files. Also includes getting hashes from files and copying files.
String utilities allow efficient splitting and joining of strings, fast hex creation, and other useful string helpers.
Date utilities
Better hash functions: our Murmur3 implementation provides superior hash quality and outperforms standard Java hash functions
Specialized Streams: for example an optimized PipedOutputStream replacement (based on a circular byte buffer)
Read more on our website.
Performance
Some classes where motivated by less than optimal performance offered by standard Java.
For long keys (also works for int), Essentials provides a specialized implementation, that can be twice as fast.
Here are some (completely non-scientific) benchmarking results running on Ubuntu 20.04 LTS using OpenJDK 11.0.9:
Essentials Class
Java (seconds)
Essentials (seconds)
Speed up
LongHashSet (Dynamic)
19.756
13.079
+ 51%
LongHashSet (Prealloc)
16.480
8.171
+ 102%
LongHashMap (Dynamic)
20.311
14.659
+ 39%
LongHashMap (Prealloc)
17.496
8.677
+ 102%
PipelineStream (1024KB)
8.036
1.424
+ 564%
StringHex (vs. Guava)
6.849
3.732
+ 84%
The benchmarking sources are available in the java-essentials-performance directory.
Add the dependency to your project
For Gradle, you add this dependency (from repository mavenCentral()):
// Get all bytes from stream and close the stream safely
byte[] bytes = IoUtils.readAllBytesAndClose(inputStream);
// Read the contents of an file as a string (use readBytes to get byte[])
String contents = FileUtils.readUtf8(file);
// How many days until new year's eve?
long time2 = DateUtils.getTimeForDay(2015, 12, 31);
int daysToNewYear = DateUtils.getDayDifference(time, time2);
Our hash functions implement java.util.zip.Checksum, so this code might look familiar to you:
Murmur3A murmur = new Murmur3A();
murmur.update(bytes);
long hash = murmur.getValue();
All hashes can be calculated progressively by calling update(...) multiple times. Our Murmur3A implementation goes a step further by offering updates with primitive data in a very efficient way:
// reuse the previous instance and start over to calculate a new hash
murmur.reset();
murmur.updateLong(42L);
// Varargs and arrays are supported natively, too
murmur.updateInt(2014, 2015, 2016);
// Hash for the previous update calls. No conversion to byte[] necessary.
hash = murmur.getValue();
The utility classes are straight forward and don't have dependencies, so you should be fine to grasp them by having a look at their source code. Most of the method names should be self-explaining, and often you'll find JavaDocs where needed.
Build setup
We use Gradle as a primary build system.
Previously, Maven is used to build greenrobot-common. Inside of build-common, there are two parent POMs defined that might be useful: parent-pom and parent-pom-with-checks. The latter integrates FindBugs and Checkstyle in your build. Use it like this:
Copyright (C) 2012-2020 Markus Junginger, greenrobot (https://greenrobot.org)
EventBus binaries and source code can be used according to the Apache License, Version 2.0.
More by greenrobot
EventBus is a central publish/subscribe bus for Android with optional delivery threads, priorities, and sticky events. A great tool to decouple components (e.g. Activities, Fragments, logic components) from each other.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/greenrobot/essentials là nguồn chính thức.
greenrobot/essentials có bao nhiêu sao?
greenrobot/essentials có 1.3k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/greenrobot/essentials. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
greenrobot/essentials có phải mã nguồn mở không?
Có — greenrobot/essentials phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/greenrobot/essentials.
greenrobot/essentials còn đang phát triển không?
Commit gần nhất trên greenrobot/essentials là 5.7 năm trước (theo timestamp GitHub). Repo có 189 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
greenrobot/essentials dùng license gì?
greenrobot/essentials phát hành theo license Apache-2.0. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
greenrobot/essentials là gì?
greenrobot/essentials (greenrobot/essentials) là dự án Java trên GitHub. Theo mô tả gốc: General purpose utilities and hash functions for Android and Java (aka java-common)
greenrobot/essentials viết bằng ngôn ngữ gì?
greenrobot/essentials chủ yếu viết bằng Java. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về essentials?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về essentials.