Add Versionstamp and Subspace support to Swift bindings #16
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Summary
This PR adds two major missing features to the Swift bindings:
These features bring the Swift bindings to parity with Python, Go, and Java bindings, enabling the development of Record Layer and other advanced FoundationDB applications in Swift.
Motivation
The Swift bindings currently lack essential features available in other language bindings, making it difficult to:
This PR addresses these gaps by implementing the missing features following the canonical behavior of official bindings.
Versionstamp Implementation
Core Features
Versionstampstruct: 12-byte value (10-byte transaction version + 2-byte user version)packWithVersionstamp(): Automatic offset calculation for atomic operationsUsage Example
Subspace Implementation
Core Features
Subspacestruct: Key namespace management with tuple encodingrange()method: Returns(prefix + [0x00], prefix + [0xFF])for tuple datastrinc()algorithm: String increment for raw binary prefixesprefixRange()method: Complete prefix coverage using strincUsage Example
Testing
Comprehensive test suite with 150 tests (all passing):
Versionstamp Tests (20)
Subspace Tests (22)
range()andprefixRange())String Increment Tests (14)
Integration
Compatibility
Cross-Language Consistency
This implementation follows the canonical behavior of official bindings:
ByteArrayUtil.strinc(),Versionstamp,Subspacefdb.strinc(),fdb.tuple.Versionstamp, tuple packingfdb.Strinc(),fdb.IncompleteVersionstamp(),Subspace.FDBRangeKeys()API Version
Files Changed
New Files
Sources/FoundationDB/Versionstamp.swift(196 lines)Sources/FoundationDB/Tuple+Versionstamp.swift(205 lines)packWithVersionstamp()methodSources/FoundationDB/Subspace.swift(424 lines)range()andprefixRange()methodsstrinc()algorithmTests/FoundationDBTests/VersionstampTests.swift(416 lines)Tests/FoundationDBTests/SubspaceTests.swift(312 lines)Tests/FoundationDBTests/StringIncrementTests.swift(194 lines)Modified Files
Sources/FoundationDB/Tuple.swift(+3 lines)Tuple.decode()switchStatistics
Breaking Changes
None. This PR is purely additive and maintains full backward compatibility with existing code.
Future Work
This PR lays the groundwork for:
Checklist
References
bindings/python/fdb/tuple.pybindings/go/src/fdb/tuple/tuple.gobindings/java/src/main/com/apple/foundationdb/tuple/Versionstamp.java