private Input suffixInput(Input input) { String suffixedAlias = String.format("%s-%s", input.getAlias(), UUID.randomUUID()); return input.alias(suffixedAlias); }
@Override public void addInput(Input input, @Nullable Class<?> mapperCls) { if (input.getNamespace() != null && input.getNamespace().equals(NamespaceId.SYSTEM.getNamespace()) && !getProgram().getNamespaceId().equals(NamespaceId.SYSTEM.getNamespace())) { // trying to access system namespace from a program outside system namespace is not allowed throw new IllegalArgumentException(String.format("Accessing Input %s in system namespace " + "is not allowed from the namespace %s", input.getName(), getProgram().getNamespaceId())); } if (input instanceof Input.DatasetInput) { Input.DatasetInput datasetInput = (Input.DatasetInput) input; Input.InputFormatProviderInput createdInput = createInput(datasetInput); addInput(createdInput.getAlias(), createdInput.getInputFormatProvider(), mapperCls); } else if (input instanceof Input.InputFormatProviderInput) { addInput(input.getAlias(), ((Input.InputFormatProviderInput) input).getInputFormatProvider(), mapperCls); } else { // shouldn't happen unless user defines their own Input class throw new IllegalArgumentException(String.format("Input %s has unknown input class %s", input.getName(), input.getClass().getCanonicalName())); } }
@Override public void addInput(Input input, @Nullable Class<?> mapperCls) { if (input.getNamespace() != null && input.getNamespace().equals(NamespaceId.SYSTEM.getNamespace()) && !getProgram().getNamespaceId().equals(NamespaceId.SYSTEM.getNamespace())) { // trying to access system namespace from a program outside system namespace is not allowed throw new IllegalArgumentException(String.format("Accessing Input %s in system namespace " + "is not allowed from the namespace %s", input.getName(), getProgram().getNamespaceId())); } if (input instanceof Input.DatasetInput) { Input.DatasetInput datasetInput = (Input.DatasetInput) input; Input.InputFormatProviderInput createdInput = createInput(datasetInput); addInput(createdInput.getAlias(), createdInput.getInputFormatProvider(), mapperCls); } else if (input instanceof Input.StreamInput) { Input.StreamInput streamInput = (Input.StreamInput) input; String namespace = streamInput.getNamespace(); if (namespace == null) { namespace = getProgram().getNamespaceId(); } addInput(input.getAlias(), new StreamInputFormatProvider(new NamespaceId(namespace), streamInput, streamAdmin), mapperCls); } else if (input instanceof Input.InputFormatProviderInput) { addInput(input.getAlias(), ((Input.InputFormatProviderInput) input).getInputFormatProvider(), mapperCls); } else { // shouldn't happen unless user defines their own Input class throw new IllegalArgumentException(String.format("Input %s has unknown input class %s", input.getName(), input.getClass().getCanonicalName())); } }