edu.unh.sdb.common
Class FieldIDMapper

java.lang.Object
  extended by edu.unh.sdb.common.FieldIDMapper

public class FieldIDMapper
extends java.lang.Object

This class records an array of field numbers from a component DataSource of a composite DataSource and a corresponding array of field numbers from that composite DataSource. It is meant to be used in the methods datum() and subblock() to facilitate the datum retrieval.


Field Summary
protected  int[] componentFields
          The field numbers from a component DataSource.
protected  int[] compositeFields
          The one-to-one corresponding field numbers from the composite DataSource.
 
Constructor Summary
FieldIDMapper(FieldIDMapper fm, RecordSpec cpsSpec)
          Constructs a FieldIDMapper from a subset of given FieldIDMapper.
FieldIDMapper(int numFields)
          Constructs an identity FieldIDMapper of specified size.
FieldIDMapper(int[] source)
          Constructs a FieldIDMapper from a simple array of ints.
FieldIDMapper(int[] componentFIDs, int[] compositeFIDs)
          Constructs a FieldIDMapper with two parallel arrays.
FieldIDMapper(RecordSpec recSpec)
          Constructs a FieldIDMapper from a RecordSpec which specifies the attributes from a DataSource.
 
Method Summary
 void checkComponentID()
          Check whether the numbers in this.componentFields are distinct.
 void checkCompositeID()
          Check whether the numbers in this.compositeFields are distinct.
 java.lang.Object clone()
          Return a copy of this FieldIDMapper object
 FieldIDMapper combine(FieldIDMapper fmap1, FieldIDMapper fmap2)
          Put two FieldIDMappers together.
static FieldIDMapper createComponentMap(FieldIDMapper src, FieldIDMapper dst)
          Constructs a FieldIDMapper by composing two related FieldIDMappers.
static FieldIDMapper createCrossMap(FieldIDMapper src, FieldIDMapper dst)
          Constructs a FieldIDMapper by composing two related FieldIDMappers.
 boolean equals(java.lang.Object obj)
          Return true if parameter equals this object, false otherwise.
 int[] getComponentFields()
          Returns the field numbers of the component DataSource.
 int[] getCompositeFields()
          Returns the field numbers of the composite DataSource.
 int[] getDestinations()
          Returns the field numbers of the composite DataSource.
 int getMaxCpnID()
          Returns the maximum field number of this.componentFields.
 int getMaxCpsID()
          Returns the maximum field number of this.compositeFields.
 int[] getSources()
          Returns the source identifier array This is the same as getComponentFields(), but FieldIDMapper need not be restricted to Component/Composite mapping
protected static void identity(int[] array)
          Assign identity mapping to the argument array "identity" mapping: 0,1, ...
protected static int[] identityArray(int len)
          Create a integer array of specified length, initialized to the "identity" mapping: 0,1, ...
 boolean isIdentityMapper()
          Returns true if it is an identity FieldIDMapper.
static void main(java.lang.String[] args)
           
 int size()
          Returns the number of fields.
 int toComponent(int compositeIndex)
          return the component index given a composite index.
 RecordSpec toComponent(RecordSpec spec1)
          Returns a RecordSpec mapped to the given RecordSpec whose field numbers could be found in this.compositeFields.
 int toComposite(int componentIndex)
          Returns the composite index given the component index.
 int toDestination(int sourceIndex)
          Returns the destination index given the source index.
 int toSource(int destinationIndex)
          return the source index given a destination index.
 java.lang.String toString()
          to String
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

componentFields

protected int[] componentFields
The field numbers from a component DataSource. The numbers are sorted in ascending order. The numbers should be distinct. Also can be thought of as the "source" of the mapping.


compositeFields

protected int[] compositeFields
The one-to-one corresponding field numbers from the composite DataSource. The numbers should be distinct. Also can be thought of as the "destination" of the mapping.

Constructor Detail

FieldIDMapper

public FieldIDMapper(int[] componentFIDs,
                     int[] compositeFIDs)
Constructs a FieldIDMapper with two parallel arrays. component -> composite source -> destination


FieldIDMapper

