Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1045#discussion_r162251307
  
    --- Diff: 
exec/java-exec/src/test/java/org/apache/drill/test/OperatorFixture.java ---
    @@ -175,19 +210,189 @@ public DrillConfig getConfig() {
         }
     
         @Override
    -    public DrillbitContext getDrillbitContext() {
    -      throw new UnsupportedOperationException("Drillbit context not 
available for operator unit tests");
    +    public ExecutorService getScanDecodeExecutor() {
    +      return null;
    +    }
    +
    +    @Override
    +    public ExecutorService getScanExecutor() {
    +      return null;
    +    }
    +
    +    @Override
    +    public ExecutorService getExecutor() {
    +      return null;
    +    }
    +
    +    @Override
    +    public ExecutorState getExecutorState() {
    +      return executorState;
    +    }
    +
    +    @Override
    +    public BufferAllocator getNewChildAllocator(String operatorName, int 
operatorId,
    +                                                long initialReservation, 
long maximumReservation) {
    +      return allocator.newChildAllocator(
    +        "op:" + operatorId + ":" + operatorName,
    +        initialReservation,
    +        maximumReservation);
         }
     
         @Override
    -    protected CodeCompiler getCompiler() {
    +    public ExecProtos.FragmentHandle getHandle() {
    +      return ExecProtos.FragmentHandle.newBuilder().build();
    +    }
    +
    +    @Override
    +    public BufferAllocator getAllocator() {
    +      return allocator;
    +    }
    +
    +    @Override
    +    public OperatorContext newOperatorContext(PhysicalOperator popConfig) {
    +      return mockOperatorContext;
    +    }
    +
    +    @Override
    +    public OperatorContext newOperatorContext(PhysicalOperator popConfig, 
OperatorStats stats) {
    +      return mockOperatorContext;
    +    }
    +
    +    @Override
    +    public SchemaPlus getFullRootSchema() {
    +      return null;
    +    }
    +
    +    @Override
    +    public String getQueryUserName() {
    +      return null;
    +    }
    +
    +    @Override
    +    public String getFragIdString() {
    +      return null;
    +    }
    +
    +    @Override
    +    public CodeCompiler getCompiler() {
            return compiler;
         }
     
         @Override
         protected BufferManager getBufferManager() {
           return bufferManager;
         }
    +
    +    @Override
    +    public void close() {
    +      bufferManager.close();
    +    }
    +
    +    @Override
    +    public ContextInformation getContextInformation() {
    +      return null;
    +    }
    +
    +    @Override
    +    public PartitionExplorer getPartitionExplorer() {
    +      return null;
    +    }
    +
    +    @Override
    +    public ValueHolder getConstantValueHolder(String value, 
TypeProtos.MinorType type, Function<DrillBuf, ValueHolder> holderInitializer) {
    +      return null;
    +    }
    +  }
    +
    +  public static class MockExecutorFragmentContext extends 
MockFragmentContext implements ExecutorFragmentContext {
    +
    +    public MockExecutorFragmentContext(DrillConfig config, OptionManager 
optionManager, BufferAllocator allocator) {
    +      super(config, optionManager, allocator);
    +    }
    +
    +    @Override
    +    public PhysicalPlanReader getPlanReader() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public ClusterCoordinator getClusterCoordinator() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public CoordinationProtos.DrillbitEndpoint getForemanEndpoint() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public CoordinationProtos.DrillbitEndpoint getEndpoint() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public Collection<CoordinationProtos.DrillbitEndpoint> getBits() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public OperatorCreatorRegistry getOperatorCreatorRegistry() {
    +      return null;
    +    }
    +
    +    @Override
    +    public void setBuffers(IncomingBuffers buffers) {
    +
    +    }
    +
    +    @Override
    +    public Set<Map.Entry<UserServer.BitToUserConnection, 
UserServer.BitToUserConnectionConfig>> getUserConnections() {
    +      return null;
    +    }
    +
    +    @Override
    +    public QueryProfileStoreContext getProfileStoreContext() {
    +      return null;
    +    }
    +
    +    @Override
    +    public void waitForSendComplete() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public AccountingDataTunnel 
getDataTunnel(CoordinationProtos.DrillbitEndpoint endpoint) {
    --- End diff --
    
    We really don't want to expose this network-related stuff in most fragment 
contexts. The idea for the API I created was to separate out the 
operator-related stuff from the Drillbit/network stuff. Doing so minimizes 
coupling and mocking. Shame to see us going back the other direction...


---

Reply via email to