keith-turner commented on code in PR #5587:
URL: https://github.com/apache/accumulo/pull/5587#discussion_r2122054686


##########
server/base/src/main/java/org/apache/accumulo/server/iterators/TabletIteratorEnvironment.java:
##########
@@ -1,269 +0,0 @@
-/*
- * 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
- *
- *   https://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.accumulo.server.iterators;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.accumulo.core.client.PluginEnvironment;
-import org.apache.accumulo.core.client.SampleNotPresentException;
-import org.apache.accumulo.core.client.sample.SamplerConfiguration;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.TableId;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.iterators.IteratorEnvironment;
-import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
-import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
-import org.apache.accumulo.core.iteratorsImpl.system.MultiIterator;
-import org.apache.accumulo.core.metadata.TabletFile;
-import org.apache.accumulo.core.metadata.schema.DataFileValue;
-import org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.spi.common.ServiceEnvironment;
-import org.apache.accumulo.core.spi.compaction.CompactionKind;
-import org.apache.accumulo.server.ServerContext;
-import org.apache.accumulo.server.ServiceEnvironmentImpl;
-import org.apache.accumulo.server.fs.FileManager.ScanFileManager;
-import org.apache.hadoop.fs.Path;
-
-public class TabletIteratorEnvironment implements SystemIteratorEnvironment {
-
-  private final ServerContext context;
-  private final ServiceEnvironment serviceEnvironment;
-  private final ScanFileManager trm;
-  private final IteratorScope scope;
-  private final boolean fullMajorCompaction;
-  private boolean userCompaction;
-  private final AccumuloConfiguration tableConfig;
-  private final TableId tableId;
-  private final ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators;
-  private Map<TabletFile,DataFileValue> files;
-
-  private final Authorizations authorizations; // these will only be supplied 
during scan scope
-  private SamplerConfiguration samplerConfig;
-  private boolean enableSampleForDeepCopy;
-
-  public TabletIteratorEnvironment(ServerContext context, IteratorScope scope,
-      AccumuloConfiguration tableConfig, TableId tableId) {
-    if (scope == IteratorScope.majc) {
-      throw new IllegalArgumentException("must set if compaction is full");
-    }
-
-    this.context = context;
-    this.serviceEnvironment = new ServiceEnvironmentImpl(context);
-    this.scope = scope;
-    this.trm = null;
-    this.tableConfig = tableConfig;
-    this.tableId = tableId;
-    this.fullMajorCompaction = false;
-    this.userCompaction = false;
-    this.authorizations = Authorizations.EMPTY;
-    this.topLevelIterators = new ArrayList<>();
-  }
-
-  public TabletIteratorEnvironment(ServerContext context, IteratorScope scope,
-      AccumuloConfiguration tableConfig, TableId tableId, 
SamplerConfigurationImpl samplerConfig) {
-    if (scope == IteratorScope.majc) {
-      throw new IllegalArgumentException("must set if compaction is full");
-    }
-
-    this.context = context;
-    this.serviceEnvironment = new ServiceEnvironmentImpl(context);
-    this.scope = scope;
-    this.trm = null;
-    this.tableConfig = tableConfig;
-    this.tableId = tableId;
-    this.fullMajorCompaction = false;
-    this.userCompaction = false;
-    this.authorizations = Authorizations.EMPTY;
-    if (samplerConfig != null) {
-      enableSampleForDeepCopy = true;
-      this.samplerConfig = samplerConfig.toSamplerConfiguration();
-    } else {
-      enableSampleForDeepCopy = false;
-    }
-    this.topLevelIterators = new ArrayList<>();
-  }
-
-  public TabletIteratorEnvironment(ServerContext context, IteratorScope scope,
-      AccumuloConfiguration tableConfig, TableId tableId, ScanFileManager trm,
-      Map<TabletFile,DataFileValue> files, Authorizations authorizations,
-      SamplerConfigurationImpl samplerConfig,
-      ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators) {
-    if (scope == IteratorScope.majc) {
-      throw new IllegalArgumentException("must set if compaction is full");
-    }
-
-    this.context = context;
-    this.serviceEnvironment = new ServiceEnvironmentImpl(context);
-    this.scope = scope;
-    this.trm = trm;
-    this.tableConfig = tableConfig;
-    this.tableId = tableId;
-    this.fullMajorCompaction = false;
-    this.files = files;
-    this.authorizations = authorizations;
-    if (samplerConfig != null) {
-      enableSampleForDeepCopy = true;
-      this.samplerConfig = samplerConfig.toSamplerConfiguration();
-    } else {
-      enableSampleForDeepCopy = false;
-    }
-
-    this.topLevelIterators = topLevelIterators;
-  }
-
-  public TabletIteratorEnvironment(ServerContext context, IteratorScope scope, 
boolean fullMajC,
-      AccumuloConfiguration tableConfig, TableId tableId, CompactionKind kind) 
{
-    if (scope != IteratorScope.majc) {
-      throw new IllegalArgumentException(
-          "Tried to set maj compaction type when scope was " + scope);
-    }
-
-    this.context = context;
-    this.serviceEnvironment = new ServiceEnvironmentImpl(context);
-    this.scope = scope;
-    this.trm = null;
-    this.tableConfig = tableConfig;
-    this.tableId = tableId;
-    this.fullMajorCompaction = fullMajC;
-    this.userCompaction = kind.equals(CompactionKind.USER);
-    this.authorizations = Authorizations.EMPTY;
-    this.topLevelIterators = new ArrayList<>();
-  }
-
-  @Deprecated(since = "2.0.0")
-  @Override
-  public AccumuloConfiguration getConfig() {

Review Comment:
   There will be a different configuration object impl returned for this 
methiod now that could have slightly different behavior.  Not sure if this 
would ever matter.



##########
server/base/src/main/java/org/apache/accumulo/server/iterators/SystemIteratorEnvironmentImpl.java:
##########
@@ -0,0 +1,158 @@
+/*
+ * 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
+ *
+ *   https://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.accumulo.server.iterators;
+
+import java.util.ArrayList;
+import java.util.Optional;
+
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.SampleNotPresentException;
+import org.apache.accumulo.core.client.sample.SamplerConfiguration;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.IteratorEnvironment;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
+import org.apache.accumulo.core.iteratorsImpl.ClientIteratorEnvironment;
+import org.apache.accumulo.core.iteratorsImpl.system.MultiIterator;
+import org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.ServiceEnvironmentImpl;
+
+/**
+ * IteratorEnvironment used on the server side that has a little different 
handling for Sampling and
+ * provides access to the ServerContext and top level iterators.
+ */
+public class SystemIteratorEnvironmentImpl extends ClientIteratorEnvironment
+    implements SystemIteratorEnvironment {
+
+  public static class Builder extends ClientIteratorEnvironment.Builder {
+
+    private final ServerContext ctx;
+    private ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators = 
new ArrayList<>();
+
+    public Builder(ServerContext ctx) {
+      this.ctx = ctx;
+      this.env = Optional.of(new ServiceEnvironmentImpl(ctx));
+    }
+
+    public Builder
+        withTopLevelIterators(ArrayList<SortedKeyValueIterator<Key,Value>> 
topLevelIterators) {
+      this.topLevelIterators = topLevelIterators;
+      return this;
+    }
+
+    @Override
+    public Builder withClient(AccumuloClient client) {
+      // Does nothing, this was set in constructor
+      return this;
+    }
+
+    @Override
+    public SystemIteratorEnvironmentImpl build() {
+      return new SystemIteratorEnvironmentImpl(this);
+    }
+
+  }
+
+  private final ServerContext ctx;
+  private final ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators;
+
+  protected 
SystemIteratorEnvironmentImpl(SystemIteratorEnvironmentImpl.Builder builder) {
+    super(builder);
+    this.ctx = builder.ctx;
+    this.topLevelIterators = builder.topLevelIterators;
+  }
+
+  private SystemIteratorEnvironmentImpl(SystemIteratorEnvironmentImpl copy) {
+    super(copy);
+    this.ctx = copy.ctx;
+    this.topLevelIterators = copy.topLevelIterators;
+  }
+
+  @Override
+  public boolean isFullMajorCompaction() {
+    if (getIteratorScope() != IteratorScope.majc) {
+      throw new IllegalStateException(
+          "Asked about major compaction type when scope is " + 
getIteratorScope());
+    }
+    return super.isFullMajorCompaction();
+  }
+
+  @Override
+  public boolean isUserCompaction() {
+    if (getIteratorScope() != IteratorScope.majc) {
+      throw new IllegalStateException(
+          "Asked about user initiated compaction type when scope is " + 
getIteratorScope());
+    }
+    return super.isUserCompaction();
+  }
+
+  @Override
+  public boolean isSamplingEnabled() {
+    if (getSamplerConfiguration() == null) {
+      return false;
+    } else {
+      return true;
+    }
+  }

Review Comment:
   Sample config could be present w/o sampling being enabled.  Seems like this 
should just return if the boolean is set in the super class that indicates 
sampling is enabled.
   
   ```suggestion
   ```



##########
server/base/src/main/java/org/apache/accumulo/server/iterators/SystemIteratorEnvironmentImpl.java:
##########
@@ -0,0 +1,158 @@
+/*
+ * 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
+ *
+ *   https://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.accumulo.server.iterators;
+
+import java.util.ArrayList;
+import java.util.Optional;
+
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.SampleNotPresentException;
+import org.apache.accumulo.core.client.sample.SamplerConfiguration;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.IteratorEnvironment;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
+import org.apache.accumulo.core.iteratorsImpl.ClientIteratorEnvironment;
+import org.apache.accumulo.core.iteratorsImpl.system.MultiIterator;
+import org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.ServiceEnvironmentImpl;
+
+/**
+ * IteratorEnvironment used on the server side that has a little different 
handling for Sampling and
+ * provides access to the ServerContext and top level iterators.
+ */
+public class SystemIteratorEnvironmentImpl extends ClientIteratorEnvironment
+    implements SystemIteratorEnvironment {
+
+  public static class Builder extends ClientIteratorEnvironment.Builder {
+
+    private final ServerContext ctx;
+    private ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators = 
new ArrayList<>();
+
+    public Builder(ServerContext ctx) {
+      this.ctx = ctx;
+      this.env = Optional.of(new ServiceEnvironmentImpl(ctx));
+    }
+
+    public Builder
+        withTopLevelIterators(ArrayList<SortedKeyValueIterator<Key,Value>> 
topLevelIterators) {
+      this.topLevelIterators = topLevelIterators;
+      return this;
+    }
+
+    @Override
+    public Builder withClient(AccumuloClient client) {
+      // Does nothing, this was set in constructor
+      return this;
+    }
+
+    @Override
+    public SystemIteratorEnvironmentImpl build() {
+      return new SystemIteratorEnvironmentImpl(this);
+    }
+
+  }
+
+  private final ServerContext ctx;
+  private final ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators;
+
+  protected 
SystemIteratorEnvironmentImpl(SystemIteratorEnvironmentImpl.Builder builder) {
+    super(builder);
+    this.ctx = builder.ctx;
+    this.topLevelIterators = builder.topLevelIterators;
+  }
+
+  private SystemIteratorEnvironmentImpl(SystemIteratorEnvironmentImpl copy) {
+    super(copy);
+    this.ctx = copy.ctx;
+    this.topLevelIterators = copy.topLevelIterators;
+  }
+
+  @Override
+  public boolean isFullMajorCompaction() {
+    if (getIteratorScope() != IteratorScope.majc) {

Review Comment:
   could this check be pushed to the super class?



##########
server/base/src/main/java/org/apache/accumulo/server/iterators/SystemIteratorEnvironmentImpl.java:
##########
@@ -0,0 +1,158 @@
+/*
+ * 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
+ *
+ *   https://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.accumulo.server.iterators;
+
+import java.util.ArrayList;
+import java.util.Optional;
+
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.SampleNotPresentException;
+import org.apache.accumulo.core.client.sample.SamplerConfiguration;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.IteratorEnvironment;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
+import org.apache.accumulo.core.iteratorsImpl.ClientIteratorEnvironment;
+import org.apache.accumulo.core.iteratorsImpl.system.MultiIterator;
+import org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.ServiceEnvironmentImpl;
+
+/**
+ * IteratorEnvironment used on the server side that has a little different 
handling for Sampling and
+ * provides access to the ServerContext and top level iterators.
+ */
+public class SystemIteratorEnvironmentImpl extends ClientIteratorEnvironment
+    implements SystemIteratorEnvironment {
+
+  public static class Builder extends ClientIteratorEnvironment.Builder {
+
+    private final ServerContext ctx;
+    private ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators = 
new ArrayList<>();
+
+    public Builder(ServerContext ctx) {
+      this.ctx = ctx;
+      this.env = Optional.of(new ServiceEnvironmentImpl(ctx));
+    }
+
+    public Builder
+        withTopLevelIterators(ArrayList<SortedKeyValueIterator<Key,Value>> 
topLevelIterators) {
+      this.topLevelIterators = topLevelIterators;
+      return this;
+    }
+
+    @Override
+    public Builder withClient(AccumuloClient client) {
+      // Does nothing, this was set in constructor
+      return this;
+    }
+
+    @Override
+    public SystemIteratorEnvironmentImpl build() {
+      return new SystemIteratorEnvironmentImpl(this);
+    }
+
+  }
+
+  private final ServerContext ctx;
+  private final ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators;
+
+  protected 
SystemIteratorEnvironmentImpl(SystemIteratorEnvironmentImpl.Builder builder) {
+    super(builder);
+    this.ctx = builder.ctx;
+    this.topLevelIterators = builder.topLevelIterators;
+  }
+
+  private SystemIteratorEnvironmentImpl(SystemIteratorEnvironmentImpl copy) {
+    super(copy);
+    this.ctx = copy.ctx;
+    this.topLevelIterators = copy.topLevelIterators;
+  }
+
+  @Override
+  public boolean isFullMajorCompaction() {
+    if (getIteratorScope() != IteratorScope.majc) {
+      throw new IllegalStateException(
+          "Asked about major compaction type when scope is " + 
getIteratorScope());
+    }
+    return super.isFullMajorCompaction();
+  }
+
+  @Override
+  public boolean isUserCompaction() {
+    if (getIteratorScope() != IteratorScope.majc) {

Review Comment:
   could this check be pushed to the super class?



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