Skip to content

Commit

Permalink
Fix a few javac warnings (#4833)
Browse files Browse the repository at this point in the history
* Unused variable/field
* Unnecessary lambda field
  • Loading branch information
snazy authored Aug 1, 2022
1 parent a142a54 commit f03d912
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ public class NessieViewCatalog extends BaseMetastoreViews implements AutoCloseab
private String warehouseLocation;
private Configuration config;
private UpdateableReference reference;
private String name;
private FileIO fileIO;
private Map<String, String> catalogOptions;

public NessieViewCatalog(Configuration conf) {
super(conf);
this.config = conf;
}

Expand All @@ -76,7 +74,6 @@ public void initialize(String inputName, Map<String, String> options) {
fileIOImpl == null
? new HadoopFileIO(config)
: CatalogUtil.loadFileIO(fileIOImpl, options, config);
this.name = inputName == null ? "nessie_view_catalog" : inputName;
// remove nessie prefix
final Function<String, String> removePrefix =
x -> x.replace(NessieUtil.NESSIE_CONFIG_PREFIX, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.exceptions.CommitFailedException;
import org.apache.iceberg.exceptions.CommitStateUnknownException;
Expand Down Expand Up @@ -52,8 +51,6 @@

public class NessieViewOperations extends BaseMetastoreViewOperations {
private static final Logger LOG = LoggerFactory.getLogger(NessieViewOperations.class);
private static final Predicate<Exception> RETRY_IF =
exc -> !exc.getClass().getCanonicalName().contains("Unrecoverable");
private final NessieApiV1 api;
private final ContentKey key;
private final UpdateableReference reference;
Expand Down Expand Up @@ -107,7 +104,11 @@ public ViewVersionMetadata refresh() {
throw new NoSuchTableException(ex, "No such view %s", key);
}
}
refreshFromMetadataLocation(metadataLocation, RETRY_IF, 2, this::loadViewMetadata);
refreshFromMetadataLocation(
metadataLocation,
exc -> !exc.getClass().getCanonicalName().contains("Unrecoverable"),
2,
this::loadViewMetadata);
return current();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@

import com.google.common.base.Preconditions;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.exceptions.AlreadyExistsException;
import org.apache.iceberg.exceptions.NotFoundException;

public abstract class BaseMetastoreViews implements Views {
private final Configuration conf;

public BaseMetastoreViews(Configuration conf) {
this.conf = conf;
}
protected BaseMetastoreViews() {}

protected abstract BaseMetastoreViewOperations newViewOps(TableIdentifier viewName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public class TestViewBase {
File metadataDir = null;

@BeforeEach
public void setupTable(@TempDir File dir) throws Exception {
public void setupTable(@TempDir File dir) {
this.tableDir = dir;
this.metadataDir = new File(tableDir, "metadata");
create(SCHEMA);
create();
}

@AfterEach
Expand All @@ -54,7 +54,7 @@ public void cleanupTables() {
TestViews.clearTables();
}

private BaseView create(Schema schema) {
private BaseView create() {
ViewDefinition viewMetadata = ViewDefinition.of(SQL, SCHEMA, "", new ArrayList<>());
TestViews.create(tableDir, "test", viewMetadata, new HashMap<>());
return TestViews.load(tableDir, "test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,17 +349,8 @@ public void testInvalidSnapshotFiltering() throws BaseNessieClientServerExceptio
CommitOutput table2 =
commitSingleOp(
prefix, branch1, branch1.getHash(), -1, CID_TWO, TABLE_TWO, METADATA_ONE, null, null);
table2 =
commitSingleOp(
prefix,
branch1,
table2.hash,
42,
CID_TWO,
TABLE_TWO,
METADATA_TWO,
table2.content,
null);
commitSingleOp(
prefix, branch1, table2.hash, 42, CID_TWO, TABLE_TWO, METADATA_TWO, table2.content, null);

final Instant cutoffTime = Instant.now();
// expect nothing to be expired as -1 is considered as invalid snapshot for expiry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static Stream<JsonNode> nonExistingFields() {
42,
array -> {
ObjectNode version = array.addObject().put(VERSION_ID, 42);
ObjectNode viewDefinition = version.putObject(VIEW_DEFINITION);
version.putObject(VIEW_DEFINITION);
}),
// metadata, CURRENT_VERSION_ID + VERSION_ID, VIEW_DEFINITION, SQL, missing SCHEMA
versions(
Expand All @@ -107,7 +107,7 @@ static Stream<JsonNode> nonExistingFields() {
ObjectNode version = array.addObject().put(VERSION_ID, 42);
ObjectNode viewDefinition = version.putObject(VIEW_DEFINITION);
viewDefinition.put(SQL, "SELECT foo FROM bar");
ObjectNode schema = viewDefinition.putObject(SCHEMA);
viewDefinition.putObject(SCHEMA);
}));
}

Expand Down

0 comments on commit f03d912

Please sign in to comment.