• This repository has been archived on 17/Aug/2023
  • Stars
    star
    286
  • Rank 144,690 (Top 3 %)
  • Language
    Java
  • License
    Other
  • Created over 11 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Java Language support

JavaLang


This project has been superceded by Chronicle-Core and Chronicle-Bytes project. Please consider migration!


This module provides marshalling, de-marshalling and handling of thread safe off heap memory through ByteBuffers.

This module is available on maven central as

<dependency>
    <groupId>net.openhft</groupId>
    <artifactId>lang</artifactId>
    <version><!--replace with the latest version--></version>
</dependency>

The version 6.x signifies that it is build for Java 6+. (It requires Java 6 update 18 or later to build)

JavaDoc

Check out our documentation at [JavaDoc] (http://openhft.github.io/Java-Lang/apidocs/)

Working with off heap objects.

Java-Lang 6.1 adds support for basic off heap data structures. More collections types and more complex data types will be added in future versions.

public interface DataType {
     // add getters and setters here
}

// can create an array of any size (provided you have the memory) off heap.
HugeArray<DataType> array = HugeCollections.newArray(DataType.class, 10*1000*1000*1000L);
DataType dt = array.get(1111111111);

// set data on dt
array.recycle(dt); // recycle the reference (or discard it)

// create a ring writeBuffer
HugeQueue<DataType> queue = HugeCollections.newQueue(DataType.class, 10*1000*1000L);
// give me a reference to an object to populate
DataType dt2 = queue.offer();
// set the values od dt2
queue.recycle(dt2);

DataType dt3 = queue.take();
// get values
queue.recycle(dt3);

This is designed to be largely GC-less and you can queue millions of entries with 32 MB heap and not trigger GCs.

Working with buffers

To work with buffers there is a several options:

Both classes provide functionality:

  • write\read operations for primitives (writeLong(long n), readLong() etc.)
  • locking in native memory, so you can add thread safe constructs to your native record.
  • CAS operations for int and long boolean compareAndSwapInt(long offset, int expected, int x), boolean compareAndSwapLong(long offset, long expected, long x)
  • addAndGetInt and getAndAddInt operations

Example

ByteBuffer byteBuffer = ByteBuffer.allocate(SIZE);
ByteBufferBytes bytes = new ByteBufferBytes(byteBuffer);
for (long i = 0; i < bytes.maximumLimit(); i++)
    bytes.writeLong(i);
for (long i = bytes.maximumLimit()-8; i >= 0; i -= 8) {
    int j = bytes.readLong(i);
    assert i ==  j;
}

Building for eclipse

Download Java-Lang zip from git https://github.com/OpenHFT/Java-Lang/archive/master.zip

Unzip master.zip, Java-Lang-master folder will be extracted from zip.

cd Java-Lang-master
mvn eclipse:eclipse

Now you have an eclipse project, import project into Eclipse

If your Eclipse configuration is not UTF-8, after importing the project you may see some errors and strange characters in some .java files. To get rid of this problem change character enconding to UTF-8: project->properties->resource->text file encoding->utf8

More Repositories

1

Chronicle-Queue

Micro second messaging that stores everything to disk
Java
3,130
star
2

Chronicle-Map

Replicate your Key Value Store across your network, with consistency, persistance and performance.
Java
2,669
star
3

Java-Thread-Affinity

Bind a java thread to a given core
Java
1,724
star
4

Zero-Allocation-Hashing

Zero-allocation hashing for Java
Java
762
star
5

Java-Runtime-Compiler

Java Runtime Compiler
Java
617
star
6

OpenHFT

Parent module to include active modules
Shell
609
star
7

Chronicle-Core

Low level access to native memory, JVM and OS.
Java
528
star
8

Chronicle-Wire

A Low Garbage Java Serialisation Library that supports multiple formats
Java
464
star
9

Chronicle-Bytes

Chronicle Bytes has a similar purpose to Java NIO's ByteBuffer with many extensions
Java
382
star
10

Chronicle-Engine

A high performance, low latency, reactive processing framework
338
star
11

Chronicle-Network

A High Performance Network ( TCP/IP ) Library
Java
243
star
12

Chronicle-Logger

A sub microsecond java logger, supporting standard logging APIs such as Slf & Log4J
Java
220
star
13

Chronicle-Threads

Java
167
star
14

Chronicle-Values

Java
102
star
15

Chronicle-Algorithms

Java
77
star
16

JLBH

JLBH
Java
68
star
17

Chronicle-Queue-Demo

Sample programs for Chronicle Queue
Java
65
star
18

Chronicle-Accelerate

HFT meets Blockchain in Java platform
Java
59
star
19

Chronicle-TimeSeries

Multi-Threaded Time Series library
Java
59
star
20

Chronicle-Decentred

Framework for building Secure Scalable Microservices on Distributed Ledger Technology
Java
50
star
21

Chronicle-Salt

Chronicle wrapper for the NaCl library
Java
30
star
22

Chronicle-Test-Framework

Java
24
star
23

Chronicle-Ticker

A time ticker as a light weight clock
Java
23
star
24

RFC

RFC's used by OpenHFT
21
star
25

Chronicle-Websocket-Jetty

Provide Websocket access via Jetty
Java
17
star
26

Puzzles

OpenHFT Puzzles
Java
15
star
27

jvm-micro-benchmarks

Microbenchmarks for JVM code.
Java
14
star
28

Spoon

Java
11
star
29

Chronicle-Engine-GUI

CSS
11
star
30

Exception-Handler

Open a browser with a message about an Exception.
Java
10
star
31

Stage-Compiler

Java
8
star
32

Binary-Compatibility-Enforcer-Plugin

Wraps the Java API ComplianceChecker into a maven plugin
Java
7
star
33

Chronicle-Common

Java
6
star
34

Chronicle-Coder

Encode and decode data as symbols and readable words
Java
5
star
35

Posix

Java
5
star
36

Microservice-Benchmark

Open Microservices Benchmark
Java
5
star
37

Chronicle-Analytics

Support for Analytics
Java
4
star