Skip to content

Add ByteBuffer serialization to Filter interface and implementations - #1

Draft
vprus with Copilot wants to merge 4 commits into
masterfrom
copilot/add-saveable-filter-class
Draft

Add ByteBuffer serialization to Filter interface and implementations#1
vprus with Copilot wants to merge 4 commits into
masterfrom
copilot/add-saveable-filter-class

Conversation

Copilot AI commented Jan 16, 2026

Copy link
Copy Markdown

Adds writeTo(ByteBuffer) and static readFrom(ByteBuffer) methods to enable filter persistence. Each filter writes a version byte (starting at 1) followed by its data members.

Implementation Coverage

Fully implemented (13 filters):

  • Bloom filters: Bloom, BlockedBloom, CountingBloom
  • Xor filters: Xor8, Xor16, XorBinaryFuse8/16/32, XorPlus8
  • Cuckoo filters: Cuckoo8/16, CuckooPlus8/16

Stub implementations (5 filters):

  • GolombCompressedSet - requires BitBuffer/MonotoneList serialization
  • SuccinctCounting* variants - require BitField/Select serialization

Stubs throw UnsupportedOperationException with TODO comments.

Example Usage

// Serialize
Xor8 filter = Xor8.construct(keys);
ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
filter.writeTo(buffer);

// Deserialize
buffer.flip();
Xor8 restored = Xor8.readFrom(buffer);

Implementation Details

  • Rank9 helper extended with ByteBuffer support for XorPlus8
  • Private constructors added for deserialization where needed
  • Test suite uses generic method to eliminate repetition across filter types
  • Version checking ensures compatibility on deserialization
Original prompt

Make the Filter class and all derived classes saveable. Specifically, add

  • writeTo method
  • readFrom method
    Use ByteBuffer for them.

The write methods for each specific filter should write a byte version, starting at 1, followed by all data members of the relevant class. The read method should check the version and then restore the data members.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 16, 2026 17:24
Co-authored-by: vprus <225915+vprus@users.noreply.github.com>
Co-authored-by: vprus <225915+vprus@users.noreply.github.com>
Co-authored-by: vprus <225915+vprus@users.noreply.github.com>
Copilot AI changed the title [WIP] Add saveable functionality to Filter class and subclasses Add ByteBuffer serialization to Filter interface and implementations Jan 16, 2026
Copilot AI requested a review from vprus January 16, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants