Skip to content

Commit

Permalink
Merge branch 'master' into alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
lesv authored Mar 21, 2018
2 parents 42d3538 + df10b39 commit bce40a5
Show file tree
Hide file tree
Showing 81 changed files with 4,000 additions and 1,076 deletions.
2 changes: 1 addition & 1 deletion appengine-java8/analytics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions appengine-java8/bigquery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>0.37.0-beta</version>
<version>1.22.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-monitoring</artifactId>
<version>0.37.0-beta</version>
<version>0.40.0-beta</version>
</dependency>
<!-- [END dependencies ] -->

Expand Down Expand Up @@ -96,7 +96,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/bigtable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ limitations under the License.
<dependency>
<groupId>com.google.cloud.bigtable</groupId>
<artifactId>bigtable-hbase-1.x</artifactId>
<version>1.1.2</version>
<version>1.2.0</version>
</dependency>

<!-- Compile/runtime dependencies -->
Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/cloudsql-postgres/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.1</version>
<version>42.2.2</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/datastore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<version>1.5.3</version>
<version>1.5.4</version>
<scope>provided</scope>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/guestbook-cloud-datastore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud</artifactId>
<version>0.37.0-alpha</version>
<version>0.40.0-alpha</version>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions appengine-java8/pubsub/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>0.37.0-beta</version>
<version>0.40.0-beta</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore</artifactId>
<version>1.19.0</version>
<version>1.22.0</version>
</dependency>
<!-- [END dependencies] -->
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/spanner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner</artifactId>
<version>0.37.0-beta</version>
<version>0.40.0-beta</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Expand Down
2 changes: 1 addition & 1 deletion appengine-java8/taskqueues-deferred/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
Expand Down
6 changes: 3 additions & 3 deletions appengine-java8/translate-pubsub/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>0.37.0-beta</version>
<version>0.40.0-beta</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore</artifactId>
<version>1.19.0</version>
<version>1.22.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-translate</artifactId>
<version>1.19.0</version>
<version>1.22.0</version>
</dependency>
<!-- [END dependencies] -->
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion appengine/firebase-tictactoe/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
Expand Down
2 changes: 1 addition & 1 deletion appengine/taskqueue/defer-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
Expand Down
2 changes: 1 addition & 1 deletion bigquery/cloud-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>0.37.0-beta</version>
<version>1.22.0</version>
</dependency>
<!-- [END dependencies] -->
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion bigquery/datatransfer/cloud-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquerydatatransfer</artifactId>
<version>0.37.0-beta</version>
<version>0.40.0-beta</version>
</dependency>
<!-- [END dependencies] -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.example.bigquerydatatransfer;

// [START bigquery_datatransfer_quickstart]
// [START bigquerydatatransfer_quickstart]
// Imports the Google Cloud client library

import com.google.cloud.bigquery.datatransfer.v1.DataSource;
Expand Down Expand Up @@ -56,4 +56,4 @@ public static void main(String... args) throws Exception {
}
}
}
// [END bigquery_datatransfer_quickstart]
// [END bigquerydatatransfer_quickstart]
2 changes: 1 addition & 1 deletion cloud-tasks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudtasks</artifactId>
<version>v2beta2-rev37-1.23.0</version>
<version>v2beta2-rev39-1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
Expand Down
2 changes: 1 addition & 1 deletion compute/cmdline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ limitations under the License.
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.compute.version>v1-rev169-1.23.0</project.compute.version>
<project.compute.version>v1-rev171-1.23.0</project.compute.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down
17 changes: 10 additions & 7 deletions dataflow/spanner-io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<systemPropertyVariables>
<spanner.test.instance>default-instance</spanner.test.instance>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -84,13 +94,6 @@
<version>${apache_beam.version}</version>
</dependency>

<!-- Google Cloud -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner</artifactId>
<version>0.34.0-beta</version>
</dependency>

<!-- Misc -->
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright 2018 Google Inc.
*
* 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.example.dataflow;

import com.google.cloud.spanner.Struct;
import org.apache.beam.sdk.transforms.DoFn;
import org.apache.beam.sdk.transforms.PTransform;
import org.apache.beam.sdk.transforms.ParDo;
import org.apache.beam.sdk.values.PCollection;

/**
* Estimates the size of the {@code Struct}.
*/
public class EstimateSize extends PTransform<PCollection<Struct>, PCollection<Long>> {

public static EstimateSize create() {
return new EstimateSize();
}

private EstimateSize() {
}

@Override
public PCollection<Long> expand(PCollection<Struct> input) {
return input.apply(ParDo.of(new EstimateStructSizeFn()));
}

/**
* Estimates the size of a Spanner row. For simplicity, arrays and structs aren't supported.
*/
public static class EstimateStructSizeFn extends DoFn<Struct, Long> {

@ProcessElement
public void processElement(ProcessContext c) throws Exception {
Struct row = c.element();
long sum = 0;
for (int i = 0; i < row.getColumnCount(); i++) {
if (row.isNull(i)) {
continue;
}

switch (row.getColumnType(i).getCode()) {
case BOOL:
sum += 1;
break;
case INT64:
case FLOAT64:
sum += 8;
break;
case TIMESTAMP:
case DATE:
sum += 12;
break;
case BYTES:
sum += row.getBytes(i).length();
break;
case STRING:
sum += row.getString(i).length();
break;
case ARRAY:
throw new IllegalArgumentException("Arrays are not supported :(");
case STRUCT:
throw new IllegalArgumentException("Structs are not supported :(");
default:
throw new IllegalArgumentException("Unsupported type :(");
}
}
c.output(sum);
}
}

}
Loading

0 comments on commit bce40a5

Please sign in to comment.