org.kitesdk.data
Class ColumnMapping.Builder

java.lang.Object
  extended by org.kitesdk.data.ColumnMapping.Builder
Enclosing class:
ColumnMapping

public static class ColumnMapping.Builder
extends Object

A fluent builder to aid in constructing a ColumnMapping.

Since:
0.14.0

Constructor Summary
ColumnMapping.Builder()
           
 
Method Summary
 ColumnMapping build()
          Builds and returns a ColumnMapping from the fields mappings added to this builder.
 ColumnMapping.Builder column(String name, String family, String qualifier)
          Adds a mapping to store the record field name in a column using the family and qualifier.
 ColumnMapping.Builder counter(String name, String family, String qualifier)
          Adds a counter mapping to store record field name in a column using the family and qualifier.
 ColumnMapping.Builder fieldMapping(FieldMapping fieldMapping)
          Adds a FieldMapping.
 ColumnMapping.Builder fieldMappings(Collection<FieldMapping> fieldMappings)
          Adds each FieldMapping from a collection.
 ColumnMapping.Builder key(String name)
          Adds a mapping to store the record field name in the record key.
 ColumnMapping.Builder keyAsColumn(String name, String family)
          Adds a key-as-column mapping to store the record field name in the given family, using its keys or fields as column qualifiers.
 ColumnMapping.Builder keyAsColumn(String name, String family, String qualifierPrefix)
          Adds a key-as-column mapping to store the record field name in the given family, using column qualifiers built from its keys or field names appended to the qualifierPrefix.
 ColumnMapping.Builder occ(String name)
          Adds an OCC version mapping for the record field name.
 ColumnMapping.Builder version(String name)
          Adds an OCC version mapping for the record field name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnMapping.Builder

public ColumnMapping.Builder()
Method Detail

key

public ColumnMapping.Builder key(String name)
Adds a mapping to store the record field name in the record key. The underlying dataset's PartitionStrategy must have an identity partitioner for the record field name so that the value can be recovered.

Parameters:
name - The name of a record field
Returns:
This Builder for method chaining

column

public ColumnMapping.Builder column(String name,
                                    String family,
                                    String qualifier)
Adds a mapping to store the record field name in a column using the family and qualifier.

Parameters:
name - The name of a record field
family - The column family for storing the record field value
qualifier - The column qualifier for storing the record field value
Returns:
This Builder for method chaining

keyAsColumn

public ColumnMapping.Builder keyAsColumn(String name,
                                         String family)
Adds a key-as-column mapping to store the record field name in the given family, using its keys or fields as column qualifiers. The record field must be a map or a record.

Parameters:
name - The name of a record field
family - The column family for storing the map or record values
Returns:
This Builder for method chaining

keyAsColumn

public ColumnMapping.Builder keyAsColumn(String name,
                                         String family,
                                         String qualifierPrefix)
Adds a key-as-column mapping to store the record field name in the given family, using column qualifiers built from its keys or field names appended to the qualifierPrefix. The record field must be a map or a record.

Parameters:
name - The name of a record field
family - The column family for storing the map or record values
qualifierPrefix - A prefix to add when building column qualifiers
Returns:
This Builder for method chaining

counter

public ColumnMapping.Builder counter(String name,
                                     String family,
                                     String qualifier)
Adds a counter mapping to store record field name in a column using the family and qualifier. The record field can be updated atomically using RandomAccessDataset.increment(Key, String, long) The record field must be an int or a long. Counters cannot be used in combination with optimistic concurrency (OCC).

Parameters:
name - The name of a record field
family - The column family for storing the record counter value
qualifier - The column qualifier for storing the record field value
Returns:
This Builder for method chaining

occ

public ColumnMapping.Builder occ(String name)
Adds an OCC version mapping for the record field name. The record field will contain the current version number of the record. Using this mapping enables optimistic concurrency (OCC), where the underlying RandomAccessDataset will only persist changes to a record if it has not changed by another process. The record field must be an int or a long. Optimistic concurrency (OCC) cannot be used in combination with counters.

Parameters:
name - The name of a record field to use for an OCC version
Returns:
This Builder for method chaining

version

public ColumnMapping.Builder version(String name)
Adds an OCC version mapping for the record field name. The record field will contain the current version number of the record. Using this mapping enables optimistic concurrency (OCC), where the underlying RandomAccessDataset will only persist changes to a record if it has not changed by another process. The record field must be an int or a long. Optimistic concurrency (OCC) cannot be used in combination with counters.

Parameters:
name - The name of a record field to use for an OCC version
Returns:
This Builder for method chaining

fieldMapping

public ColumnMapping.Builder fieldMapping(FieldMapping fieldMapping)
Adds a FieldMapping.

Parameters:
fieldMapping - A FieldMapping
Returns:
This Builder for method chaining

fieldMappings

public ColumnMapping.Builder fieldMappings(Collection<FieldMapping> fieldMappings)
Adds each FieldMapping from a collection.

Parameters:
fieldMappings - A collection of FieldMapping objects
Returns:
This Builder for method chaining

build

public ColumnMapping build()
Builds and returns a ColumnMapping from the fields mappings added to this builder.

Returns:
a ColumnMapping


Copyright © 2013–2014. All rights reserved.