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

ASF GitHub Bot logged work on GOBBLIN-1941:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Oct/23 00:12
            Start Date: 28/Oct/23 00:12
    Worklog Time Spent: 10m 
      Work Description: phet commented on code in PR #3811:
URL: https://github.com/apache/gobblin/pull/3811#discussion_r1375129146


##########
gobblin-temporal/src/main/java/org/apache/gobblin/temporal/util/nesting/work/SeqBackedWorkSpan.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.gobblin.temporal.util.nesting.work;
+
+import java.util.Iterator;
+import java.util.List;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+
+
+/** Logical sub-sequence of `WORK_ITEM`s, backed for simplicity's sake by an 
in-memory collection */
+@NoArgsConstructor
+@RequiredArgsConstructor
+public class SeqBackedWorkSpan<WORK_ITEM> implements 
Workload.WorkSpan<WORK_ITEM> {
+
+  @NonNull
+  private List<WORK_ITEM> elems;
+  // CAUTION: despite the "warning: @NonNull is meaningless on a primitive 
@lombok.RequiredArgsConstructor"...
+  // if removed, no two-arg ctor is generated, so syntax error on `new 
CollectionBackedTaskSpan(elems, startIndex)`
+  @NonNull
+  private int startingIndex;
+  private transient Iterator<WORK_ITEM> statefulDelegatee = null;
+
+  @Override
+  public int getNumElems() {
+    return elems.size();
+  }
+
+  @Override
+  public boolean hasNext() {
+    if (statefulDelegatee == null) {
+      statefulDelegatee = elems.iterator();
+    }
+    return statefulDelegatee.hasNext();
+  }
+
+  @Override
+  public WORK_ITEM next() {
+    if (statefulDelegatee == null) {
+      throw new IllegalStateException("first call `hasNext()`!");

Review Comment:
   That's the `Iterator` contract I've always known, essentially just a 
modernization on bounds checking from C, et. al. without that discipline, how 
could one safely work with an empty `Iterator`?





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

    Worklog Id:     (was: 887667)
    Time Spent: 0.5h  (was: 20m)

> Create abstractions for developing on Temporal
> ----------------------------------------------
>
>                 Key: GOBBLIN-1941
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1941
>             Project: Apache Gobblin
>          Issue Type: Improvement
>          Components: gobblin-core
>            Reporter: Kip Kohn
>            Assignee: Abhishek Tiwari
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Develop abstractions to assist in implementing Gobblin-on-Temporal, including 
> to overcome temporal's limitation of 50Ki events per workflow history -  
> https://docs.temporal.io/workflows#event-history
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to