mosche commented on code in PR #22182:
URL: https://github.com/apache/beam/pull/22182#discussion_r921852047


##########
sdks/java/core/jmh/src/main/java/org/apache/beam/sdk/schemas/RowBundle.java:
##########
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.schemas;
+
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toMap;
+import static java.util.stream.IntStream.range;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.stream.IntStream;
+import org.apache.beam.sdk.transforms.SerializableFunction;
+import org.apache.beam.sdk.values.Row;
+import org.apache.beam.sdk.values.RowWithGetters;
+import org.apache.beam.sdk.values.RowWithStorage;
+import org.apache.beam.sdk.values.TypeDescriptor;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.infra.Blackhole;
+
+/**
+ * Bundle of rows according to the configured {@link Factory} as input for 
benchmarks.
+ *
+ * <p>The rows are created during {@link #setup()} to exclude initialization 
costs from the
+ * measurement. To prevent unintended cache hits in {@link RowWithGetters}, a 
new bundle of rows
+ * must be generated before every invocation.
+ *
+ * <p>Setup per {@link Level#Invocation} has considerable drawbacks. Though, 
given that processing
+ * bundles of rows (n={@link #bundleSize}) takes well above 1 ms, each 
individual invocation can be
+ * adequately timestamped without risking generating wrong results.
+ */
+@State(Scope.Benchmark)
+public class RowBundle {
+  @SuppressWarnings("ImmutableEnumChecker") // false positive
+  public enum Action {
+    /**
+     * Write field to object using {@link
+     * GetterBasedSchemaProvider#fromRowFunction(TypeDescriptor)}.
+     *
+     * <p>Use {@link RowWithStorage} to bypass optimizations in RowWithGetters 
for writes.
+     */
+    WRITE(Factory::createWithStorage),
+
+    /**
+     * Read field from {@link RowWithGetters} provided by {@link
+     * GetterBasedSchemaProvider#toRowFunction(TypeDescriptor)}.
+     */
+    READ_ONCE(Factory::createWithGetter),
+
+    /**
+     * Repeatedly (3x) read field from {@link RowWithGetters} provided by 
{@link

Review Comment:
   Ok, that makes sense two me, thanks for the clarification. I haven't looked 
too deeply into the available sql transforms on rows. It doesn't look like this 
is supported in the context of the `GetterBasedSchemaProvider`, neither 
`RowWithGetters` nor `RowWithStorage` support mutating / setting field values. 
Setters are used (exclusively?) when invoking the `fromRowFunction` to set 
field values on a new empty instance (or create that instance via some 
creator). 
   
   Another thing to consider when adding more benchmarks is probably the total 
runtime. With the current default configuration a single benchmark takes around 
500secs (warmups, iterations, forks) + some overhead. In total that already 
sums up to ~ 5h (12 runs per each of the 3 actions).
   
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to