Skip to content

Commit 7c46b40

Browse files
committed
Fix mvn lint formatting
1 parent cf1bb19 commit 7c46b40

File tree

5 files changed

+49
-40
lines changed

5 files changed

+49
-40
lines changed

samples/snippets/src/main/java/com/example/datastore/vectorsearch/StoreVectors.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,22 @@ public static void invoke() throws Exception {
3434

3535
// Prepares the entity with a vector embedding
3636
Entity entity =
37-
Entity.newBuilder(key)
38-
.set("name", "Kahawa")
39-
.set("description", "Information about the Kahawa coffee beans.")
40-
.set("roast", "dark")
41-
.set("embedding_field", VectorValue.newBuilder(1.0, 7.0, 11.1).build())
42-
.build();
37+
Entity.newBuilder(key)
38+
.set("name", "Kahawa")
39+
.set("description", "Information about the Kahawa coffee beans.")
40+
.set("roast", "dark")
41+
.set("embedding_field", VectorValue.newBuilder(1.0, 7.0, 11.1).build())
42+
.build();
4343

4444
// Saves the entity
4545
datastore.put(entity);
4646
System.out.printf("Saved %s: %s%n", entity.getKey().getName(), entity.getString("description"));
4747

4848
// Retrieve entity
4949
Entity retrieved = datastore.get(key);
50-
System.out.printf("Retrieved %s with embedding_field: %s%n", key.getName(), retrieved.getVector("embedding_field"));
50+
System.out.printf("Retrieved %s with embedding_field: %s%n",
51+
key.getName(),
52+
retrieved.getVector("embedding_field"));
5153
}
5254
}
5355
// [END datastore_store_vectors]

samples/snippets/src/main/java/com/example/datastore/vectorsearch/VectorSearchDistanceResultPropertyProjection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public static void invoke() throws Exception {
5252

5353
while (results.hasNext()) {
5454
ProjectionEntity entity = results.next();
55-
System.out.printf("Entity: %s, Distance: %s%n", entity.getKey().getName(), entity.getDouble("vector_distance"));
55+
System.out.printf("Entity: %s, Distance: %s%n",
56+
entity.getKey().getName(),
57+
entity.getDouble("vector_distance"));
5658
}
5759
}
5860
}

samples/snippets/src/main/java/com/example/datastore/vectorsearch/VectorSearchLargeResponse.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818

1919
// [START datastore_vector_search_large_response]
2020

21-
import com.google.common.collect.ImmutableList;
22-
import com.google.common.collect.Iterators;
23-
import java.util.Iterator;
2421
import com.google.cloud.datastore.Datastore;
2522
import com.google.cloud.datastore.DatastoreOptions;
2623
import com.google.cloud.datastore.Entity;
@@ -31,6 +28,9 @@
3128
import com.google.cloud.datastore.QueryResults;
3229
import com.google.cloud.datastore.StructuredQuery;
3330
import com.google.cloud.datastore.VectorValue;
31+
import com.google.common.collect.ImmutableList;
32+
import com.google.common.collect.Iterators;
33+
import java.util.Iterator;
3434

