Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6762#discussion_r34106289
  
    --- Diff: 
unsafe/src/test/java/org/apache/spark/unsafe/types/UTF8StringSuite.java ---
    @@ -88,4 +88,57 @@ public void substring() {
         Assert.assertEquals(
           UTF8String.fromString("数据砖头").substring(3, 5), 
UTF8String.fromString("头"));
       }
    +
    +  @Test
    +  public void trims() {
    +    Assert.assertEquals(
    +            UTF8String.fromString("  hello ").trim(), 
UTF8String.fromString("hello"));
    +    Assert.assertEquals(
    +            UTF8String.fromString("  hello ").trimLeft(), 
UTF8String.fromString("hello "));
    +    Assert.assertEquals(
    +            UTF8String.fromString("  hello ").trimRight(), 
UTF8String.fromString("  hello"));
    +
    +    Assert.assertEquals(
    +            UTF8String.fromString("  数据砖头 ").trim(), 
UTF8String.fromString("数据砖头"));
    +    Assert.assertEquals(
    +            UTF8String.fromString("  数据砖头 ").trimLeft(), 
UTF8String.fromString("数据砖头 "));
    +    Assert.assertEquals(
    +            UTF8String.fromString("  数据砖头 ").trimRight(), 
UTF8String.fromString("  数据砖头"));
    +
    +    Assert.assertEquals(
    +            UTF8String.fromString("数据砖头").trim(), 
UTF8String.fromString("数据砖头"));
    +    Assert.assertEquals(
    +            UTF8String.fromString("数据砖头").trimLeft(), 
UTF8String.fromString("数据砖头"));
    +    Assert.assertEquals(
    +            UTF8String.fromString("数据砖头").trimRight(), 
UTF8String.fromString("数据砖头"));
    +  }
    +
    +  @Test
    +  public void instr() {
    +    Assert.assertEquals(
    +            
UTF8String.fromString("hello").instr(UTF8String.fromString("l"), 0), 2);
    +    Assert.assertEquals(
    +            
UTF8String.fromString("hello").instr(UTF8String.fromString("l"), 3), 3);
    +    Assert.assertEquals(
    +            
UTF8String.fromString("hello").instr(UTF8String.fromString("a"), 0), -1);
    +
    +    Assert.assertEquals(
    +            UTF8String.fromString("数据ç 
–头").instr(UTF8String.fromString("据砖"), 0), 1);
    +    Assert.assertEquals(
    +            UTF8String.fromString("数据ç 
–头").instr(UTF8String.fromString("数"), 3), -1);
    +    Assert.assertEquals(
    +            UTF8String.fromString("数据ç 
–头").instr(UTF8String.fromString("数"), 0), 0);
    +    Assert.assertEquals(
    +            UTF8String.fromString("数据ç 
–头").instr(UTF8String.fromString("头"), 0), 3);
    +  }
    +
    +  @Test
    +  public void reverse() {
    +    Assert.assertEquals(
    +            UTF8String.fromString("hello").reverse(), 
UTF8String.fromString("olleh"));
    +    Assert.assertEquals(
    +            UTF8String.fromString("").reverse(), 
UTF8String.fromString(""));
    +    Assert.assertEquals(
    +            UTF8String.fromString("数据砖头").reverse(), 
UTF8String.fromString("头砖据数"));
    --- End diff --
    
    Cool idea, I will update to that once #7197 merged :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to