Java Code Examples for com.google.cloud.spanner.KeySet#newBuilder()
The following examples show how to use
com.google.cloud.spanner.KeySet#newBuilder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XATransaction.java From spanner-jdbc with MIT License | 6 votes |
private static void cleanupPrepared(TransactionContext transaction, String xid) { boolean foundRecords = false; KeySet.Builder builder = KeySet.newBuilder(); try (ResultSet rs = transaction.executeQuery(getPreparedMutationsStatement(xid))) { while (rs.next()) { foundRecords = true; long number = rs.getLong(0); builder.addKey(Key.of(xid, number)); } } if (foundRecords) { Mutation delete = Mutation.delete(CloudSpannerXAConnection.XA_PREPARED_MUTATIONS_TABLE, builder.build()); transaction.buffer(delete); } }
Example 2
Source File: SimpleSpannerRepository.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
@Override public Iterable<T> findAllById(Iterable<ID> ids) { KeySet.Builder builder = KeySet.newBuilder(); for (Object id : ids) { builder.addKey(toKey(id)); } return this.spannerTemplate.read(this.entityType, builder.build()); }
Example 3
Source File: SpannerMutationFactoryImpl.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
@Override public <T> Mutation delete(Class<T> entityClass, Iterable<? extends T> entities) { SpannerPersistentEntity<?> persistentEntity = this.spannerMappingContext .getPersistentEntity(entityClass); KeySet.Builder builder = KeySet.newBuilder(); for (T entity : entities) { PersistentPropertyAccessor accessor = persistentEntity .getPropertyAccessor(entity); PersistentProperty idProperty = persistentEntity.getIdProperty(); Key value = (Key) accessor.getProperty(idProperty); builder.addKey(value); } return delete(entityClass, builder.build()); }
Example 4
Source File: SpannerIOWriteTest.java From beam with Apache License 2.0 | 5 votes |
private static Mutation del(Long... keys) { KeySet.Builder builder = KeySet.newBuilder(); for (Long key : keys) { builder.addKey(Key.of(key)); } return Mutation.delete("test", builder.build()); }