Skip to content

Commit dc54c03

Browse files
committed
Refactor code formatting and improve readability across multiple files
1 parent f85bbf5 commit dc54c03

43 files changed

Lines changed: 11654 additions & 11553 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- ea
66
- develop
77
pull_request:
8-
types: [opened, synchronize, reopened]
8+
types: [ opened, synchronize, reopened ]
99
jobs:
1010
build:
1111
name: Build

.mvn/wrapper/MavenWrapperDownloader.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
import java.net.*;
1718
import java.io.*;
1819
import java.nio.channels.*;
@@ -25,7 +26,7 @@ public class MavenWrapperDownloader {
2526
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
2627
*/
2728
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28-
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29+
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
2930

3031
/**
3132
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
@@ -54,7 +55,7 @@ public static void main(String args[]) {
5455
// wrapperUrl parameter.
5556
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
5657
String url = DEFAULT_DOWNLOAD_URL;
57-
if(mavenWrapperPropertyFile.exists()) {
58+
if (mavenWrapperPropertyFile.exists()) {
5859
FileInputStream mavenWrapperPropertyFileInputStream = null;
5960
try {
6061
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
@@ -65,7 +66,7 @@ public static void main(String args[]) {
6566
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
6667
} finally {
6768
try {
68-
if(mavenWrapperPropertyFileInputStream != null) {
69+
if (mavenWrapperPropertyFileInputStream != null) {
6970
mavenWrapperPropertyFileInputStream.close();
7071
}
7172
} catch (IOException e) {
@@ -76,8 +77,8 @@ public static void main(String args[]) {
7677
System.out.println("- Downloading from: " + url);
7778

7879
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79-
if(!outputFile.getParentFile().exists()) {
80-
if(!outputFile.getParentFile().mkdirs()) {
80+
if (!outputFile.getParentFile().exists()) {
81+
if (!outputFile.getParentFile().mkdirs()) {
8182
System.out.println(
8283
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
8384
}

.travis.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ jobs:
3232
- arch: s390x
3333
jdk: openjdk7 # target release on big-endian machine
3434
install:
35-
- wget -O ibmjdk7.bin -q -T 10 -t 5 https://public.dhe.ibm.com/ibmdl/export/pub/systems/cloud/runtimes/java/7.1.4.85/linux/s390x/ibm-java-sdk-7.1-4.85-s390x-archive.bin
36-
- echo "6a901bc0b713582a323481d5b41d0c289cbd6fbb265eefb4962080240fe59ff2 ibmjdk7.bin" | sha256sum -c -
37-
- chmod +x ibmjdk7.bin
38-
- echo "INSTALLER_UI=silent" > response.properties
39-
- echo "USER_INSTALL_DIR=$PWD/ibmjdk7" >> response.properties
40-
- echo "LICENSE_ACCEPTED=TRUE" >> response.properties
41-
- ./ibmjdk7.bin -i silent -f response.properties
42-
- export PATH="$PWD/ibmjdk7/bin:$PATH"
43-
- export JAVA_HOME="$PWD/ibmjdk7"
44-
- java -version
35+
- wget -O ibmjdk7.bin -q -T 10 -t 5 https://public.dhe.ibm.com/ibmdl/export/pub/systems/cloud/runtimes/java/7.1.4.85/linux/s390x/ibm-java-sdk-7.1-4.85-s390x-archive.bin
36+
- echo "6a901bc0b713582a323481d5b41d0c289cbd6fbb265eefb4962080240fe59ff2 ibmjdk7.bin" | sha256sum -c -
37+
- chmod +x ibmjdk7.bin
38+
- echo "INSTALLER_UI=silent" > response.properties
39+
- echo "USER_INSTALL_DIR=$PWD/ibmjdk7" >> response.properties
40+
- echo "LICENSE_ACCEPTED=TRUE" >> response.properties
41+
- ./ibmjdk7.bin -i silent -f response.properties
42+
- export PATH="$PWD/ibmjdk7/bin:$PATH"
43+
- export JAVA_HOME="$PWD/ibmjdk7"
44+
- java -version
4545

4646
cache:
4747
directories:

README.adoc

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
== Zero-Allocation Hashing
2+
23
Chronicle Software
34

45
image:https://maven-badges.herokuapp.com/maven-central/net.openhft/zero-allocation-hashing/badge.svg[caption="",link=https://maven-badges.herokuapp.com/maven-central/net.openhft/zero-allocation-hashing]
@@ -12,38 +13,31 @@ toc::[]
1213

1314
== About
1415

15-
This project provides a Java API for hashing any sequence of bytes in Java, including all kinds of
16-
primitive arrays, buffers, `CharSequence` and more.
16+
This project provides a Java API for hashing any sequence of bytes in Java, including all kinds of primitive arrays, buffers, `CharSequence` and more.
1717

1818
Written for Java 7+ under Apache 2.0 license.
1919

2020
The key difference compared to other similar projects, e.g.
21-
https://guava.dev/releases/28.1-jre/api/docs/com/google/common/hash/package-summary.html[Guava hashing],
22-
is that this has no object allocation during the hash computation and does not use `ThreadLocal`.
21+
https://guava.dev/releases/28.1-jre/api/docs/com/google/common/hash/package-summary.html[Guava hashing], is that this has no object allocation during the hash computation and does not use `ThreadLocal`.
2322

2423
The implementation utilises native access where possible, but is also platform-endianness-agnostic.
25-
This provides consistent results whatever the byte order, while only moderately affecting
26-
performance.
24+
This provides consistent results whatever the byte order, while only moderately affecting performance.
25+
26+
Currently `long`-valued hash function interface is defined for 64-bit hash, and `long[]`-valued hash function interface for more than 64-bit hash, with the following implementations (in alphabetical order):
2727

28-
Currently `long`-valued hash function interface is defined for 64-bit hash, and `long[]`-valued hash
29-
function interface for more than 64-bit hash, with the following implementations (in alphabetical
30-
order):
28+
- *https://github.com/google/cityhash[CityHash], version 1.1* (latest; 1.1.1 is a C++ language-specific maintenance release).
3129

32-
- *https://github.com/google/cityhash[CityHash], version 1.1* (latest; 1.1.1 is a C++
33-
language-specific maintenance release).
30+
- Two algorithms from *https://github.com/google/farmhash[FarmHash]*: `farmhashna` (introduced in FarmHash 1.0) and `farmhashuo` (introduced in FarmHash 1.1).
3431

35-
- Two algorithms from *https://github.com/google/farmhash[FarmHash]*: `farmhashna` (introduced
36-
in FarmHash 1.0) and `farmhashuo` (introduced in FarmHash 1.1).
32+
- *https://github.com/jandrewrogers/MetroHash[MetroHash]* (using the metrohash64_2 initialization vector).
3733

38-
- *https://github.com/jandrewrogers/MetroHash[MetroHash]* (using the metrohash64_2 initialization vector).
34+
- *https://github.com/aappleby/smhasher/wiki/MurmurHash3[MurmurHash3]* 128-bit and low 64-bit.
3935

40-
- *https://github.com/aappleby/smhasher/wiki/MurmurHash3[MurmurHash3]* 128-bit and low 64-bit.
36+
- *https://github.com/wangyi-fudan/wyhash[wyHash]*, version 3.
4137

42-
- *https://github.com/wangyi-fudan/wyhash[wyHash]*, version 3.
38+
- *https://github.com/Cyan4973/xxHash[xxHash]*.
4339

44-
- *https://github.com/Cyan4973/xxHash[xxHash]*.
45-
46-
- *https://github.com/Cyan4973/xxHash[xxh3, xxh128]*, 128-bit and 64 bit.
40+
- *https://github.com/Cyan4973/xxHash[xxh3, xxh128]*, 128-bit and 64 bit.
4741

4842
These are thoroughly tested with
4943
*https://www.oracle.com/java/technologies/java-se-support-roadmap.html[LTS JDKs]*
@@ -53,6 +47,7 @@ Other non-LTS JDKs from 9 should also work, but they will not be tested from hal
5347
==== Performance
5448

5549
Tested on Intel Core i7-4870HQ CPU @ 2.50GHz
50+
5651
|===
5752
|Algorithm |Speed, GB/s |Bootstrap, ns
5853

@@ -69,43 +64,47 @@ Tested on Intel Core i7-4870HQ CPU @ 2.50GHz
6964
To sum up,
7065

7166
==== When to use Zero-Allocation Hashing
72-
* You need to hash plain byte sequences, memory blocks or "flat" objects.
73-
* You want zero-allocation and good performance (at Java scale).
74-
* You need hashing to be agile with regards to byte ordering.
67+
68+
* You need to hash plain byte sequences, memory blocks or "flat" objects.
69+
* You want zero-allocation and good performance (at Java scale).
70+
* You need hashing to be agile with regards to byte ordering.
7571

7672
==== When _not_ to use Zero-Allocation Hashing
77-
* You need to hash POJOs whose actual data is scattered in memory between managed objects.
78-
There is no simple way to hash these using this project, for example, classes such as:
73+
74+
* You need to hash POJOs whose actual data is scattered in memory between managed objects.
75+
There is no simple way to hash these using this project, for example, classes such as:
7976
+
80-
[source, Java]
77+
[source,Java]
8178
----
8279
class Person {
8380
String givenName, surName;
8481
int salary;
8582
}
8683
----
8784

88-
* You need to hash byte sequences of unknown length, for the simpliest example,
89-
`Iterator<Byte>`.
85+
* You need to hash byte sequences of unknown length, for the simpliest example,
86+
`Iterator<Byte>`.
9087

91-
* You need to transform the byte sequence (e.g. encode or decode it with a specific coding),
92-
and hash the resulting byte sequence on the way without dumping it to memory.
88+
* You need to transform the byte sequence (e.g. encode or decode it with a specific coding), and hash the resulting byte sequence on the way without dumping it to memory.
9389

9490
==== Java Doc
91+
9592
See http://javadoc.io/doc/net.openhft/zero-allocation-hashing/latest
9693

9794
== Quick start
9895

9996
Gradle:
100-
[source, groovy]
97+
98+
[source,groovy]
10199
----
102100
dependencies {
103101
implementation 'net.openhft:zero-allocation-hashing:0.16'
104102
}
105103
----
106104

107105
Or Maven:
108-
[source, xml]
106+
107+
[source,xml]
109108
----
110109
<dependency>
111110
<groupId>net.openhft</groupId>
@@ -115,13 +114,13 @@ Or Maven:
115114
----
116115

117116
In Java:
118-
[source, Java]
117+
118+
[source,Java]
119119
----
120120
long hash = LongHashFunction.wy_3().hashChars("hello");
121121
----
122122

123-
See *http://javadoc.io/doc/net.openhft/zero-allocation-hashing/0.15[JavaDocs]* for more
124-
information.
123+
See *http://javadoc.io/doc/net.openhft/zero-allocation-hashing/0.15[JavaDocs]* for more information.
125124

126125
== Contributions are most welcome!
127126

pom.xml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@
1515
~ limitations under the License.
1616
-->
1717

18-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1920

20-
<parent>
21+
<parent>
2122
<groupId>net.openhft</groupId>
2223
<artifactId>java-parent-pom</artifactId>
2324
<version>1.27ea1</version>
24-
<relativePath />
25+
<relativePath/>
2526
</parent>
2627

2728
<modelVersion>4.0.0</modelVersion>
2829
<artifactId>zero-allocation-hashing</artifactId>
2930
<version>0.27ea2-SNAPSHOT</version>
3031
<name>Zero-allocation Hashing</name>
3132
<description>Zero-allocation implementations of fast non-cryptographic hash functions
32-
for byte sequences or blocks of memory</description>
33+
for byte sequences or blocks of memory
34+
</description>
3335
<inceptionYear>2014</inceptionYear>
3436
<url>https://github.com/OpenHFT/Zero-Allocation-Hashing</url>
3537
<packaging>bundle</packaging>
@@ -237,15 +239,16 @@
237239
</executions>
238240
</plugin>
239241

240-
242+
241243
<plugin>
242244
<artifactId>maven-release-plugin</artifactId>
243245
<version>3.0.0-M4</version>
244246
<dependencies>
245247
<dependency>
246248
<groupId>org.apache.maven.scm</groupId>
247249
<artifactId>maven-scm-provider-gitexe</artifactId>
248-
<version>1.11.2</version> <!-- this version should be sync with the scmVersion of maven-release-plugin -->
250+
<version>1.11.2
251+
</version> <!-- this version should be sync with the scmVersion of maven-release-plugin -->
249252
</dependency>
250253
</dependencies>
251254
</plugin>
@@ -264,7 +267,7 @@
264267
</configuration>
265268
</plugin>
266269

267-
<plugin>
270+
<plugin>
268271
<groupId>org.apache.felix</groupId>
269272
<artifactId>maven-bundle-plugin</artifactId>
270273
<version>${maven.bundle.plugin.version}</version>
@@ -317,7 +320,7 @@
317320
<properties>
318321
<project.jdk.min-version>1.${project.target.release}</project.jdk.min-version>
319322
<maven.bundle.plugin.version>3.5.1</maven.bundle.plugin.version>
320-
<doclint />
323+
<doclint/>
321324
</properties>
322325
</profile>
323326
<profile>

src/main/java-stub/java/lang/Math.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
/**
44
* Stub for JDK internal ckass java.lang.Math.
5-
*
5+
* <p>
66
* - When crossing compiling for Java SE 7 and 8, this stub class can be used for detecting
7-
* Math#multiplyHigh() method at runtime.
7+
* Math#multiplyHigh() method at runtime.
88
* - Only used methods are exported.
99
* - In test and production runtime, the real class is loaded from boot classpath.
1010
*/
1111

1212
public class Math {
13-
public static long multiplyHigh(long x, long y) { throw new UnsupportedOperationException(); }
13+
public static long multiplyHigh(long x, long y) {
14+
throw new UnsupportedOperationException();
15+
}
1416
}

src/main/java-stub/sun/misc/Unsafe.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,29 @@
22

33
/**
44
* Stub for JDK internal ckass sun.misc.Unsafe.
5-
*
5+
* <p>
66
* - When crossing compiling for Java SE 7 and 8, this stub class can bypass compiler sun-api
7-
* warnings.
7+
* warnings.
88
* - Only used methods are exported.
99
* - In test and production runtime, the real class is loaded from boot classpath.
1010
*/
1111

1212
public final class Unsafe {
13-
public native Object getObject( Object o, long offset);
14-
public native int getInt( Object o, long offset);
13+
public native Object getObject(Object o, long offset);
14+
15+
public native int getInt(Object o, long offset);
16+
1517
public native boolean getBoolean(Object o, long offset);
16-
public native byte getByte( Object o, long offset);
17-
public native short getShort( Object o, long offset);
18-
public native char getChar( Object o, long offset);
19-
public native long getLong( Object o, long offset);
18+
19+
public native byte getByte(Object o, long offset);
20+
21+
public native short getShort(Object o, long offset);
22+
23+
public native char getChar(Object o, long offset);
24+
25+
public native long getLong(Object o, long offset);
2026

2127
public native long objectFieldOffset(java.lang.reflect.Field f);
28+
2229
public native int arrayBaseOffset(Class arrayClass);
2330
}

0 commit comments

Comments
 (0)