E - The type of entities stored in the Dataset underlying this
View.@Immutable public interface View<E>
View is a subset of a Dataset.
A View defines a space of potential storage keys or a partition
space. Views can be created from ranges, partial keys, or the union of other
views.| Modifier and Type | Method and Description |
|---|---|
View<GenericRecord> |
asSchema(Schema schema)
Creates a copy of this
View that projects entities to the given
Schema. |
<T> View<T> |
asType(Class<T> type)
Creates a copy of this
View that reads and writes entities of the
given type class. |
boolean |
deleteAll()
Deletes the entities included in this
View or throws an
UnsupportedOperationException. |
Iterable<PartitionView<E>> |
getCoveringPartitions()
|
Dataset<E> |
getDataset()
Returns the underlying
Dataset for the
View. |
Schema |
getSchema()
Get the schema of entities contained in this
View. |
Class<E> |
getType()
Get the runtime type of entities contained in this
View. |
URI |
getUri()
Get a
URI that identifies this View. |
boolean |
includes(E entity)
|
boolean |
isEmpty()
Check whether this
View contains any records. |
DatasetReader<E> |
newReader()
Get an appropriate
DatasetReader implementation based on this
View of the underlying Dataset implementation. |
DatasetWriter<E> |
newWriter()
Get an appropriate
DatasetWriter implementation based on this
View of the underlying Dataset implementation. |
Dataset<E> getDataset()
Dataset for the
View.DatasetDatasetReader<E> newReader()
DatasetReader implementation based on this
View of the underlying Dataset implementation.
Implementations are free to return different types of readers, depending on
the disposition of the data. For example, a partitioned dataset can use a
different reader than that of a non-partitioned dataset. Clients should not
make any assumptions about the returned implementations: implementations
are free to change their internal structure at any time.DatasetExceptionDatasetWriter<E> newWriter()
DatasetWriter implementation based on this
View of the underlying Dataset implementation.
Implementations are free to return different types of writers depending on
the disposition of the data. For example, a partitioned dataset may use a
different writer than that of a non-partitioned dataset. Clients should not
make any assumptions about the returned implementations: implementations
are free to change their internal structure at any time.DatasetExceptionboolean includes(E entity)
entity - an entity Objectentity is in the partition space of this view.boolean deleteAll()
View or throws an
UnsupportedOperationException.
Implementations are allowed to throw UnsupportedOperationException
if the View could require additional work to delete. For example,
if some but not all of the data in an underlying data file must be removed,
then the implementation is allowed to reject the deletion rather than
copy the remaining records to a new file. Implementations must document
what deletes are supported and under what conditions deletes are rejected.UnsupportedOperationException - if the requested delete cannot be completed by the implementationDatasetIOException - if the requested delete failed because of an IOExceptionClass<E> getType()
View.Schema getSchema()
View.boolean isEmpty()
View contains any records.
Implementations should return once a single record in this view is found.
But this might require scanning through large amounts of data sequentially
to determine if there are any records.true if least one record exists, false otherwiseIterable<PartitionView<E>> getCoveringPartitions()
Iterable of non-overlapping View objects that
partition the underlying Dataset and cover this View.
The returned View objects are implementation-specific, but should
represent reasonable partitions of the underlying Dataset based on
its layout.
The data contained by the union of each View in the
Iterable must be a super-set of this View.
Note that partitions are actual partitions under which data is stored.
Implementations should omit any View that is empty.View that cover this View.IllegalStateException - If the underlying Dataset is not partitioned.UnsupportedOperationException - If the implementation does not support covering partitions.View<GenericRecord> asSchema(Schema schema)
View that projects entities to the given
Schema.
This method always returns a View with type GenericRecord.
schema - an Avro schema to project entities toIncompatibleSchemaException - If the given schema is incompatible with the underlying
dataset.<T> View<T> asType(Class<T> type)
View that reads and writes entities of the
given type class.T - the type of entities that will be read or written by this viewtype - an entity class to useIncompatibleSchemaException - If the given type is incompatible with the underlying
dataset.Copyright © 2013–2015. All rights reserved.