[ 
https://issues.apache.org/jira/browse/BEAM-9331?focusedWorklogId=390462&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-390462
 ]

ASF GitHub Bot logged work on BEAM-9331:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Feb/20 06:56
            Start Date: 21/Feb/20 06:56
    Worklog Time Spent: 10m 
      Work Description: alexvanboxel commented on pull request #10883: 
[BEAM-9331] Add better Row builders
URL: https://github.com/apache/beam/pull/10883#discussion_r382422957
 
 

 ##########
 File path: sdks/java/core/src/test/java/org/apache/beam/sdk/values/RowTest.java
 ##########
 @@ -477,6 +477,172 @@ public void testCreateMapWithRowValue() {
     assertEquals(data, row.getMap("map"));
   }
 
+  @Test
 
 Review comment:
   Elaborating on the above comment:
   
   `getValues` is currently not safe (it makes the Row mutable), if the meaning 
changes that it returns the logical type the implementation will need to make a 
copy of the content as it needs to translate the basetype to the logicaltype. 
As it's a copy the Row is immutable again. See this for test:
   
   ```  
     @Test
     public void testImmutability() {
       Schema schema = 
Schema.builder().addInt32Field("a").addInt32Field("b").build();
       Row row1 = Row.withSchema(schema).addValue(1).addValue(2).build();
       List<Object> values = row1.getValues();
       values.set(1, 3);
       assertEquals(2,(int)row1.getValue(1));
     }
   ```
   Then the question is left for `attach` or `detach`: if you make values an 
immutable array it can be returned with `detach`, as it's immutable that's 
safe. The `attach` needs then make a copy of the array to an immutable array 
(or check if it's immutable) and `build` needs to make the immutable array as 
well.
   
   - 
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 390462)
    Time Spent: 3h  (was: 2h 50m)

> The Row object needs better builders
> ------------------------------------
>
>                 Key: BEAM-9331
>                 URL: https://issues.apache.org/jira/browse/BEAM-9331
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-java-core
>            Reporter: Reuven Lax
>            Priority: Major
>          Time Spent: 3h
>  Remaining Estimate: 0h
>
> Users should be able to build a Row object by specifying field names. Desired 
> syntax:
>  
> Row.withSchema(schema)
>    .withFieldName("field1", "value)
>   .withFieldName("field2.field3", value)
>   .build()
>  
> Users should also have a builder that allows taking an existing row and 
> changing specific fields.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to