-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create packages for bigquery and outline spi layer
- Loading branch information
Showing
9 changed files
with
552 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
Google Cloud Java Client for BigQuery | ||
==================================== | ||
|
||
Java idiomatic client for [Google Cloud BigQuery] (https://cloud.google.com/bigquery). | ||
|
||
[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) | ||
[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) | ||
<!-- TODO(mziccard): add in the maven shield once the artifact is pushed to maven --> | ||
|
||
- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) | ||
+<!-- TODO(mziccard): add link to API documentatin --> | ||
|
||
> Note: This client is a work-in-progress, and may occasionally | ||
> make backwards-incompatible changes. | ||
Quickstart | ||
---------- | ||
Add this to your pom.xml file | ||
<!-- TODO(mziccard): add dependency code --> | ||
|
||
|
||
Example Application | ||
------------------- | ||
|
||
<!-- TODO(mziccard): add example application --> | ||
|
||
Authentication | ||
-------------- | ||
|
||
See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the base directory's README. | ||
|
||
About Google Cloud BigQuery | ||
-------------------------- | ||
|
||
[Google Cloud BigQuery][cloud-bigquery] is a fully managed, NoOps, low cost data analytics service. | ||
Data can be streamed into BigQuery at millions of rows per second to enable real-time analysis. | ||
With BigQuery you can easily deploy Petabyte-scale Databases. | ||
|
||
Be sure to activate the Google Cloud BigQuery API on the Developer's Console to use BigQuery from your project. | ||
|
||
See the ``gcloud-java`` API [bigquery documentation][bigquery-api] to learn how to interact | ||
with Google Cloud BigQuery using this Client Library. | ||
|
||
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) and a project ID if running this snippet elsewhere. | ||
|
||
<!-- TODO(mziccard): add code snippet --> | ||
|
||
Java Versions | ||
------------- | ||
|
||
Java 7 or above is required for using this client. | ||
|
||
Testing | ||
------- | ||
|
||
<!-- TODO(mziccard): add this in once the RemoteGCBQMHelper class is functional --> | ||
|
||
Versioning | ||
---------- | ||
|
||
This library follows [Semantic Versioning] (http://semver.org/). | ||
|
||
It is currently in major version zero (``0.y.z``), which means that anything | ||
may change at any time and the public API should not be considered | ||
stable. | ||
|
||
Contributing | ||
------------ | ||
|
||
Contributions to this library are always welcome and highly encouraged. | ||
|
||
See [CONTRIBUTING] for more information on how to get started. | ||
|
||
License | ||
------- | ||
|
||
Apache 2.0 - See [LICENSE] for more information. | ||
|
||
|
||
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md | ||
[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE | ||
[TESTING]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/TESTING.md#testing-code-that-uses-bigquery | ||
[cloud-platform]: https://cloud.google.com/ | ||
|
||
[cloud-bigquery]: https://cloud.google.com/bigquery/ | ||
[bigquery-api]: http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/bigquery/package-summary.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.google.gcloud</groupId> | ||
<artifactId>gcloud-java-bigquery</artifactId> | ||
<packaging>jar</packaging> | ||
<name>GCloud Java bigquery</name> | ||
<description> | ||
Java idiomatic client for Google Cloud BigQuery. | ||
</description> | ||
<parent> | ||
<groupId>com.google.gcloud</groupId> | ||
<artifactId>gcloud-java-pom</artifactId> | ||
<version>0.0.11-SNAPSHOT</version> | ||
</parent> | ||
<properties> | ||
<site.installationModule>gcloud-java-bigquery</site.installationModule> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>gcloud-java-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.apis</groupId> | ||
<artifactId>google-api-services-bigquery</artifactId> | ||
<version>v2-rev244-1.20.0</version> | ||
<scope>compile</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava-jdk5</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.easymock</groupId> | ||
<artifactId>easymock</artifactId> | ||
<version>3.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
29 changes: 29 additions & 0 deletions
29
gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Bigquery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2015 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed 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 com.google.gcloud.bigquery; | ||
|
||
import com.google.gcloud.Service; | ||
|
||
/** | ||
* An interface for Google Cloud BigQuery. | ||
* | ||
* @see <a href="https://cloud.google.com/bigquery/what-is-bigquery">Google Cloud BigQuery</a> | ||
*/ | ||
public interface Bigquery extends Service<BigqueryOptions> { | ||
|
||
// TODO(mziccard) add missing methods | ||
} |
54 changes: 54 additions & 0 deletions
54
gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigqueryException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2015 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed 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 com.google.gcloud.bigquery; | ||
|
||
import com.google.gcloud.BaseServiceException; | ||
import com.google.gcloud.RetryHelper.RetryHelperException; | ||
import com.google.gcloud.RetryHelper.RetryInterruptedException; | ||
|
||
/** | ||
* BigQuery service exception. | ||
* | ||
* @see <a href="https://cloud.google.com/bigquery/troubleshooting-errors">Google Cloud | ||
* BigQuery error codes</a> | ||
*/ | ||
public class BigqueryException extends BaseServiceException { | ||
|
||
private static final long serialVersionUID = -5504832700512784654L; | ||
public static final int UNKNOWN_CODE = -1; | ||
|
||
public BigqueryException(int code, String message, boolean retryable) { | ||
super(code, message, retryable); | ||
} | ||
|
||
/** | ||
* Translate RetryHelperException to the BigqueryException that caused the error. This method will | ||
* always throw an exception. | ||
* | ||
* @throws BigqueryException when {@code ex} was caused by a {@code BigqueryException} | ||
* @throws RetryInterruptedException when {@code ex} is a {@code RetryInterruptedException} | ||
*/ | ||
static BigqueryException translateAndThrow(RetryHelperException ex) { | ||
if (ex.getCause() instanceof BigqueryException) { | ||
throw (BigqueryException) ex.getCause(); | ||
} | ||
if (ex instanceof RetryInterruptedException) { | ||
RetryInterruptedException.propagate(); | ||
} | ||
throw new BigqueryException(UNKNOWN_CODE, ex.getMessage(), false); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigqueryFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2015 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed 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 com.google.gcloud.bigquery; | ||
|
||
|
||
import com.google.gcloud.ServiceFactory; | ||
|
||
/** | ||
* An interface for BigQuery factories. | ||
*/ | ||
public interface BigqueryFactory extends ServiceFactory<Bigquery, BigqueryOptions> { | ||
} |
112 changes: 112 additions & 0 deletions
112
gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigqueryOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright 2015 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed 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 com.google.gcloud.bigquery; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.google.gcloud.ServiceOptions; | ||
import com.google.gcloud.spi.DefaultBigqueryRpc; | ||
import com.google.gcloud.spi.BigqueryRpc; | ||
import com.google.gcloud.spi.BigqueryRpcFactory; | ||
|
||
import java.util.Set; | ||
|
||
public class BigqueryOptions extends ServiceOptions<Bigquery, BigqueryRpc, BigqueryOptions> { | ||
|
||
private static final String BIGQUERY_SCOPE = "https://www.googleapis.com/auth/bigquery"; | ||
private static final Set<String> SCOPES = ImmutableSet.of(BIGQUERY_SCOPE); | ||
private static final long serialVersionUID = -215981591481708043L; | ||
|
||
public static class DefaultBigqueryFactory implements BigqueryFactory { | ||
|
||
private static final BigqueryFactory INSTANCE = new DefaultBigqueryFactory(); | ||
|
||
@Override | ||
public Bigquery create(BigqueryOptions options) { | ||
// TODO(mziccard) return new BigqueryImpl(options); | ||
return null; | ||
} | ||
} | ||
|
||
public static class DefaultBigqueryRpcFactory implements BigqueryRpcFactory { | ||
|
||
private static final BigqueryRpcFactory INSTANCE = new DefaultBigqueryRpcFactory(); | ||
|
||
@Override | ||
public BigqueryRpc create(BigqueryOptions options) { | ||
// TODO(mziccard) return new DefaultBigqueryRpc(options); | ||
return null; | ||
} | ||
} | ||
|
||
public static class Builder extends | ||
ServiceOptions.Builder<Bigquery, BigqueryRpc, BigqueryOptions, Builder> { | ||
|
||
private Builder() { | ||
} | ||
|
||
private Builder(BigqueryOptions options) { | ||
super(options); | ||
} | ||
|
||
@Override | ||
public BigqueryOptions build() { | ||
return new BigqueryOptions(this); | ||
} | ||
} | ||
|
||
private BigqueryOptions(Builder builder) { | ||
super(BigqueryFactory.class, BigqueryRpcFactory.class, builder); | ||
} | ||
|
||
@Override | ||
protected BigqueryFactory defaultServiceFactory() { | ||
return DefaultBigqueryFactory.INSTANCE; | ||
} | ||
|
||
@Override | ||
protected BigqueryRpcFactory defaultRpcFactory() { | ||
return DefaultBigqueryRpcFactory.INSTANCE; | ||
} | ||
|
||
@Override | ||
protected Set<String> scopes() { | ||
return SCOPES; | ||
} | ||
|
||
@Override | ||
public Builder toBuilder() { | ||
return new Builder(this); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return baseHashCode(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof BigqueryOptions)) { | ||
return false; | ||
} | ||
BigqueryOptions other = (BigqueryOptions) obj; | ||
return baseEquals(other); | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2015 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
/** | ||
* A client to Google Cloud BigQuery. | ||
* | ||
* <p>A simple usage example: | ||
* <pre>{@code | ||
* //TODO(mziccard): add code example | ||
* }</pre> | ||
* | ||
* @see <a href="https://cloud.google.com/bigquery/">Google Cloud BigQuery</a> | ||
*/ | ||
package com.google.gcloud.bigquery; |
Oops, something went wrong.