* Update CLAUDE.md development workflow - Fix typo in 'commit' - Add PR guidelines and common development tasks - Update native code build command to use 'make clean-native native' * Update Snappy version to 1.2.2 and fix test compatibility - Update SNAPPY_VERSION from 1.1.10 to 1.2.2 in VERSION file - Fix SnappyOutputStreamTest expected compression size for aarch64 (90277 bytes) to match improved compression ratio in Snappy 1.2.2 - All tests pass with new version Fixes #662 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Update CI to trigger tests on Makefile and VERSION changes - Add Makefile* pattern to catch all Makefile variants - Add **/VERSION pattern to catch VERSION files anywhere in repo - Ensures tests run when native build configuration or versions change 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Migrate to sonaRelease command for publishing - Remove sbt-sonatype plugin dependency - Update to sbt 1.11.3 for built-in Sonatype support - Replace sonatypePublishToBundle with direct Sonatype URLs - Add release process documentation to CLAUDE.md - Simplify publishing workflow using built-in sbt functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Update publishTo to use Central Portal URLs and localStaging - Use https://central.sonatype.com/repository/maven-snapshots/ for snapshots - Use localStaging.value for releases to support sonaRelease workflow * Revert unintended changes to keep PR focused on sonaRelease migration - Revert SNAPPY_VERSION upgrade (1.2.2 -> 1.1.10) - Revert SnappyOutputStreamTest compression ratio change - Revert native library binary update - Revert CI workflow trigger additions These changes should be in separate PRs, not part of the publishing migration. * Update release.yml to use sonaRelease command - Replace sonatypeBundleRelease with sonaRelease - Update environment variable names to standard SONATYPE_USERNAME/PASSWORD - Aligns with sbt's built-in Sonatype publishing workflow * Update snapshot.yml environment variable names - Update SONATYPE_USER to SONATYPE_USERNAME - Update SONATYPE_PASS to SONATYPE_PASSWORD - Aligns with standard naming used in sonaRelease workflow --------- Co-authored-by: Claude <noreply@anthropic.com>
4.3 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
snappy-java is a Java port of Google's Snappy compression library, providing fast compression/decompression with JNI bindings for native performance across multiple platforms.
Build Commands
Using sbt (primary build tool)
# Enter sbt console
./sbt
# Run tests
./sbt test
# Run tests matching a pattern
./sbt "testOnly *BitShuffleTest"
# Create jar file
./sbt package
# Publish to local Maven repository
./sbt publishM2
# Run tests continuously on code changes
./sbt "~test"
Using make (for native library compilation)
# Build native libraries
make
# Clean build artifacts
make clean
# Platform-specific builds (when cross-compiling)
make native-all
Architecture
Core Components
-
Java API Layer (
src/main/java/org/xerial/snappy/
)Snappy.java
: Main API facade providing high-level compression/decompression methodsSnappyNative.java
: JNI interface to native Snappy librarySnappyLoader.java
: Handles platform-specific native library loading
-
Native Layer (
src/main/java/org/xerial/snappy/
)SnappyNative.cpp
: JNI implementation bridging Java and C++ SnappyBitShuffleNative.cpp
: JNI implementation for BitShuffle algorithm
-
Stream API (
src/main/java/org/xerial/snappy/
)SnappyOutputStream
/SnappyInputStream
: Block-based compression streamsSnappyFramedOutputStream
/SnappyFramedInputStream
: Framing format implementationSnappyHadoopCompatibleOutputStream
: Hadoop-compatible format
-
Memory Management (
src/main/java/org/xerial/snappy/buffer/
and/pool/
)- Buffer allocation and pooling for efficient memory usage
- Direct ByteBuffer management for zero-copy operations
Platform Support
The project includes pre-built native libraries for multiple platforms in src/main/resources/org/xerial/snappy/native/
:
- Windows (x86, x86_64, aarch64)
- macOS (x86, x86_64, aarch64)
- Linux (x86, x86_64, aarch64, arm, armv6, armv7, ppc64, ppc64le, s390x, riscv64, loongarch64)
- AIX (ppc, ppc64)
- SunOS (x86, x86_64, sparc)
- Android (arm, aarch64)
Cross-compilation
The project uses Docker-based cross-compilation toolchains (see docker/
directory) for building native libraries across different architectures.
Testing
# Run all tests with debug logging
./sbt "testOnly * -- -l debug"
# Run specific test class
./sbt "testOnly org.xerial.snappy.SnappyTest"
# The project uses AirSpec (for Scala tests) and JUnit (for Java tests)
# Tests are located in src/test/java/org/xerial/snappy/
Important Notes
- Native Library Loading: The project automatically detects the platform and loads the appropriate native library from resources
- Memory Safety: Uses direct ByteBuffers for efficient memory operations - be aware of buffer boundaries
- Thread Safety: Snappy compression/decompression methods are thread-safe as they don't maintain state
- OSGi Support: The project includes OSGi bundle configuration in build.sbt
- Compatibility: Multiple stream formats are supported - ensure you use matching read/write formats (see compatibility matrix in README.md)
Development Workflow
Pull Request Guidelines
- Use squashed commits when merging PRs to maintain clean commit history
- Run tests before creating PR:
./sbt test
- Format code:
./sbt scalafmtAll
Release Process
The project uses sbt's built-in Sonatype integration for publishing:
# 1. Stage artifacts to Sonatype
./sbt publishSigned
# 2. Release to Maven Central
./sbt sonaRelease
Prerequisites:
- Set up Sonatype credentials in
~/.sbt/1.0/sonatype.sbt
:credentials += Credentials("Sonatype Nexus Repository Manager", "s01.oss.sonatype.org", "<username>", "<password>")
- Configure PGP signing for artifact signing
Common Development Tasks
- When making changes to native code, rebuild with
make clean-native native
- For Java/Scala changes, use
./sbt ~test
for continuous testing - Always test on multiple JDK versions if possible (8, 11, 17, 21)
Native Code Testing
- Use make clean-native native for testing native code