Class AssetPagingIterator
- java.lang.Object
-
- org.odpi.openmetadata.frameworks.connectors.properties.AssetPropertyElementBase
-
- org.odpi.openmetadata.frameworks.connectors.properties.AssetPropertyBase
-
- org.odpi.openmetadata.frameworks.connectors.properties.AssetPagingIterator
-
- All Implemented Interfaces:
Serializable,Iterator<AssetPropertyBase>
public class AssetPagingIterator extends AssetPropertyBase implements Iterator<AssetPropertyBase>
PagingIterator supports an iterator over a list of objects that extend AssetPropertyBase. Callers can use it to step through the list just once. If they want to parse the list again, they could use the copy/clone constructor to create a new iterator. PagingIterator provides paging support to enable the list in the iterator to be much bigger than can be stored in memory. It maintains pointers for the full list, and a potentially smaller cached list that is used to batch up elements being retrieved from the property (metadata) server. Thus is combines the ability to process very large lists whilst minimising the chatter with the property server. The class uses a number of pointers and counts. Imagine a list of 4000 columns in a table. We can not retrieve all 4000 columns on one call. So we retrieve subsets over a number of REST calls as the caller walks through the full list.- totalElement is 4000 - ie how many elements there are in total.
- maxCacheSize is the maximum elements we can retrieve in one call
- cachedElementList.size() is how many elements we have in memory at this time.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<AssetPropertyBase>cachedElementListprotected intcachedElementPointerprotected intcachedElementStartprotected AssetPropertyIteratorBaseiteratorprotected intmaxCacheSizeprotected inttotalElementCount-
Fields inherited from class org.odpi.openmetadata.frameworks.connectors.properties.AssetPropertyBase
parentAsset
-
-
Constructor Summary
Constructors Constructor Description AssetPagingIterator(AssetDescriptor parentAsset, AssetPropertyIteratorBase iterator, int totalElementCount, int maxCacheSize)Typical Constructor creates an iterator with the supplied list of comments.AssetPagingIterator(AssetDescriptor parentAsset, AssetPropertyIteratorBase iterator, AssetPagingIterator templateIterator)Copy/clone constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetElementCount()Return the number of elements in the list.booleanhasNext()The iterator can only be used once to step through the elements.AssetPropertyBasenext()Return the next element in the listvoidremove()Remove the current element in the iterator.StringtoString()Standard toString method.-
Methods inherited from class org.odpi.openmetadata.frameworks.connectors.properties.AssetPropertyBase
equals, getParentAsset, getParentAssetName, getParentAssetTypeName, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Field Detail
-
maxCacheSize
protected int maxCacheSize
-
totalElementCount
protected int totalElementCount
-
cachedElementStart
protected int cachedElementStart
-
cachedElementList
protected List<AssetPropertyBase> cachedElementList
-
cachedElementPointer
protected int cachedElementPointer
-
iterator
protected AssetPropertyIteratorBase iterator
-
-
Constructor Detail
-
AssetPagingIterator
public AssetPagingIterator(AssetDescriptor parentAsset, AssetPropertyIteratorBase iterator, int totalElementCount, int maxCacheSize)
Typical Constructor creates an iterator with the supplied list of comments.- Parameters:
parentAsset- descriptor of parent asset.iterator- type-specific iterator that wraps this paging iterator.totalElementCount- the total number of elements to process. A negative value is converted to 0.maxCacheSize- maximum number of elements that should be retrieved from the property server and cached in the element list at any one time. If a number less than one is supplied, 1 is used.
-
AssetPagingIterator
public AssetPagingIterator(AssetDescriptor parentAsset, AssetPropertyIteratorBase iterator, AssetPagingIterator templateIterator)
Copy/clone constructor. Used to reset iterator element pointer to 0;- Parameters:
parentAsset- descriptor of parent assetiterator- type-specific iterator that wraps this paging iterator.templateIterator- template to copy; null to create an empty iterator
-
-
Method Detail
-
hasNext
public boolean hasNext()
The iterator can only be used once to step through the elements. This method returns a boolean to indicate if it has got to the end of the list yet.- Specified by:
hasNextin interfaceIterator<AssetPropertyBase>- Returns:
- boolean indicating whether there are more elements.
-
next
public AssetPropertyBase next()
Return the next element in the list- Specified by:
nextin interfaceIterator<AssetPropertyBase>- Returns:
- AssetPropertyBase next element.
- Throws:
OCFRuntimeException- if there are no more elements in the list or there are problems retrieving elements from the property (metadata) server.
-
getElementCount
public int getElementCount()
Return the number of elements in the list.- Returns:
- elementCount
-
remove
public void remove()
Remove the current element in the iterator. This call is not supported and results in an exception- Specified by:
removein interfaceIterator<AssetPropertyBase>
-
-