Skip to content

Add SliceUtf8.toTitleCase()#177

Merged
wendigo merged 1 commit into
airlift:masterfrom
wendigo:serafin/tile-case
Jun 9, 2026
Merged

Add SliceUtf8.toTitleCase()#177
wendigo merged 1 commit into
airlift:masterfrom
wendigo:serafin/tile-case

Conversation

@wendigo

@wendigo wendigo commented Feb 10, 2025

Copy link
Copy Markdown
Contributor

this is based on the logic of the toLower and toUpper case

@wendigo

wendigo commented Mar 25, 2025

Copy link
Copy Markdown
Contributor Author

@martint @dain ptal

@wendigo

wendigo commented Apr 14, 2025

Copy link
Copy Markdown
Contributor Author

@martint PTAL

@PPL-TBSK

Copy link
Copy Markdown

@wendigo @martint any news please ?

@dain dain left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Comment thread src/main/java/io/airlift/slice/SliceUtf8.java
Comment thread src/test/java/io/airlift/slice/TestSlice.java Outdated
@wendigo wendigo force-pushed the serafin/tile-case branch from 3e1949e to d8d6530 Compare June 8, 2026 09:07
@wendigo wendigo requested a review from dain June 8, 2026 09:07
@wendigo

wendigo commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@dain I've pushed new implementation. PTAL

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7f93a8ab-e52f-4c0c-a036-ee7ce4a8b291

📥 Commits

Reviewing files that changed from the base of the PR and between a0818bd and 53d58d9.

📒 Files selected for processing (2)
  • src/main/java/io/airlift/slice/SliceUtf8.java
  • src/test/java/io/airlift/slice/TestSliceUtf8.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/io/airlift/slice/SliceUtf8.java
  • src/test/java/io/airlift/slice/TestSliceUtf8.java

📝 Walkthrough

Walkthrough

This pull request adds UTF-8 title-casing support to SliceUtf8. It introduces a TITLE_CODE_POINTS lookup table in static initialization, adds public toTitleCase methods for Slice and byte-array ranges, and implements a code-point-based transformation that title-cases the first cased code point of each whitespace-delimited word and lowercases subsequent code points. Invalid UTF-8 sequences are copied verbatim and do not reset word-start state. Output allocation is lazy; unchanged input is returned as a wrapped view. Tests validate behavior, invalid-UTF-8 handling, and no-op wrapping.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/test/java/io/airlift/slice/TestSliceUtf8.java (1)

756-775: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Consider adding test coverage for toTitleCase with invalid bytes at start and middle positions.

The assertions for toLowerCase/toUpperCase test invalid sequences at three positions: end only, start + end ("FOO"), and surrounding ("FOO" + invalid + "BAR"). However, toTitleCase only covers the end position. This matters for title-casing because the start-of-word state should persist across invalid sequences.

🧪 Suggested additional assertions
+        // invalid sequence at start followed by text should not start a new word
+        assertThat(toTitleCase(wrappedBuffer(concat(invalidSequence, new byte[] {'F', 'O', 'O'}))))
+                .isEqualTo(wrappedBuffer(concat(invalidSequence, new byte[] {'F', 'o', 'o'})));
+
+        // invalid sequence in middle should not start a new word
+        assertThat(toTitleCase(wrappedBuffer(concat(new byte[] {'F', 'O', 'O'}, invalidSequence, new byte[] {'B', 'A', 'R'}))))
+                .isEqualTo(wrappedBuffer(concat(new byte[] {'F', 'o', 'o'}, invalidSequence, new byte[] {'b', 'a', 'r'})));

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 227aa4ea-f292-45cf-a25b-5bbce119c3a5

📥 Commits

Reviewing files that changed from the base of the PR and between f72c712 and d8d6530.

📒 Files selected for processing (2)
  • src/main/java/io/airlift/slice/SliceUtf8.java
  • src/test/java/io/airlift/slice/TestSliceUtf8.java

@wendigo wendigo force-pushed the serafin/tile-case branch from d8d6530 to a0818bd Compare June 8, 2026 09:25

@dain dain left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but maybe squash to one commit

@wendigo wendigo force-pushed the serafin/tile-case branch from a0818bd to 53d58d9 Compare June 9, 2026 01:42
@wendigo wendigo merged commit 12ace0b into airlift:master Jun 9, 2026
1 check passed
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.

3 participants