Package com.atlan.util
Class AssetBatch
java.lang.Object
com.atlan.util.AssetBatch
- All Implemented Interfaces:
Closeable
,AutoCloseable
Utility class for managing bulk updates in batches.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Class to uniquely identify an asset by its type and qualifiedName.static enum
static final class
Internal class to capture batch failures. -
Constructor Summary
ConstructorDescriptionAssetBatch
(AtlanClient client, int maxSize) Create a new batch of assets to be bulk-saved.AssetBatch
(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling) Create a new batch of assets to be bulk-saved.AssetBatch
(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures) Create a new batch of assets to be bulk-saved.AssetBatch
(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly) Create a new batch of assets to be bulk-saved.AssetBatch
(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly, boolean track) Create a new batch of assets to be bulk-saved.AssetBatch
(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly, boolean track, boolean caseInsensitive) Create a new batch of assets to be bulk-saved.AssetBatch
(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly, boolean track, boolean caseInsensitive, AssetCreationHandling creationHandling) Create a new batch of assets to be bulk-saved.AssetBatch
(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly, boolean track, boolean caseInsensitive, AssetCreationHandling creationHandling, boolean tableViewAgnostic) Create a new batch of assets to be bulk-saved.AssetBatch
(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly, boolean track, boolean caseInsensitive, AssetCreationHandling creationHandling, boolean tableViewAgnostic, OffHeapAssetCache created, OffHeapAssetCache updated, OffHeapAssetCache restored, OffHeapAssetCache skipped) Create a new batch of assets to be bulk-saved. -
Method Summary
Modifier and TypeMethodDescriptionAdd an asset to the batch to be processed.void
close()
Close the batch by freeing up any resources it has used.flush()
Flush any remaining assets in the batch.Assets that were created (minimal info only).Batches that failed to be committed (only populated when captureFailures is set to true).Number of assets that were created (no details, just a count).Number of assets that were potentially restored from being archived, or otherwise touched without actually being updated (no details, just a count).Number of assets that were skipped during processing (no details, just a count).Number of assets that were updated (no details, just a count).Map from placeholder GUID to resolved (actual) GUID, for all assets that were processed through the batch.Map from all-lowercase qualifiedName (case-insensitive) to case-sensitive qualifiedName, for all assets that were processed through the batch.Assets that were potentially restored from being archived, or otherwise touched without actually being updated (minimal info only).Assets that were skipped, when updateOnly is requested and the asset does not exist in Atlan.Assets that were updated (minimal info only).
-
Constructor Details
-
AssetBatch
Create a new batch of assets to be bulk-saved.- Parameters:
client
- connectivity to AtlanmaxSize
- maximum size of each batch that should be processed (per API call)
-
AssetBatch
public AssetBatch(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling) Create a new batch of assets to be bulk-saved.- Parameters:
client
- connectivity to AtlanmaxSize
- maximum size of each batch that should be processed (per API call)replaceAtlanTags
- if true, all Atlan tags on an existing asset will be overwritten; if false, all Atlan tags will be ignoredcustomMetadataHandling
- how to handle custom metadata (ignore it, replace it (wiping out anything pre-existing), or merge it)
-
AssetBatch
public AssetBatch(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures) Create a new batch of assets to be bulk-saved.- Parameters:
client
- connectivity to AtlanmaxSize
- maximum size of each batch that should be processed (per API call)replaceAtlanTags
- if true, all Atlan tags on an existing asset will be overwritten; if false, all Atlan tags will be ignoredcustomMetadataHandling
- how to handle custom metadata (ignore it, replace it (wiping out anything pre-existing), or merge it)captureFailures
- when true, any failed batches will be captured and retained rather than exceptions being raised (for large amounts of processing this could cause memory issues!)
-
AssetBatch
public AssetBatch(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly) Create a new batch of assets to be bulk-saved.- Parameters:
client
- connectivity to AtlanmaxSize
- maximum size of each batch that should be processed (per API call)replaceAtlanTags
- if true, all Atlan tags on an existing asset will be overwritten; if false, all Atlan tags will be ignoredcustomMetadataHandling
- how to handle custom metadata (ignore it, replace it (wiping out anything pre-existing), or merge it)captureFailures
- when true, any failed batches will be captured and retained rather than exceptions being raised (for large amounts of processing this could cause memory issues!)updateOnly
- when true, only attempt to update existing assets and do not create any assets (note: this will incur a performance penalty)
-
AssetBatch
public AssetBatch(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly, boolean track) Create a new batch of assets to be bulk-saved.- Parameters:
client
- connectivity to AtlanmaxSize
- maximum size of each batch that should be processed (per API call)replaceAtlanTags
- if true, all Atlan tags on an existing asset will be overwritten; if false, all Atlan tags will be ignoredcustomMetadataHandling
- how to handle custom metadata (ignore it, replace it (wiping out anything pre-existing), or merge it)captureFailures
- when true, any failed batches will be captured and retained rather than exceptions being raised (for large amounts of processing this could cause memory issues!)updateOnly
- when true, only attempt to update existing assets and do not create any assets (note: this will incur a performance penalty)track
- when false, details about each created and updated asset will no longer be tracked (only an overall count of each) -- useful if you intend to send close to (or more than) 1 million assets through a batch
-
AssetBatch
public AssetBatch(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly, boolean track, boolean caseInsensitive) Create a new batch of assets to be bulk-saved.- Parameters:
client
- connectivity to AtlanmaxSize
- maximum size of each batch that should be processed (per API call)replaceAtlanTags
- if true, all Atlan tags on an existing asset will be overwritten; if false, all Atlan tags will be ignoredcustomMetadataHandling
- how to handle custom metadata (ignore it, replace it (wiping out anything pre-existing), or merge it)captureFailures
- when true, any failed batches will be captured and retained rather than exceptions being raised (for large amounts of processing this could cause memory issues!)updateOnly
- when true, only attempt to update existing assets and do not create any assets (note: this will incur a performance penalty)track
- when false, details about each created and updated asset will no longer be tracked (only an overall count of each) -- useful if you intend to send close to (or more than) 1 million assets through a batchcaseInsensitive
- (only applies when updateOnly is true) when matching assets, search for their qualifiedName in a case-insensitive way
-
AssetBatch
public AssetBatch(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly, boolean track, boolean caseInsensitive, AssetCreationHandling creationHandling) Create a new batch of assets to be bulk-saved.- Parameters:
client
- connectivity to AtlanmaxSize
- maximum size of each batch that should be processed (per API call)replaceAtlanTags
- if true, all Atlan tags on an existing asset will be overwritten; if false, all Atlan tags will be ignoredcustomMetadataHandling
- how to handle custom metadata (ignore it, replace it (wiping out anything pre-existing), or merge it)captureFailures
- when true, any failed batches will be captured and retained rather than exceptions being raised (for large amounts of processing this could cause memory issues!)updateOnly
- when true, only attempt to update existing assets and do not create any assets (note: this will incur a performance penalty)track
- when false, details about each created and updated asset will no longer be tracked (only an overall count of each) -- useful if you intend to send close to (or more than) 1 million assets through a batchcaseInsensitive
- (only applies when updateOnly is true) when matching assets, search for their qualifiedName in a case-insensitive waycreationHandling
- if assets are to be created, how they should be created (as full assets or only partial assets)
-
AssetBatch
public AssetBatch(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly, boolean track, boolean caseInsensitive, AssetCreationHandling creationHandling, boolean tableViewAgnostic) Create a new batch of assets to be bulk-saved.- Parameters:
client
- connectivity to AtlanmaxSize
- maximum size of each batch that should be processed (per API call)replaceAtlanTags
- if true, all Atlan tags on an existing asset will be overwritten; if false, all Atlan tags will be ignoredcustomMetadataHandling
- how to handle custom metadata (ignore it, replace it (wiping out anything pre-existing), or merge it)captureFailures
- when true, any failed batches will be captured and retained rather than exceptions being raised (for large amounts of processing this could cause memory issues!)updateOnly
- when true, only attempt to update existing assets and do not create any assets (note: this will incur a performance penalty)track
- when false, details about each created and updated asset will no longer be tracked (only an overall count of each) -- useful if you intend to send close to (or more than) 1 million assets through a batchcaseInsensitive
- (only applies when updateOnly is true) when matching assets, search for their qualifiedName in a case-insensitive waycreationHandling
- if assets are to be created, how they should be created (as full assets or only partial assets)tableViewAgnostic
- if true, tables and views will be treated interchangeably (an asset in the batch marked as a table will attempt to match a view if not found as a table, and vice versa)
-
AssetBatch
public AssetBatch(AtlanClient client, int maxSize, boolean replaceAtlanTags, AssetBatch.CustomMetadataHandling customMetadataHandling, boolean captureFailures, boolean updateOnly, boolean track, boolean caseInsensitive, AssetCreationHandling creationHandling, boolean tableViewAgnostic, OffHeapAssetCache created, OffHeapAssetCache updated, OffHeapAssetCache restored, OffHeapAssetCache skipped) Create a new batch of assets to be bulk-saved.- Parameters:
client
- connectivity to AtlanmaxSize
- maximum size of each batch that should be processed (per API call)replaceAtlanTags
- if true, all Atlan tags on an existing asset will be overwritten; if false, all Atlan tags will be ignoredcustomMetadataHandling
- how to handle custom metadata (ignore it, replace it (wiping out anything pre-existing), or merge it)captureFailures
- when true, any failed batches will be captured and retained rather than exceptions being raised (for large amounts of processing this could cause memory issues!)updateOnly
- when true, only attempt to update existing assets and do not create any assets (note: this will incur a performance penalty)track
- when false, details about each created and updated asset will no longer be tracked (only an overall count of each) -- useful if you intend to send close to (or more than) 1 million assets through a batchcaseInsensitive
- (only applies when updateOnly is true) when matching assets, search for their qualifiedName in a case-insensitive waycreationHandling
- if assets are to be created, how they should be created (as full assets or only partial assets)tableViewAgnostic
- if true, tables and views will be treated interchangeably (an asset in the batch marked as a table will attempt to match a view if not found as a table, and vice versa)created
- off-heap asset cache tracking assets that have been createdupdated
- off-heap asset cache tracking assets that have been updatedrestored
- off-heap asset cache tracking assets that have been restoredskipped
- off-heap asset cache tracking assets that have been skipped
-
-
Method Details
-
add
Add an asset to the batch to be processed.- Parameters:
single
- the asset to add to a batch- Returns:
- the assets that were created or updated in this batch, or null if the batch is still queued
- Throws:
AtlanException
- on any problems adding the asset to or processing the batch
-
close
Close the batch by freeing up any resources it has used. Note: this will clear any internal caches of results, so only call this after you have processed those!- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- on any problems freeing up resources
-
flush
Flush any remaining assets in the batch.- Returns:
- the mutation response from the queued batch of assets that were flushed
- Throws:
AtlanException
- on any problems flushing (submitting) the batch
-
getNumCreated
Number of assets that were created (no details, just a count). -
getNumUpdated
Number of assets that were updated (no details, just a count). -
getNumRestored
Number of assets that were potentially restored from being archived, or otherwise touched without actually being updated (no details, just a count). -
getNumSkipped
Number of assets that were skipped during processing (no details, just a count). -
getCreated
Assets that were created (minimal info only). -
getUpdated
Assets that were updated (minimal info only). -
getRestored
Assets that were potentially restored from being archived, or otherwise touched without actually being updated (minimal info only). -
getFailures
Batches that failed to be committed (only populated when captureFailures is set to true). -
getSkipped
Assets that were skipped, when updateOnly is requested and the asset does not exist in Atlan. -
getResolvedGuids
Map from placeholder GUID to resolved (actual) GUID, for all assets that were processed through the batch. -
getResolvedQualifiedNames
Map from all-lowercase qualifiedName (case-insensitive) to case-sensitive qualifiedName, for all assets that were processed through the batch. Note: This is only produced when caseInsensitive is true, otherwise it will be empty.
-