本文整理匯總了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));
}