public FieldIDMapper(int numFields)
Constructs an identity FieldIDMapper of specified size.


FieldIDMapper

public FieldIDMapper(RecordSpec recSpec)
Constructs a FieldIDMapper from a RecordSpec which specifies the attributes from a DataSource. The RecordSpec entries become the "source" or component fields; the destination (composite fields) is the "identity" mapping: 0, 1, 2, ... This.compositeFields records the index positions of the field numbers in the RecordSpec argument.


FieldIDMapper

public FieldIDMapper(int[] source)
Constructs a FieldIDMapper from a simple array of ints. the int array is the source (components). the destination (composite fields) is the "identity" mapping: 0, 1, 2, ... This.compositeFields records the index positions of the field numbers in the RecordSpec argument.


FieldIDMapper

public FieldIDMapper(FieldIDMapper fm,
                     RecordSpec cpsSpec)
Constructs a FieldIDMapper from a subset of given FieldIDMapper. The given RecordSpec specifies a subset of compositeFields (source) of the given FieldIDMapper.

Method Detail

createCrossMap

public static FieldIDMapper createCrossMap(FieldIDMapper src,
                                           FieldIDMapper dst)
Constructs a FieldIDMapper by composing two related FieldIDMappers. The mapping is between fm1.compositeFields and fm2.componentFields. Useful for AttributeJoinDataSource.


createComponentMap

public static FieldIDMapper createComponentMap(FieldIDMapper src,
                                               FieldIDMapper dst)
Constructs a FieldIDMapper by composing two related FieldIDMappers. The mapping is between src.componentFields and dst.componentFields. Useful for BlockedDataSource.


identityArray

protected static final int[] identityArray(int len)
Create a integer array of specified length, initialized to the "identity" mapping: 0,1, ...


identity

protected static final void identity(int[] array)
Assign identity mapping to the argument array "identity" mapping: 0,1, ...


clone

public java.lang.Object clone()
Return a copy of this FieldIDMapper object

Overrides:
clone in class java.lang.Object

combine

public FieldIDMapper combine(FieldIDMapper fmap1,
                             FieldIDMapper fmap2)
Put two FieldIDMappers together.


isIdentityMapper

public boolean isIdentityMapper()
Returns true if it is an identity FieldIDMapper.


getComponentFields

public int[] getComponentFields()
Returns the field numbers of the component DataSource.


getCompositeFields

public int[] getCompositeFields()
Returns the field numbers of the composite DataSource.


getSources

public int[] getSources()
Returns the source identifier array This is the same as getComponentFields(), but FieldIDMapper need not be restricted to Component/Composite mapping


getDestinations

public int[] getDestinations()
Returns the field numbers of the composite DataSource. This is the same as getCompositeFields(), but FieldIDMapper need not be restricted to Component/Composite mapping


getMaxCpnID

public int getMaxCpnID()
Returns the maximum field number of this.componentFields.


getMaxCpsID

public int getMaxCpsID()
Returns the maximum field number of this.compositeFields.


size

public int size()
Returns the number of fields.


toComponent

public int toComponent(int compositeIndex)
return the component index given a composite index.


toComposite

public int toComposite(int componentIndex)
Returns the composite index given the component index.


toSource

public final int toSource(int destinationIndex)
return the source index given a destination index. Identical to toComponent( int ).


toDestination

public final int toDestination(int sourceIndex)
Returns the destination index given the source index. Identical to toComposite( int )


toComponent

public RecordSpec toComponent(RecordSpec spec1)
Returns a RecordSpec mapped to the given RecordSpec whose field numbers could be found in this.compositeFields. It is useful for BlockedDataSource since the components and the composite DataSource have the same attributes.


equals

public boolean equals(java.lang.Object obj)
Return true if parameter equals this object, false otherwise.

Overrides:
equals in class java.lang.Object

checkComponentID

public void checkComponentID()
Check whether the numbers in this.componentFields are distinct.


checkCompositeID

public void checkCompositeID()
Check whether the numbers in this.compositeFields are distinct.


toString

public java.lang.String toString()
to String

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)