greenrobot / essentials Goto Github PK
View Code? Open in Web Editor NEWGeneral purpose utilities and hash functions for Android and Java (aka java-common)
License: Apache License 2.0
General purpose utilities and hash functions for Android and Java (aka java-common)
License: Apache License 2.0
Like #8, but to run on Android
Why not use LinkedHashMap for the key to preserve order when iterating through the map ?
Or provide a LinkedListMultimap class like
public class LinkedListMultimap<K, V> extends AbstractMultimap<K, V, List<V>> {
public static <K, V> LinkedListMultimap<K, V> create() {
return new LinkedListMultimap<>(new LinkedHashMap<K, List<V>>());
}
protected LinkedListMultimap(LinkedHashMap<K, List<V>> map) {
super(map);
}
@Override protected List<V> createNewCollection() {
return new ArrayList<>();
}
}
I'd be happy to make a PR with this as I'm using this in my own project with great success
I want to extend its functionality (like, direct access to Buffers without copying byte arrays twice), but its fields are private. This forces me to make a copy of the class just to add a few new methods instead of being able to extend it. Can you please change this?
Trying to use Murmur implementation from this library, and got the error for:
Murmur3A murmur = new Murmur3A();
murmur.updateUtf8("My test string");
error: cannot find symbol method updateUtf8(String)
Tried with both versions: org.greenrobot:essentials:3.0.0-RC1
and de.greenrobot:java-common:2.3.1
Most of the link in README.md section is broken. Like: stream-based IO
Your website says:
For more details, please have a look at the documentation.
But I can't find a visible documentation link anywhere.
JDK 11
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.greenrobot.essentials.PrimitiveArrayUtils$UnsafeImpl (file:/<REDACTED>/essentials-3.0.0-RC1.jar) to method java.nio.Bits.unaligned()
WARNING: Please consider reporting this to the maintainers of org.greenrobot.essentials.PrimitiveArrayUtils$UnsafeImpl
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
I might not be using the api correctly, but we're getting collisons for the following case:
var m1 = new Murmur3F();
m1.update(0);
m1.update(-17664);
var m2 = new Murmur3F();
m2.update(0);
m2.update(-16640);
assert !Objects.equals(new UUID(m1.getValueHigh(), m1.getValue()), new UUID(m2.getValueHigh(), m2.getValue()));
Do we need a finalize or something?
Not sure if those Android projects should be Gradle or Maven. On the plus side of Maven would be that base project is Maven. Also, Android Studio has trouble mixing Android with Java projects (see EventBus and greenDAO).
Create another sub project to check performance of...
Reference platform: Java 8
Building with proguard enabled would result in this error:
PrimitiveArrayUtils$UnsafeImpl: can't find referenced class sun.misc.Unsafe
adding the follow to my proguard configs seemed to help:
-dontwarn sun.misc.Unsafe
What steps will reproduce the problem?
Please provide any additional information below:
Below is the current constructor for when a seed is supplied.
public Murmur3F(int seed)
{
this.seed = seed & (0xffffffffL); // unsigned
h1 = seed;
h2 = seed;
}
Here is the code from the reference implementation:
void MurmurHash3_x64_128 ( const void * key, const int len,
const uint32_t seed, void * out )
{
const uint8_t * data = (const uint8_t*)key;
const int nblocks = len / 16;
uint64_t h1 = seed;
uint64_t h2 = seed;
Note that h1 and h2 are unsigned 64-bit integers. Because they are unsigned, they will not inherit the sign of the supplied seed. However, in the corresponding java code, h1 and h2 will become negative if the seed is negative (e.g. a value greater than Integer.MAX_VALUE).
A minor modification to the constructor resolves the issue, and makes the output congruent with the reference implementation for negative seed values:
public Murmur3F(int seed)
{
this.seed = seed & (0xffffffffL); // unsigned
h1 = this.seed;
h2 = this.seed;
}
Question: What is the required minimum java version of the project?
Officially, unofficially? It's easy enough to test, but is there a decision regarding this? Looking into using it in an embedded environment where some hardware still only has java 1.5. Looks like the collections, dates, files etc can manage with only 1.5. At least not any 1.7. sun.misc.Unsafe might be an issue but isolated use of that.
Currently ObjectCache depends on the system time never changing, which is not optimal in a setup where the app runs for a long time, the user or the system might change the time.
a solution would be not to use the time but the uptime of the phone.
https://developer.android.com/reference/android/os/SystemClock#uptimeMillis()
I post EventBus.getDefault().post(new SendPlayer(player));
from a services, which is running in non main thread
<service
android:name=".player.PlayerService"
android:process=":player"
android:enabled="true"
android:exported="true">
</service>
I expect to recieve even in my fragment
@Subscribe(threadMode = ThreadMode.MAIN) public void onEvent(SendPlayer event) {
Log.w("mcheck", "onEvent");
}
However, i get message D/EventBus: No subscribers registered for event class yarh.com.tryexo.player.SendPlayer
. Events are delivered only if i remove android:process=":player"
.
Is it a bug or I misunderstud flow of posting events between bachground thread and main thread?
Test file size: 1.09GB
Here is the code:
try {
Log.d(TAG, "SHA1");
Log.d(TAG, FileUtils.getSha1(file));
} catch (IOException e) {
e.printStackTrace();
}
try {
Murmur3F checksum = new Murmur3F(123);
Log.d(TAG, "murmur");
FileUtils.updateChecksum(file, checksum);
Log.d(TAG, "" + checksum.getValueHexString());
} catch (IOException e) {
e.printStackTrace();
}
Here is the result:
09-20 18:18:53.021 D/HashTest: SHA1
09-20 18:19:12.721 D/HashTest: a21321f03c0463927f51f2febaf2ea1e66acff21
09-20 18:19:12.731 D/HashTest: murmur
09-20 18:19:47.951 D/HashTest: 6e838ff35a6d624310df1607cc5892f6
SHA1: ~20s
MurmurHash: ~40s
Is this result reasonable?
I experienced Random to have significant impact on performance. Please pull the usage of Random out into some set up step, which is not measured. Affects some tests.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.