操作上の目的で、テーブルを複数の行に分割し、組み合わせるとテーブルを形成できます。これらの各サブセットはテーブルのパーティションです。
パーティション表現
AMO オブジェクトの観点では、パーティション表現には、 Partition との 1 対 1 のマッピング関係があり、他のメイン AMO オブジェクトは必要ありません
AMO でのパーティション
AMO を使用してパーティションを管理する場合は、表形式モデル テーブルを表すメジャー グループを見つけて、そこから作業する必要があります。
次のコード スニペットは、既存の表形式モデル テーブルにパーティションを追加する方法を示しています。
private void AddPartition(
AMO.Cube modelCube
, AMO.DataSource newDatasource
, string mgName
, string newPartitionName
, string partitionSelectStatement
, Boolean processPartition
)
{
mgName = mgName.Trim();
newPartitionName = newPartitionName.Trim();
partitionSelectStatement = partitionSelectStatement.Trim();
//Validate Input
if (string.IsNullOrEmpty(newPartitionName) || string.IsNullOrWhiteSpace(newPartitionName))
{
MessageBox.Show(String.Format("Partition Name cannot be empty or blank"), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (modelCube.MeasureGroups[mgName].Partitions.ContainsName(newPartitionName))
{
MessageBox.Show(String.Format("Partition Name already defined. Duplicated names are not allowed"), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(partitionSelectStatement) || string.IsNullOrWhiteSpace(partitionSelectStatement))
{
MessageBox.Show(String.Format("Select statement cannot be empty or blank"), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//Input validated
string partitionID = newPartitionName; //Using partition name as the ID
AMO.Partition currentPartition = new AMO.Partition(partitionID, partitionID);
currentPartition.StorageMode = AMO.StorageMode.InMemory;
currentPartition.ProcessingMode = AMO.ProcessingMode.Regular;
currentPartition.Source = new AMO.QueryBinding(newDatasource.ID, partitionSelectStatement);
modelCube.MeasureGroups[mgName].Partitions.Add(currentPartition);
try
{
modelCube.Update(AMO.UpdateOptions.ExpandFull, AMO.UpdateMode.UpdateOrCreate);
if (processPartition)
{
modelCube.MeasureGroups[mgName].Partitions[partitionID].Process(AMO.ProcessType.ProcessFull);
MessageBox.Show(String.Format("Partition successfully processed."), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (AMO.AmoException amoXp)
{
MessageBox.Show(String.Format("AMO exception accessing the server.\nError message: {0}", amoXp.Message), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
catch (Exception)
{
throw;
}
}
AMO2Tabular サンプル
ただし、AMO を使用してパーティション表現を作成および操作する方法を理解するには、AMO から表形式へのサンプルのソース コードを参照してください。 サンプルは Codeplex で入手できます。 コードに関する重要な注意事項: コードは、ここで説明する論理的な概念のサポートとしてのみ提供され、運用環境では使用しないでください。また、教育的な目的以外の目的で使用してはなりません。