Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ public static String getGcsFileAsString(String filePath) {
result = FileSystems.match(filePath);
checkArgument(
result.status() == MatchResult.Status.OK && !result.metadata().isEmpty(),
"Failed to match any files with the pattern: " + filePath);
"Failed to match any files with the pattern: %s",
filePath);

List<ResourceId> rId =
result.metadata().stream()
.map(MatchResult.Metadata::resourceId)
.collect(Collectors.toList());

checkArgument(rId.size() == 1, "Expected exactly 1 file, but got " + rId.size() + " files.");
checkArgument(rId.size() == 1, "Expected exactly 1 file, but got %s files.", rId.size());

Reader reader =
Channels.newReader(FileSystems.open(rId.get(0)), StandardCharsets.UTF_8.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class SplittableProcessElementsEvaluatorFactory<
public DoFnLifecycleManager load(final AppliedPTransform<?, ?, ?> application) {
checkArgument(
ProcessElements.class.isInstance(application.getTransform()),
"No know extraction of the fn from " + application);
"No know extraction of the fn from %s",
application);
final ProcessElements<
InputT, OutputT, RestrictionT, PositionT, WatermarkEstimatorStateT>
transform =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public CloudObject toCloudObject(FullWindowedValueCoder target, SdkComponents sd
@Override
public FullWindowedValueCoder fromCloudObject(CloudObject object) {
List<Coder<?>> components = getComponents(object);
checkArgument(components.size() == 2, "Expecting 2 components, got " + components.size());
checkArgument(components.size() == 2, "Expecting 2 components, got %s", components.size());
@SuppressWarnings("unchecked")
Coder<? extends BoundedWindow> window = (Coder<? extends BoundedWindow>) components.get(1);
return FullWindowedValueCoder.of(components.get(0), window);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public ParDoFn create(
SerializableUtils.deserializeFromByteArray(serializedCombineFn, "serialized combine fn");
checkArgument(
combineFnObj instanceof AppliedCombineFn,
"unexpected kind of AppliedCombineFn: " + combineFnObj.getClass().getName());
"unexpected kind of AppliedCombineFn: %s",
combineFnObj.getClass().getName());
combineFn = (AppliedCombineFn<?, ?, ?, ?>) combineFnObj;
}

Expand All @@ -110,14 +111,16 @@ public ParDoFn create(
Coder<?> inputCoder = CloudObjects.coderFromCloudObject(CloudObject.fromSpec(inputCoderObject));
checkArgument(
inputCoder instanceof WindowedValueCoder,
"Expected WindowedValueCoder for inputCoder, got: " + inputCoder.getClass().getName());
"Expected WindowedValueCoder for inputCoder, got: %s",
inputCoder.getClass().getName());
@SuppressWarnings("unchecked")
WindowedValueCoder<?> windowedValueCoder = (WindowedValueCoder<?>) inputCoder;

Coder<?> elemCoder = windowedValueCoder.getValueCoder();
checkArgument(
elemCoder instanceof KvCoder,
"Expected KvCoder for inputCoder, got: " + elemCoder.getClass().getName());
"Expected KvCoder for inputCoder, got: %s",
elemCoder.getClass().getName());
@SuppressWarnings("unchecked")
KvCoder<?, ?> kvCoder = (KvCoder<?, ?>) elemCoder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ public InMemoryReader(
int maxIndex = encodedElements.size();
this.startIndex = Math.min(maxIndex, firstNonNull(startIndex, 0));
this.endIndex = Math.min(maxIndex, firstNonNull(endIndex, maxIndex));
checkArgument(this.startIndex >= 0, "negative start index: " + startIndex);
checkArgument(this.startIndex >= 0, "negative start index: %s", startIndex);
checkArgument(
this.endIndex >= this.startIndex,
"end index before start: [" + this.startIndex + ", " + this.endIndex + ")");
"end index before start: [%s, %s)",
this.startIndex,
this.endIndex);
this.coder = coder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public RunningProcess startProcess(
public void stopProcess(String id) {
checkNotNull(id, "Process id must not be null");
try {
Process process = checkNotNull(processes.remove(id), "Process for id does not exist: " + id);
Process process = checkNotNull(processes.remove(id), "Process for id does not exist: %s", id);
stopProcess(id, process);
} finally {
synchronized (ALL_PROCESS_MANAGERS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,11 @@ public CompletableFuture<StateResponse> handle(StateRequest.Builder requestBuild
ImmutableBiMap.copyOf(new ModelCoderRegistrar().getCoderURNs())
.inverse()
.get(coder.getUrn());
checkNotNull(coderType, "Unknown coder URN: " + coder.getUrn());
checkNotNull(coderType, "Unknown coder URN: %s", coder.getUrn());

CoderTranslator<?> translator = new ModelCoderRegistrar().getCoderTranslators().get(coderType);
checkNotNull(
translator, "No translator found for common coder class: " + coderType.getSimpleName());
translator, "No translator found for common coder class: %s", coderType.getSimpleName());

return translator.fromComponents(components, coder.getPayload(), new TranslationContext() {});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public SparkSideInputReader(
checkNotNull(view, "The PCollectionView passed to sideInput cannot be null ");
KV<WindowingStrategy<?, ?>, SideInputBroadcast<?>> windowedBroadcastHelper =
sideInputs.get(view.getTagInternal());
checkNotNull(windowedBroadcastHelper, "SideInput for view " + view + " is not available.");
checkNotNull(windowedBroadcastHelper, "SideInput for view %s is not available.", view);

// --- sideInput window
final BoundedWindow sideInputWindow = view.getWindowMappingFn().getSideInputWindow(window);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Twister2SideInputReader(
public <T> @Nullable T get(PCollectionView<T> view, BoundedWindow window) {
checkNotNull(view, "View passed to sideInput cannot be null");
TupleTag<?> tag = view.getTagInternal();
checkNotNull(sideInputs.get(tag), "Side input for " + view + " not available.");
checkNotNull(sideInputs.get(tag), "Side input for %s not available.", view);
return getSideInput(view, window);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public void validate() {
if (errorHandling != null) {
checkArgument(
!Strings.isNullOrEmpty(errorHandling.getOutput()),
invalidConfigMessage + "Output must not be empty if error handling specified.");
"%sOutput must not be empty if error handling specified.",
invalidConfigMessage);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ public Schema(List<Field> fields, Options options) {
for (Field field : this.fields) {
Preconditions.checkArgument(
fieldIndicesMutable.get(field.getName()) == null,
"Duplicate field " + field.getName() + " added to schema");
"Duplicate field %s added to schema",
field.getName());
encodingPositions.put(field.getName(), index);
fieldIndicesMutable.put(field.getName(), index++);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static <T> Coder<T> coderForFieldType(FieldType fieldType) {
default:
coder = (Coder<T>) CODER_MAP.get(fieldType.getTypeName());
}
Preconditions.checkNotNull(coder, "Unexpected field type " + fieldType.getTypeName());
Preconditions.checkNotNull(coder, "Unexpected field type %s", fieldType.getTypeName());
if (fieldType.getNullable()) {
coder = NullableCoder.of(coder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ public Value toInputType(Row base) {
for (int i = 0; i < base.getFieldCount(); ++i) {
Object value = base.getValue(i);
if (value != null) {
checkArgument(caseType == null, "More than one field set in union " + this);
checkArgument(caseType == null, "More than one field set in union %s", this);
caseType = enumerationType.valueOf(oneOfSchema.getField(i).getName());
oneOfValue = value;
}
}
checkNotNull(oneOfValue, "No value set in union" + this);
checkNotNull(oneOfValue, "No value set in union %s", this);
return createValue(caseType, oneOfValue);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public <T> OutputReceiver<T> get(TupleTag<T> tag) {
@Override
public <T> OutputReceiver<Row> getRowReceiver(TupleTag<T> tag) {
Coder<T> outputCoder = (Coder<T>) checkNotNull(outputCoders).get(tag);
checkStateNotNull(outputCoder, "No output tag for " + tag);
checkStateNotNull(outputCoder, "No output tag for %s ", tag);
checkState(
outputCoder instanceof SchemaCoder,
"Output with tag " + tag + " must have a schema in order to call getRowReceiver");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private static ReadableByteChannel openLocalFile(String filePath) {
List<ResourceId> rId =
result.metadata().stream().map(MatchResult.Metadata::resourceId).collect(toList());

checkArgument(rId.size() == 1, "Expected exactly 1 file, but got " + rId.size() + " files.");
checkArgument(rId.size() == 1, "Expected exactly 1 file, but got %s files.", rId.size());
return FileSystems.open(rId.get(0));
} catch (IOException e) {
throw new RuntimeException("Error when finding: " + filePath, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private Map<String, String> parseProperties() {
String.format(
"Unexpected properties entry '%s' of class '%s'", property, property.getClass()));
SqlNodeList kv = ((SqlNodeList) property);
checkState(kv.size() == 2, "Expected 2 items in properties entry, but got " + kv.size());
checkState(kv.size() == 2, "Expected 2 items in properties entry, but got %s", kv.size());
String key = checkStateNotNull(SqlDdlNodes.getString(kv.get(0)));
String value = checkStateNotNull(SqlDdlNodes.getString(kv.get(1)));
props.put(key, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void useDatabase(String database) {

@Override
public boolean dropDatabase(String database, boolean cascade) {
checkState(!cascade, getClass().getSimpleName() + " does not support CASCADE.");
checkState(!cascade, "%s does not support CASCADE.", getClass().getSimpleName());

boolean removed = databases.remove(database);
if (database.equals(currentDatabase)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public synchronized BeamSqlTable buildBeamSqlTable(Table table) {
}

public void addRows(String tableName, Row... rows) {
checkArgument(tables().containsKey(tableName), "Table not found: " + tableName);
checkArgument(tables().containsKey(tableName), "Table not found: %s", tableName);
tables().get(tableName).rows.addAll(Arrays.asList(rows));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ private <T> OutputReceiver<Row> createTaggedRowReceiver(TupleTag<T> tag) {
}

Coder<T> outputCoder = (Coder<T>) outputCoders.get(tag);
checkState(outputCoder != null, "No output tag for " + tag);
checkState(outputCoder != null, "No output tag for %s", tag);
checkState(
outputCoder instanceof SchemaCoder,
"Output with tag " + tag + " must have a schema in order to call getRowReceiver");
Expand Down Expand Up @@ -2449,7 +2449,7 @@ private <T> OutputReceiver<Row> createTaggedRowReceiver(TupleTag<T> tag) {
}

Coder<T> outputCoder = (Coder<T>) outputCoders.get(tag);
checkState(outputCoder != null, "No output tag for " + tag);
checkState(outputCoder != null, "No output tag for %s", tag);
checkState(
outputCoder instanceof SchemaCoder,
"Output with tag " + tag + " must have a schema in order to call getRowReceiver");
Expand Down Expand Up @@ -2763,7 +2763,7 @@ private <T> OutputReceiver<Row> createTaggedRowReceiver(TupleTag<T> tag) {
}

Coder<T> outputCoder = (Coder<T>) outputCoders.get(tag);
checkState(outputCoder != null, "No output tag for " + tag);
checkState(outputCoder != null, "No output tag for %s", tag);
checkState(
outputCoder instanceof SchemaCoder,
"Output with tag " + tag + " must have a schema in order to call getRowReceiver");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3472,19 +3472,22 @@ && getStorageApiTriggeringFrequency(bqOptions) != null) {
}
}
} else { // PCollection is bounded
String error =
String.format(
" is only applicable to an unbounded PCollection, but the input PCollection is %s.",
input.isBounded());
checkArgument(getTriggeringFrequency() == null, "Triggering frequency" + error);
checkArgument(!getAutoSharding(), "Auto-sharding" + error);
checkArgument(getNumFileShards() == 0, "Number of file shards" + error);
checkArgument(
getTriggeringFrequency() == null,
"Triggering frequency is only applicable to an unbounded PCollection.");
checkArgument(
!getAutoSharding(), "Auto-sharding is only applicable to an unbounded PCollection.");
checkArgument(
getNumFileShards() == 0,
"Number of file shards is only applicable to an unbounded PCollection.");

if (getStorageApiTriggeringFrequency(bqOptions) != null) {
LOG.warn("Setting a triggering frequency" + error);
LOG.warn(
"Setting the triggering frequency is only applicable to an unbounded PCollection.");
}
if (getStorageApiNumStreams(bqOptions) != 0) {
LOG.warn("Setting the number of Storage API streams" + error);
LOG.warn(
"Setting the number of Storage API streams is only applicable to an unbounded PCollection.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private static void setBeamValueToMutation(
@Nullable BigDecimal decimal = row.getDecimal(columnName);
// BigDecimal is not nullable
if (decimal == null) {
checkNotNull(decimal, "Null decimal at column " + columnName);
checkNotNull(decimal, "Null decimal at column %s", columnName);
} else {
mutationBuilder.set(columnName).to(decimal);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static Struct beamRowToStruct(Row row) {
@Nullable BigDecimal decimal = row.getDecimal(column);
// BigDecimal is not nullable
if (decimal == null) {
checkNotNull(decimal, "Null decimal at column " + column);
checkNotNull(decimal, "Null decimal at column %s", column);
} else {
structBuilder.set(column).to(decimal);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2717,8 +2717,7 @@ public void testWriteValidateFailsWithBatchAutoSharding() {
p.enableAbandonedNodeEnforcement(false);

thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"Auto-sharding is only applicable to an unbounded PCollection, but the input PCollection is BOUNDED.");
thrown.expectMessage("Auto-sharding is only applicable to an unbounded PCollection.");
p.apply(Create.empty(INPUT_RECORD_CODER))
.apply(
BigQueryIO.<InputRecord>write()
Expand Down Expand Up @@ -3146,7 +3145,7 @@ public void testRemoveTemporaryTables() throws Exception {

for (TableReference ref : tableRefs) {
loggedWriteRename.verifyDebug("Deleting table " + toJsonString(ref));
checkState(datasetService.getTable(ref) == null, "Table " + ref + " was not deleted!");
checkState(datasetService.getTable(ref) == null, "Table %s was not deleted!", ref);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,8 @@ private void validateConfiguration(Configuration configuration) {
if (configuration.get("mapreduce.job.inputformat.class").endsWith("DBInputFormat")) {
checkArgument(
configuration.get(DBConfiguration.INPUT_ORDER_BY_PROPERTY) != null,
"Configuration must contain \""
+ DBConfiguration.INPUT_ORDER_BY_PROPERTY
+ "\" when using DBInputFormat");
"Configuration must contain \"%s\" when using DBInputFormat",
DBConfiguration.INPUT_ORDER_BY_PROPERTY);
}
}

Expand Down Expand Up @@ -1061,8 +1060,7 @@ public static class SerializableSplit implements Serializable {
public SerializableSplit() {}

public SerializableSplit(InputSplit split) {
checkArgument(
split instanceof Writable, String.format("Split is not of type Writable: %s", split));
checkArgument(split instanceof Writable, "Split is not of type Writable: %s", split);
this.inputSplit = split;
}

Expand Down Expand Up @@ -1684,14 +1682,17 @@ private void validateConfiguration(Configuration conf) {
checkArgument(conf != null, "Configuration can not be null");
checkArgument(
conf.get(OUTPUT_FORMAT_CLASS_ATTR) != null,
"Configuration must contain \"" + OUTPUT_FORMAT_CLASS_ATTR + "\"");
"Configuration must contain \"%s\"",
OUTPUT_FORMAT_CLASS_ATTR);
checkArgument(
conf.get(OUTPUT_KEY_CLASS) != null,
"Configuration must contain \"" + OUTPUT_KEY_CLASS + "\"");
"Configuration must contain \"%s\"",
OUTPUT_KEY_CLASS);
checkArgument(
conf.get(OUTPUT_VALUE_CLASS) != null,
"Configuration must contain \"" + OUTPUT_VALUE_CLASS + "\"");
checkArgument(conf.get(JOB_ID) != null, "Configuration must contain \"" + JOB_ID + "\"");
"Configuration must contain \"%s\"",
OUTPUT_VALUE_CLASS);
checkArgument(conf.get(JOB_ID) != null, "Configuration must contain \"%s\"", JOB_ID);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public Read withTerminationCondition(TerminationCondition<Read, ?> terminationCo
}

Read withSplitId(int splitId) {
checkArgument(splitId >= 0, "Invalid split id-" + splitId);
checkArgument(splitId >= 0, "Invalid split id-%s", splitId);
return toBuilder().setSplitId(splitId).build();
}

Expand Down
Loading