- All Superinterfaces:
org.apache.jena.atlas.lib.Closeable
,Iterable<T>
,org.apache.jena.atlas.lib.Sink<T>
- All Known Implementing Classes:
AbstractDataBag
,DefaultDataBag
,DistinctDataBag
,DistinctDataNet
,SortedDataBag
DataBag provides an Iterator interface, that allows callers to read through the contents. The iterators are aware of the data spilling. They have to be able to handle reading from files.
The DataBag interface assumes that all data is written before any is read. That is, a DataBag cannot be used as a queue. If data is written after data is read, the results are undefined. This condition is not checked on each add or read, for reasons of speed. Caveat emptor.
DataBags come in several types, default, sorted, and distinct. The type must be chosen up front, there is no way to convert a bag on the fly. Default data bags do not guarantee any particular order of retrieval for the tuples and may contain duplicate tuples. Sorted data bags guarantee that tuples will be retrieved in order, where "in order" is defined either by the default comparator for Tuple or the comparator provided by the caller when the bag was created. Sorted bags may contain duplicates. Distinct bags do not guarantee any particular order of retrieval, but do guarantee that they will not contain duplicate tuples.
Inspired by Apache Pig
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a tuple to the bag.default void
Add contents of an Iterable to the bag.default void
Add contents of an Iterator to the bag.boolean
Find out if the bag is distinct.boolean
isSorted()
Find out if the bag is sorted.long
size()
Get the number of elements in the bag, both in memory and on disk.Methods inherited from interface org.apache.jena.atlas.lib.Closeable
close
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.apache.jena.atlas.lib.Sink
flush, send
-
Method Details
-
size
long size()Get the number of elements in the bag, both in memory and on disk.- Returns:
- number of elements in the bag
-
isSorted
boolean isSorted()Find out if the bag is sorted.- Returns:
- true if this is a sorted data bag, false otherwise.
-
isDistinct
boolean isDistinct()Find out if the bag is distinct.- Returns:
- true if the bag is a distinct bag, false otherwise.
-
add
Add a tuple to the bag.- Parameters:
t
- tuple to add.
-
addAll
Add contents of an Iterable to the bag.- Parameters:
it
- iterable to add contents of.
-
addAll
Add contents of an Iterator to the bag.- Parameters:
it
- iterator to add contents of.
-