Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: Renamed SchemaCompact.java to SchemaCompatibility.java (#362)
* Renaming SchemaCompact.java to SchemaCompatibility.java, and changed all instances of SchemaCompact.

* Update clirr-ignore file

* Fixed class name

* Fix small typo
  • Loading branch information
allenc3 committed Jun 20, 2020
1 parent 27c55e9 commit d3f4787
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 49 deletions.
18 changes: 17 additions & 1 deletion google-cloud-bigquerystorage/clirr-ignored-differences.xml
Expand Up @@ -12,4 +12,20 @@
<className>com/google/cloud/bigquery/storage/v1alpha2/StreamWriter</className>
<method>boolean awaitTermination(long, java.util.concurrent.TimeUnit) </method>
</difference>
</differences>
<difference>
<differenceType>7005</differenceType>
<className>com/google/cloud/bigquery/storage/v1alpha2/DirectWriter</className>
<method>void testSetStub(com.google.cloud.bigquery.storage.v1alpha2.BigQueryWriteClient, int, com.google.cloud.bigquery.storage.v1alpha2.SchemaCompact) </method>
<to>void testSetStub(com.google.cloud.bigquery.storage.v1alpha2.BigQueryWriteClient, int, com.google.cloud.bigquery.storage.v1alpha2.SchemaCompatibility)</to>
</difference>
<difference>
<differenceType>8001</differenceType>
<className>com/google/cloud/bigquery/storage/v1alpha2/SchemaCompact</className>
</difference>
<difference>
<differenceType>7005</differenceType>
<className>com/google/cloud/bigquery/storage/v1alpha2/WriterCache</className>
<method>com.google.cloud.bigquery.storage.v1alpha2.WriterCache getTestInstance(com.google.cloud.bigquery.storage.v1alpha2.BigQueryWriteClient, int, com.google.cloud.bigquery.storage.v1alpha2.SchemaCompact) </method>
<to>com.google.cloud.bigquery.storage.v1alpha2.WriterCache getTestInstance(com.google.cloud.bigquery.storage.v1alpha2.BigQueryWriteClient, int, com.google.cloud.bigquery.storage.v1alpha2.SchemaCompatibility)</to>
</difference>
</differences>
Expand Up @@ -99,7 +99,7 @@ public Long apply(Storage.AppendRowsResponse appendRowsResponse) {

@VisibleForTesting
public static void testSetStub(
BigQueryWriteClient stub, int maxTableEntry, SchemaCompact schemaCheck) {
BigQueryWriteClient stub, int maxTableEntry, SchemaCompatibility schemaCheck) {
cache = WriterCache.getTestInstance(stub, maxTableEntry, schemaCheck);
}

Expand Down
Expand Up @@ -41,9 +41,9 @@
* <p>The implementation as of now is not complete, which measn, if this check passed, there is
* still a possbility of writing will fail.
*/
public class SchemaCompact {
public class SchemaCompatibility {
private BigQuery bigquery;
private static SchemaCompact compact;
private static SchemaCompatibility compact;
private static String tablePatternString = "projects/([^/]+)/datasets/([^/]+)/tables/([^/]+)";
private static Pattern tablePattern = Pattern.compile(tablePatternString);
private static final int NestingLimit = 15;
Expand All @@ -70,33 +70,33 @@ public class SchemaCompact {
Descriptors.FieldDescriptor.Type.GROUP,
Descriptors.FieldDescriptor.Type.ENUM)));

private SchemaCompact(BigQuery bigquery) {
// TODO: Add functionality that allows SchemaCompact to build schemas.
private SchemaCompatibility(BigQuery bigquery) {
// TODO: Add functionality that allows SchemaCompatibility to build schemas.
this.bigquery = bigquery;
}

/**
* Gets a singleton {code SchemaCompact} object.
* Gets a singleton {code SchemaCompatibility} object.
*
* @return
*/
public static SchemaCompact getInstance() {
public static SchemaCompatibility getInstance() {
if (compact == null) {
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
compact = new SchemaCompact(bigqueryHelper.getOptions().getService());
compact = new SchemaCompatibility(bigqueryHelper.getOptions().getService());
}
return compact;
}

/**
* Gets a {code SchemaCompact} object with custom BigQuery stub.
* Gets a {code SchemaCompatibility} object with custom BigQuery stub.
*
* @param bigquery
* @return
*/
@VisibleForTesting
public static SchemaCompact getInstance(BigQuery bigquery) {
return new SchemaCompact(bigquery);
public static SchemaCompatibility getInstance(BigQuery bigquery) {
return new SchemaCompatibility(bigquery);
}

private TableId getTableId(String tableName) {
Expand Down
Expand Up @@ -47,9 +47,9 @@ public class WriterCache {
private static final int MAX_WRITERS_PER_TABLE = 2;

private final BigQueryWriteClient stub;
private final SchemaCompact compact;
private final SchemaCompatibility compact;

private WriterCache(BigQueryWriteClient stub, int maxTableEntry, SchemaCompact compact) {
private WriterCache(BigQueryWriteClient stub, int maxTableEntry, SchemaCompatibility compact) {
this.stub = stub;
this.compact = compact;
writerCache =
Expand All @@ -71,15 +71,15 @@ public static WriterCache getInstance() throws IOException {
if (instance == null) {
BigQueryWriteSettings stubSettings = BigQueryWriteSettings.newBuilder().build();
BigQueryWriteClient stub = BigQueryWriteClient.create(stubSettings);
instance = new WriterCache(stub, MAX_TABLE_ENTRY, SchemaCompact.getInstance());
instance = new WriterCache(stub, MAX_TABLE_ENTRY, SchemaCompatibility.getInstance());
}
return instance;
}

/** Returns a cache with custom stub used by test. */
@VisibleForTesting
public static WriterCache getTestInstance(
BigQueryWriteClient stub, int maxTableEntry, SchemaCompact compact) {
BigQueryWriteClient stub, int maxTableEntry, SchemaCompatibility compact) {
return new WriterCache(stub, maxTableEntry, compact);
}

Expand Down
Expand Up @@ -53,7 +53,7 @@ public class DirectWriterTest {
private BigQueryWriteClient client;
private LocalChannelProvider channelProvider;

@Mock private static SchemaCompact schemaCheck;
@Mock private static SchemaCompatibility schemaCheck;

@BeforeClass
public static void startStaticServer() {
Expand Down

0 comments on commit d3f4787

Please sign in to comment.