Skip to content

Commit

Permalink
add no-op writer
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Keller committed Jan 21, 2024
1 parent a9a7389 commit 8573900
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public RecordWriter createWriter(
if (config.autoCreateEnabled()) {
table = autoCreateTable(tableName, sample);
} else if (ignoreMissingTable) {
return new RecordWriter() {};
return new NoOpWriter();
} else {
throw nst;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.iceberg.connect.data;

import java.util.List;
import org.apache.kafka.connect.sink.SinkRecord;

public class NoOpWriter implements RecordWriter {
@Override
public void write(SinkRecord record) {
// NO-OP
}

@Override
public List<WriterResult> complete() {
// NO-OP
return null;
}

@Override
public void close() {
// NO-OP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
package org.apache.iceberg.connect.data;

import java.util.List;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
import org.apache.kafka.connect.sink.SinkRecord;

public interface RecordWriter extends Cloneable {

default void write(SinkRecord record) {}
void write(SinkRecord record);

default List<WriterResult> complete() {
return ImmutableList.of();
}
List<WriterResult> complete();

default void close() {}
void close();
}

0 comments on commit 8573900

Please sign in to comment.