browse_next
ノード数がサーバー側の一ページあたりの制限(基盤層での一回のリクエストあたり最大1000件)を超えた場合、サーバーはBrowseResult内に空ではない continuation_point (ページ送りトークン)を返します。 を使用して、次の browse_next ページを取得します。
事前学習
- continuation_point を取得するには、必ず browse_with_paging, 普通 browse 破棄される CP (Referencesのみを取得し、継続トークンは読み込まない)。
署名
def browse_next(self,
continuation_point: Optional[bytes],
release: bool = False) -> BrowsePage: ...
| パラメータ | 説明 |
|---|---|
| continuation_point | 前回 browse_with_paging / browse_next 戻り値の継続トークン (バイト) |
| release | True = ページ送りの継続を中止し、サーバー側がリソースを解放する(参照を返さない) |
BrowsePage フィールド
@dataclass
class BrowsePage:
references: List[Reference] # デフォルトは None。生成後は [] になる。
continuation_point: Optional[bytes] = None # 「None」は、これ以上ページがないことを示します。
ページめくりの完全な例
page = ua.browse_with_paging("ns=2;s=BigFolder")
all_refs = list(page.references)
while page.continuation_point is not None:
page = ua.browse_next(page.continuation_point)
all_refs.extend(page.references)
print(f"Total {len(all_refs)} children")
能動的な解放(サーバーリソースの節約)
サーバー側は各メンテナンス ContinuationPoint 状態ごとにリソースを消費します。途中で処理を続行したくない場合は、明示 release=True 的に解放するように設定してください:
ua.browse_next(page.continuation_point, release=True)
release モードでは、サーバー側は参照を解放するだけで、新たな参照は与えないため、取得されるのは空のリスト BrowsePage.references であり、その値 continuation_point は である None。SDK サーバー側が、解放されていないメモリをいつ回収するのかは分かりません。 CP ―― それはサーバー側の問題です。リソースを確実に解放したい場合は、明示的に行いましょう release=True。
注意
continuation_point不透明ですbytes、 変更・解析はしないでください- ページをめくる際は、必ず直近の
browse_next返されるcontinuation_point続ける (ページをめくるたびに、サーバーから新しいデータが返されます CP) - CP 数量の上限と回収のタイミングはサーバー側で決定され、クライアント側は単にデータを透過的に転送する SDK のみである