本文整理汇总了Java中com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata类的典型用法代码示例。如果您正苦于以下问题:Java UpdateDatabaseDdlMetadata类的具体用法?Java UpdateDatabaseDdlMetadata怎么用?Java UpdateDatabaseDdlMetadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UpdateDatabaseDdlMetadata类属于com.google.spanner.admin.database.v1包,在下文中一共展示了UpdateDatabaseDdlMetadata类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mockOperation
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; //导入依赖的package包/类
private Operation<Void, UpdateDatabaseDdlMetadata> mockOperation(boolean error)
{
@SuppressWarnings("unchecked")
Operation<Void, UpdateDatabaseDdlMetadata> op = mock(Operation.class);
when(op.getName()).then(new Returns("TEST_OPERATION"));
when(op.isDone()).then(new Answer<Boolean>()
{
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable
{
return reportDone;
}
});
when(op.reload()).then(new Returns(op));
if (error)
when(op.getResult()).thenThrow(
SpannerExceptionFactory.newSpannerException(ErrorCode.INVALID_ARGUMENT, "Some exception"));
else
when(op.getResult()).then(new Returns(null));
UpdateDatabaseDdlMetadata metadata = UpdateDatabaseDdlMetadata.getDefaultInstance();
when(op.getMetadata()).then(new Returns(metadata));
return op;
}
示例2: DdlOperation
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; //导入依赖的package包/类
private DdlOperation(Timestamp timeStarted, List<String> sql,
Operation<Void, UpdateDatabaseDdlMetadata> operation)
{
this.timeStarted = timeStarted;
this.sql = new ArrayList<>(sql);
this.operation = operation;
}
示例3: executeDDL
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; //导入依赖的package包/类
/**
* Execute one or more DDL-statements on the database and wait for it to
* finish or return after syntax check (when running in async mode). Calling
* this method will also automatically commit the currently running
* transaction.
*
* @param sql
* The DDL-statement(s) to execute
* @return Nothing
* @throws SQLException
* If an error occurs during the execution of the statement.
*/
public Void executeDDL(List<String> sql) throws SQLException
{
if (!getAutoCommit())
commit();
try
{
Operation<Void, UpdateDatabaseDdlMetadata> operation = adminClient.updateDatabaseDdl(database.instance,
database.database, sql, null);
if (asyncDdlOperations)
{
operations.addOperation(sql, operation);
}
else
{
do
{
operation = operation.waitFor();
}
while (!operation.isDone());
}
return operation.getResult();
}
catch (SpannerException e)
{
throw new CloudSpannerSQLException(
"Could not execute DDL statement(s) " + String.join("\n;\n", sql) + ": " + e.getMessage(), e);
}
}
示例4: addMarketingBudgetColumnToAlbums
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; //导入依赖的package包/类
private static void addMarketingBudgetColumnToAlbums(PrintWriter pw) {
Operation<Void, UpdateDatabaseDdlMetadata> op =
SpannerClient.getDatabaseAdminClient()
.updateDatabaseDdl(
SpannerClient.getInstanceId(),
SpannerClient.getDatabaseId(),
Arrays.asList("ALTER TABLE Albums ADD COLUMN MarketingBudget INT64"),
null);
op.waitFor();
}
示例5: addIndex
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; //导入依赖的package包/类
private static void addIndex() {
Operation<Void, UpdateDatabaseDdlMetadata> op =
SpannerClient.getDatabaseAdminClient()
.updateDatabaseDdl(
SpannerClient.getInstanceId(),
SpannerClient.getDatabaseId(),
Arrays.asList("CREATE INDEX AlbumsByAlbumTitle ON Albums(AlbumTitle)"),
null);
op.waitFor();
}
示例6: addStoringIndex
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; //导入依赖的package包/类
private static void addStoringIndex() {
Operation<Void, UpdateDatabaseDdlMetadata> op =
SpannerClient.getDatabaseAdminClient()
.updateDatabaseDdl(
SpannerClient.getInstanceId(),
SpannerClient.getDatabaseId(),
Arrays.asList(
"CREATE INDEX AlbumsByAlbumTitle2 "
+ "ON Albums(AlbumTitle) STORING (MarketingBudget)"),
null);
op.waitFor();
}
示例7: addOperation
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; //导入依赖的package包/类
void addOperation(List<String> sql, Operation<Void, UpdateDatabaseDdlMetadata> operation)
{
operations.add(new DdlOperation(Timestamp.now(), sql, operation));
}