{"id":21376916,"url":"https://github.com/codesqueak/inmemoryrecordstore","last_synced_at":"2025-03-16T09:44:02.192Z","repository":{"id":57718402,"uuid":"68337122","full_name":"codesqueak/InMemoryRecordStore","owner":"codesqueak","description":"A fast and storage efficient library for holding fixed length records","archived":false,"fork":false,"pushed_at":"2017-08-10T23:24:51.000Z","size":215,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-22T21:44:35.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codesqueak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-15T22:44:21.000Z","updated_at":"2016-12-28T10:10:40.000Z","dependencies_parsed_at":"2022-09-11T21:50:35.588Z","dependency_job_id":null,"html_url":"https://github.com/codesqueak/InMemoryRecordStore","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codesqueak%2FInMemoryRecordStore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codesqueak%2FInMemoryRecordStore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codesqueak%2FInMemoryRecordStore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codesqueak%2FInMemoryRecordStore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codesqueak","download_url":"https://codeload.github.com/codesqueak/InMemoryRecordStore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243852434,"owners_count":20358270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T09:18:11.330Z","updated_at":"2025-03-16T09:44:02.168Z","avatar_url":"https://github.com/codesqueak.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.codingrodent/InMemoryRecordStore/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.codingrodent/InMemoryRecordStore)\n[![Maven Central](https://img.shields.io/jenkins/s/https/jenkins.qa.ubuntu.com/precise-desktop-amd64_default.svg)](https://img.shields.io/jenkins/s/https/jenkins.qa.ubuntu.com)\n# In Memory Record Storage\n\nIn Memory Record Storage is a library to allow object data defined as records to be efficiently stored into memory.  \nEach record field may be either bit or byte aligned, with each record being in turn byte aligned.\nThe types supported are:\n\n* Boolean\n* Byte\n* Short\n* Integer\n* Long\n* Character\n* Float\n* Double\n* Void (Special case, used for packing only)\n* Array - Boolean / boolean\n* UUID\n\nTo define a record, the owning class must be annotated with a *@PackRecord* annotation.  For example,\n \n**@recordByteAligned(fieldByteAligned=true)**\n\n* fieldByteAligned - Signifies if each field is bit or byte aligned in a record in memory\n\nTo define a field in a record, the field must be annotated with a *@PackField* annotation. For example\n\n**@PackField(order = 1, bits = 9)**\n\nThis signified that a field is to be packed into 9 bits (if bit aligned) or 2 bytes (if byte aligned). Note that types can be defined to occupy less space (e.g. Integer into 9 bits)\nbut cannot be more space (e.g. Integer into 33 bits). The maximum bit size is the natural primitive type length.\n\nNote that Float and Double values ignore packing size and will be held in 32 and 64 bits respectively\n\nThe order argument of the annotation states in which order the field is to be packed.  Fields are sorted before packing.  Two fields with the same order value will cause an exception to be thrown.\n\nAn example record:\n\n```java\n@PackRecord\npublic class Record {\n    @PackField(order = 0, bits = 24)\n    public Integer a = 0x0012_3456;\n\n    @PackField(order = 7, bits = 16)\n    public int b = 0x0000_FECB;\n\n    @PackField(order = 3, bits = 16)\n    public int c = 0x0000_789A;\n\n    @PackField(order = 100, bits = 1)\n    public boolean d = true;\n\n    @Padding(order = 4, bits = 8)\n    public Void v1;\n\n    @PackField(order = 200, bits = 8)\n    public int e = 0x0000_0077;\n\n    @PackField(order = 300, bits = 16)\n    public int f = -32768;\n    \n    @PackArray(order = 0, bits = 2, elements = 10)\n    public boolean[] lotsOfBits = new boolean[100];\n}\n\n```\n\n\n# Build a Record Store\n\nThe records are held in a data structure complying with the *IMemoryStore* interface.  A basic store, *ArrayMemoryStore* is defined for default use.\n\nThe simplest way to use this is to define an empty store and let the RecordManager handle allocation.  For example the following defines storage for \nup to 1000 copies of the Record class.  Read \u0026 write operations can now be performed via the record manager which treats storage as an array of records.\n\n```java\n    RecordDescriptor descriptor = new RecordDescriptor(Record.class);\n    RecordManager rm = new RecordManager(new ArrayMemoryStore(), 1000, descriptor);\n    //\n    rm.putRecord(123, new Record())\n    Record record = (Record) rm.getRecord(123)\n```\n\n# Collections\n\nVarious collections are available.  It is intended to enlarge this list in future releases.\n\n## Array\n\nA simple array store. For example, to store up to 1000 records use:\n\n```java\n    PackedArray\u003cRecord\u003e array = new PackedArray\u003c\u003e(Record.class, 1000);\n    Record record = new Record(...); // create\n    array.putRecord(1, record); // save it\n    record = array.getRecord(i); // recover\n```\n\n## LinkedList\n\nA bidirectional linked list. For example, to create a list capable of storing up to 1000 elements use:\n\n```java\n    List\u003cRecord\u003e list = list = new PackedList\u003c\u003e(Record.class, 1000); // create\n    deque.addFirst(record1); // add some data\n    deque.addFirst(record2);\n    deque.addFirst(record3);\n    list.stream().map(...).forEach(...); // process records\n```\n\n# Array Elements\n\nLimited support exists for handling fields which are arrays. For example:\n\n```java\n@PackArray(order = 0, bits = 2, elements = 10)\npublic boolean[] lotsOfBits = new boolean[100];\n```\n\nThis allows support of a 100 element boolean array with each element packed into two bits. \nThe default packing density is one bit, allowing for maximum packing using boolean types.\n\nThe following array types are supported at present:\n\n* boolean\n* Boolean\n\nNote: The arrays size specified in the annotation is fixed.  If an array of a different size is supplied in an object, an error will result.\n\n# String\n\nSupport is included for strings.  These are held as fixed length entries up to a specified maximum. For example:\n\n```\n@PackSpring(order = 0, bits = 7, elements = 50)\npublic String message =\"Packed string\";\n```\n\nThis allows support of a string of up to 50 characters, each character packed to 7 bits. Zero length strings are allowed but nulls will result in an exception.\n\nNote: Each string has a four byte overhead which is used to hold the actual length of the stored string as opposed to its maximum (elements) length.\n\n# Restrictions\n\nThe following features are not yet available but will included when time allows:\n\n* Use of custom memory stores\n* use of custom object reader / writer\n\n# Things to add\n\n* ~~Bit record packing~~\n* ~~Float \u0026 Double~~\n* Support arrays (Partly Implementation - booleans only)\n* ~~Support fixed size strings~~\n* Collection classes (partly implemented)\n* Binary file I/O\n\n# Build\n\n(Windows)\n\n*gradlew clean build test*\n\n(Linux)\n\n*./gradlew clean build test*\n\n\n# Using Jenkins\n\nThe project includes a Jenkins file to control a pipeline build.\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodesqueak%2Finmemoryrecordstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodesqueak%2Finmemoryrecordstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodesqueak%2Finmemoryrecordstore/lists"}