3535
public class VectorSearchLargeResponse {
3636
public static void invoke() throws Exception {
@@ -51,7 +51,8 @@ public static void invoke() throws Exception {
5151

5252
QueryResults<ProjectionEntity> keyOnlyResults = datastore.run(keyOnlyVectorQuery);
5353
ProjectionEntity[] keyEntities = Iterators.toArray(keyOnlyResults, ProjectionEntity.class);
54-
Key[] keys = ImmutableList.copyOf(keyEntities).stream().map(e -> e.getKey()).toArray(Key[]::new);
54+
Key[] keys =
55+
ImmutableList.copyOf(keyEntities).stream().map(e -> e.getKey()).toArray(Key[]::new);
5556
System.out.printf("Key query result size: %s%n", keys.length);
5657

5758
// Lookup the full entities using the result of the keys only query.
@@ -60,9 +61,11 @@ public static void invoke() throws Exception {
6061
System.out.printf("Entity query result size: %s%n", entitiesArray.length);
6162

6263
// Combine and print results
63-
for (int i = 0; i < keyEntities.length; i++)
64-
{
65-
System.out.printf("Entity: %s, Distance: %s, Roast: %s%n", keyEntities[i].getKey().getName(), keyEntities[i].getDouble("vector_distance"), entitiesArray[i].getString("roast"));
64+
for (int i = 0; i < keyEntities.length; i++) {
65+
System.out.printf("Entity: %s, Distance: %s, Roast: %s%n",
66+
keyEntities[i].getKey().getName(),
67+
keyEntities[i].getDouble("vector_distance"),
68+
entitiesArray[i].getString("roast"));
6669
}
6770
}
6871
}

samples/snippets/src/main/java/com/example/datastore/vectorsearch/VectorSearchPrefilter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public static void invoke() throws Exception {
5353

5454
while (results.hasNext()) {
5555
Entity entity = results.next();
56-
System.out.printf("Entity: %s, Distance: %s%n", entity.getKey().getName(), entity.getDouble("vector_distance"));
56+
System.out.printf("Entity: %s, Distance: %s%n",
57+
entity.getKey().getName(),
58+
entity.getDouble("vector_distance"));
5759
}
5860
}
5961
}

samples/snippets/src/test/java/com/example/datastore/vectorsearch/VectorSearchSampleIT.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.example.datastore.vectorsearch;
1718

18-
import com.google.cloud.datastore.*;
19+
import com.google.cloud.datastore.Datastore;
20+
import com.google.cloud.datastore.DatastoreOptions;
21+
import com.google.cloud.datastore.Entity;
22+
import com.google.cloud.datastore.Key;
23+
import com.google.cloud.datastore.VectorValue;
1924
import com.rule.SystemsOutRule;
2025
import org.junit.After;
2126
import org.junit.Before;
2227
import org.junit.Rule;
2328
import org.junit.Test;
2429
import org.junit.runner.RunWith;
2530
import org.junit.runners.JUnit4;
26-
import com.google.cloud.datastore.Datastore;
27-
import com.google.cloud.datastore.DatastoreOptions;
2831

2932
@RunWith(JUnit4.class)
3033
@SuppressWarnings("checkstyle:abbreviationaswordinname")
@@ -43,31 +46,28 @@ public void setUp() {
4346
//DatastoreOptions.getDefaultHttpTransportOptions()
4447
coffeeBeanKey1 = datastore.newKeyFactory().setKind("CoffeeBean").newKey("Kahawa");
4548
// Prepares the entity with a vector embedding
46-
Entity entity1 =
47-
Entity.newBuilder(coffeeBeanKey1)
48-
.set("name", "Arabica")
49-
.set("description", "Information about the Arabica coffee beans.")
50-
.set("roast", "dark")
51-
.set("embedding_field", VectorValue.newBuilder(1.0, 7.0, 11.1).build())
52-
.build();
49+
Entity entity1 = Entity.newBuilder(coffeeBeanKey1)
50+
.set("name", "Arabica")
51+
.set("description", "Information about the Arabica coffee beans.")
52+
.set("roast", "dark")
53+
.set("embedding_field", VectorValue.newBuilder(1.0, 7.0, 11.1).build())
54+
.build();
5355

5456
coffeeBeanKey2 = datastore.newKeyFactory().setKind("CoffeeBean").newKey("Robusta");
55-
Entity entity2 =
56-
Entity.newBuilder(coffeeBeanKey2)
57-
.set("name", "Robusta")
58-
.set("description", "Information about the Robusta coffee beans.")
59-
.set("roast", "light")
60-
.set("embedding_field", VectorValue.newBuilder(1.0, 9.0, 11.1).build())
61-
.build();
57+
Entity entity2 = Entity.newBuilder(coffeeBeanKey2)
58+
.set("name", "Robusta")
59+
.set("description", "Information about the Robusta coffee beans.")
60+
.set("roast", "light")
61+
.set("embedding_field", VectorValue.newBuilder(1.0, 9.0, 11.1).build())
62+
.build();
6263

6364
coffeeBeanKey3 = datastore.newKeyFactory().setKind("CoffeeBean").newKey("Excelsa");
64-
Entity entity3 =
65-
Entity.newBuilder(coffeeBeanKey3)
66-
.set("name", "Excelsa")
67-
.set("description", "Information about the Excelsa coffee beans.")
68-
.set("roast", "dark")
69-
.set("embedding_field", VectorValue.newBuilder(4.0, 9.0, 11.1).build())
70-
.build();
65+
Entity entity3 = Entity.newBuilder(coffeeBeanKey3)
66+
.set("name", "Excelsa")
67+
.set("description", "Information about the Excelsa coffee beans.")
68+
.set("roast", "dark")
69+
.set("embedding_field", VectorValue.newBuilder(4.0, 9.0, 11.1).build())
70+
.build();
7171

7272
datastore.put(entity1);
7373
datastore.put(entity2);

0 commit comments

Comments
 (0)