edu.unh.sdb.common
Class RecordDescriptor

java.lang.Object
  extended by edu.unh.sdb.common.Type
      extended by edu.unh.sdb.common.UserType
          extended by edu.unh.sdb.common.RecordDescriptor
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BytesOnlyRecordDescriptor

public class RecordDescriptor
extends UserType
implements java.lang.Cloneable

A RecordDescriptor is an ordered collection of AttributeDescriptors. Used to represent the name and type of all the attributes of a point in the geometric space (i.e. a Datum).


Field Summary
protected  int[] byteOffsets
           
protected  int byteSize
           
protected  AttributeDescriptor[] defs
           
protected  java.util.ArrayList typeCounters
           
protected  TypeTable types
           
 
Fields inherited from class edu.unh.sdb.common.UserType
storageType
 
Fields inherited from class edu.unh.sdb.common.Type
name
 
Constructor Summary
protected RecordDescriptor()
          Constructs an empty RecordDescriptor.
  RecordDescriptor(AttributeDescriptor[] attrs)
          Constructs an unnamed RecordDescriptor from an array of AttributeDescriptors.
  RecordDescriptor(char typeSpec, int numAttr)
          Constructs an unnamed uni-type RecordDescriptor of a specified length The type is determined by the first argument, the number of fields by the second.
  RecordDescriptor(java.lang.String typeSpec)
          Constructs an unnamed RecordDescriptor from a String in which each character identifies a field and its type.
  RecordDescriptor(java.lang.String name, AttributeDescriptor[] attrs)
          Constructs a named RecordDescriptor from an array of AttributeDescriptors.
  RecordDescriptor(java.lang.String name, char typeSpec, int numAttr)
          Constructs a named uni-type RecordDescriptor of a specified length The type is determined by the first argument, the number of fields by the second.
  RecordDescriptor(java.lang.String name, java.lang.String typeSpec)
          Constructs a named RecordDescriptor from a String in which each character identifies a field and its type.
  RecordDescriptor(java.lang.String name, TypeTable types, AttributeDescriptor[] attrs)
          Constructs a named RecordDescriptor from an array of AttributeDescriptors, referring to the given TypeTable.
  RecordDescriptor(TypeTable types, AttributeDescriptor[] attrs)
          Constructs an unnamed RecordDescriptor from an array of AttributeDescriptors, referring to the given TypeTable.
 
Method Summary
 int[] attributeByteSizes()
          Returns an array of integers indicating the size in bytes of the correspoding attributes in this RecordDescriptor.
 int byteOffset(int attributeNumber)
          Return the offset of the indicated attribute from the beginning of the record.
 int[] byteOffsets()
          Returns an array of integers indicated the byte offsets of each of the correspoding attributes in this RecordDescriptor.
 int byteSize()
          Return the number of bytes occupied by records decribed by this descriptor.
 java.lang.Object clone()
          Make a copy of this RecordDescriptor.
 RecordDescriptor copy()
          Make a copy of this RecordDescriptor.
 RecordDescriptor create(FieldIDMapper FIDMapper)
          Makes a new RecordDescriptor object from "this" RecordDescriptor and the FieldIDMapper.
 RecordDescriptor create(RecordSpec rs)
          Makes a new RecordDescriptor object from "this" RecordDescriptor and the RecordSpec.
protected static AttributeDescriptor[] createAttrDescriptorArray(char typeSpec, int numAttr)
          Create an array of AttributeDescriptors whose types are identified by a single char argument indicating type and an attr count.
protected static AttributeDescriptor[] createAttrDescriptorArray(java.lang.String typeSpec)
          Create an array of AttributeDescriptors whose types are identified by the individual characters in the argument String.
 DataBlock createDataBlock(ISBounds bnds)
          Creates a DataBlock that would be efficient to use for this RecordDescriptor.
 DataBlock createDataBlock(ISBounds bnds, FieldIDMapper fm)
          Creates a DataBlock that would be efficient to use for a subset of this RecordDescriptor, based on the FieldIDMapper.
 DataBlock createDataBlock(ISBounds bnds, RecordSpec rs)
          Creates a DataBlock that would be efficient to use for a subset of this RecordDescriptor, based on the RecordSpec.
 Datum createDatum()
          Returns a Datum of an appropriate type.
 Datum createDatum(Datum d)
          Returns a Datum of an appropriate type, initialized to the values of the passed in argument Datum.
 Datum createDatum(Datum d, FieldIDMapper fim)
          Returns a Datum of an appropriate type, initialized to the values of the passed in argument Datum.
 Datum createDatum(Datum d, RecordSpec spec)
          Returns a Datum of an appropriate type, initialized to the values of the passed in argument Datum.
 Datum createDatum(FieldIDMapper fm)
          Returns a Datum of an appropriate type.
 Datum createDatum(RecordSpec rs)
          Returns a Datum of an appropriate type as constrained by RecordSpec.
 Values createValues(int numEntries)
          Create a Values object of the appropriate type and size for this RecordDescriptor numEntries is the number of data points, so if there are multiple attributes there needs to be space for all of them
 boolean equals(java.lang.Object o)
          True if the argument is equal to this AttributeDescriptor, false otherwise.
 AttributeDescriptor getAttribute(int i)
          Return the AttributeDescriptor at the specified position.
 java.lang.String[] getFieldNames()
          Return an array of the field names.
 java.lang.String[] getFieldTypes()
          Return an array of the field types in string form.
 int getMaxAttributeByteSize()
          Returns the size in bytes of the largest attribute.
 int getNumAttributes()
          Return the number of Attributes in this collection.
 int getNumUsedTypes()
          Return the number of distinct storage types defined by this RecordDescriptor.
 int getStorageType()
          Return the underlying storage type for the entire record.
 int getStorageType(int index)
          Return the storage type of an attribute at the specified position.
 int[] getStorageTypes()
          Return an array of storage types; there is one entry per attribute.
 int getUsedType(int index)
          Get the StorageType of the i-th distinct storage type in this RecordDescriptor.
 int getUsedTypeCount(int index)
          Get the count of attributes of the i-th distinct storage type in this RecordDescriptor.
 int[] getUsedTypes()
          Get the an array of all StorageTypes used in this RecordDescriptor.
 boolean isUserType(int index)
          Return true if the attribute at the specified position is a User defined type.
static void main(java.lang.String[] args)
           
protected  void makeOffsets()
          Allocate and fill in the array of byte offsets.
protected  void makeStorageTypeInfo()
          Initialize arrays used for quick access to type information.
 java.lang.String name(int index)
          Return the name of a attribute at the specified position.
 RecordDescriptor project(FieldIDMapper fm)
          Returns a new RecordDescriptor with fields copied from this RecordDescriptor.
 RecordDescriptor project(RecordSpec rs)
          Returns a new RecordDescriptor with fields copied from this RecordDescriptor.
 int size()
          Return the number of Attributes in this collection.
 java.lang.String toString()
          Return a String representing the object.
 java.lang.String toString(java.lang.String indent)
          Return a String representing the object indented by the argument string.
 
Methods inherited from class edu.unh.sdb.common.Type
getName
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defs

protected AttributeDescriptor[] defs

types

protected TypeTable types

byteOffsets

protected int[] byteOffsets

byteSize

protected int byteSize

typeCounters

protected java.util.ArrayList typeCounters
Constructor Detail

RecordDescriptor

public RecordDescriptor(AttributeDescriptor[] attrs)
Constructs an unnamed RecordDescriptor from an array of AttributeDescriptors.


RecordDescriptor

public RecordDescriptor(java.lang.String name,
                        AttributeDescriptor[] attrs)
Constructs a named RecordDescriptor from an array of AttributeDescriptors.


RecordDescriptor

public RecordDescriptor(TypeTable types,
                        AttributeDescriptor[] attrs)
Constructs an unnamed RecordDescriptor from an array of AttributeDescriptors, referring to the given TypeTable.


RecordDescriptor

public RecordDescriptor(java.lang.String name,
                        TypeTable types,
                        AttributeDescriptor[] attrs)
Constructs a named RecordDescriptor from an array of AttributeDescriptors, referring to the given TypeTable.


RecordDescriptor

public RecordDescriptor(java.lang.String typeSpec)
Constructs an unnamed RecordDescriptor from a String in which each character identifies a field and its type. The fields are unnamed. The legal characters (for now) are: d - double f - float i - int s - short b - byte In the future, might add more. Could also extend to use printf type notation.


RecordDescriptor

public RecordDescriptor(java.lang.String name,
                        java.lang.String typeSpec)
Constructs a named RecordDescriptor from a String in which each character identifies a field and its type. The fields are unnamed. The legal characters (for now) are: d - double f - float i - int s - short b - byte In the future, might add more. Could also extend to use printf type notation.


RecordDescriptor

public RecordDescriptor(char typeSpec,
                        int numAttr)
Constructs an unnamed uni-type RecordDescriptor of a specified length The type is determined by the first argument, the number of fields by the second. The fields are unnamed. The legal characters (for now) are: d - double f - float i - int s - short b - byte In the future, might add more. Could also extend to use printf type notation.


RecordDescriptor

public RecordDescriptor(java.lang.String name,
                        char typeSpec,
                        int numAttr)
Constructs a named uni-type RecordDescriptor of a specified length The type is determined by the first argument, the number of fields by the second. The fields are unnamed. The legal characters (for now) are: d - double f - float i - int s - short b - byte In the future, might add more. Could also extend to use printf type notation.


RecordDescriptor

protected RecordDescriptor()
Constructs an empty RecordDescriptor.

Method Detail

project

public RecordDescriptor project(FieldIDMapper fm)
Returns a new RecordDescriptor with fields copied from this RecordDescriptor. The FieldIDMapper specifies which fields are copied. The location of the fields in the new RecordDescriptor is determined by their order in the FieldIDMapper.


create

public RecordDescriptor create(FieldIDMapper FIDMapper)
Makes a new RecordDescriptor object from "this" RecordDescriptor and the FieldIDMapper. The new RecordDescriptor will have the same number of fields as the FIDMapper. The componentFields of FIDMapper specifys which attributes are taken from "this" RecordDescriptor. The compositeFields of FIDMapper also determines their axisOrdering in the new RecordDescriptor. This method as currently implemented does not appear to be stable. It makes an array that is the size of the FieldIDMapper, but indexes into that array using composite field values that, in general, can be larger than the size of the FieldIDMapper. I am going to assume that the intent is that the FieldIDMapper that is passed in is only a "shuffling" FieldIDMapper. That is, there should be no indexes that are larger than the size of the component and composite arrays. The "project" method works if the result is a simple selection (projection).


create

public RecordDescriptor create(RecordSpec rs)
Makes a new RecordDescriptor object from "this" RecordDescriptor and the RecordSpec. The new RecordDescriptor will have the same number of fields as the RecordSpec.


project

public RecordDescriptor project(RecordSpec rs)
Returns a new RecordDescriptor with fields copied from this RecordDescriptor. The RecordSpec specifies which fields are copied. The location of the fields in the new RecordDescriptor is determined by their order in the RecordSpec.


createAttrDescriptorArray

protected static AttributeDescriptor[] createAttrDescriptorArray(java.lang.String typeSpec)
Create an array of AttributeDescriptors whose types are identified by the individual characters in the argument String. Valid characters are d,f,i,s,b for double, float, int, short, byte. We may add some additional functionality. The Attribute descriptors will be unnamed.


createAttrDescriptorArray

protected static AttributeDescriptor[] createAttrDescriptorArray(char typeSpec,
                                                                 int numAttr)
Create an array of AttributeDescriptors whose types are identified by a single char argument indicating type and an attr count. Valid characters are d,f,i,s,b for double, float, int, short, byte. We may add some additional functionality. The Attribute descriptors will be unnamed.


makeOffsets

protected void makeOffsets()
Allocate and fill in the array of byte offsets. Also gives a value to this.byteSize.


copy

public RecordDescriptor copy()
Make a copy of this RecordDescriptor. If a TypeTable is present, the copy will contain a reference to the same TypeTable object.


clone

public java.lang.Object clone()
Make a copy of this RecordDescriptor. If a TypeTable is present, the copy will contain a reference to the same TypeTable object.

Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
True if the argument is equal to this AttributeDescriptor, false otherwise. Currently, two AttributeDescriptors are equal if their name and type fields are equal, and they are using the same TypeTable object.

Overrides:
equals in class UserType

getStorageType

public final int getStorageType(int index)
Return the storage type of an attribute at the specified position.


getStorageTypes

public final int[] getStorageTypes()
Return an array of storage types; there is one entry per attribute.


getStorageType

public final int getStorageType()
Return the underlying storage type for the entire record. If all attributes are of the same type, the record will be of that type. Normally, mixed types in the record result in StorageType.Record as the storage type. However, it may some day be reasonable to have an underlying common type even though the fields are mixed. For example, a "smart" RecordDescriptor might choose to promote 1 byte field to short if all the other fields are short since that would provide a more efficient implementation. The value returned by this method should match the StorageType associated with the Values object that will be returned by DataCollection.getValues().

Overrides:
getStorageType in class UserType

isUserType

public final boolean isUserType(int index)
Return true if the attribute at the specified position is a User defined type. Return false otherwise.


getFieldNames

public java.lang.String[] getFieldNames()
Return an array of the field names.


getFieldTypes

public java.lang.String[] getFieldTypes()
Return an array of the field types in string form.


name

public java.lang.String name(int index)
Return the name of a attribute at the specified position.


getAttribute

public final AttributeDescriptor getAttribute(int i)
Return the AttributeDescriptor at the specified position.


size

public final int size()
Return the number of Attributes in this collection.


getNumAttributes

public final int getNumAttributes()
Return the number of Attributes in this collection.


byteSize

public final int byteSize()
Return the number of bytes occupied by records decribed by this descriptor. We are not accounting for padding at the moment.


byteOffset

public final int byteOffset(int attributeNumber)
Return the offset of the indicated attribute from the beginning of the record. We are not accounting for padding at the moment.


makeStorageTypeInfo

protected void makeStorageTypeInfo()
Initialize arrays used for quick access to type information. storageTypeCounts<\b> is an array of pairs of integers such that the first element of each pair indicates how many attributes with a certain storage type occur in this RecordDescriptor, and the second element indicates the storage type for that count. storageTypes<\b> is an array of integers representing the types of each field of the RecordDescriptor.


getNumUsedTypes

public int getNumUsedTypes()
Return the number of distinct storage types defined by this RecordDescriptor.


getUsedTypes

public int[] getUsedTypes()
Get the an array of all StorageTypes used in this RecordDescriptor.


getUsedType

public int getUsedType(int index)
Get the StorageType of the i-th distinct storage type in this RecordDescriptor.


getUsedTypeCount

public int getUsedTypeCount(int index)
Get the count of attributes of the i-th distinct storage type in this RecordDescriptor.


getMaxAttributeByteSize

public final int getMaxAttributeByteSize()
Returns the size in bytes of the largest attribute.


toString

public java.lang.String toString()
Return a String representing the object.

Overrides:
toString in class UserType

toString

public java.lang.String toString(java.lang.String indent)
Return a String representing the object indented by the argument string.


attributeByteSizes

public int[] attributeByteSizes()
Returns an array of integers indicating the size in bytes of the correspoding attributes in this RecordDescriptor. added by Xuan Tang 08/05/03


byteOffsets

public int[] byteOffsets()
Returns an array of integers indicated the byte offsets of each of the correspoding attributes in this RecordDescriptor. added by Xuan Tang 08/06/03


createDatum

public Datum createDatum()
Returns a Datum of an appropriate type. If all fields are of the same type, it will create a Datum of that type; otherwise, it creates a MixedDatum object.


createDatum

public Datum createDatum(RecordSpec rs)
Returns a Datum of an appropriate type as constrained by RecordSpec. If the RecordSpec argument is null, all fields of the RecordDescriptor are used. If all fields are of the same type, it will create a Datum of that type; otherwise, it creates a MixedDatum object.


createDatum

public Datum createDatum(FieldIDMapper fm)
Returns a Datum of an appropriate type. Only includes fields defined by the toComponent results of the FieldIDMapper. If the FieldIDMapper argument is null, all fields of the RecordDescriptor are used. If all fields are of the same type, it will create a Datum of that type; otherwise, it creates a MixedDatum object.


createDatum

public Datum createDatum(Datum d)
Returns a Datum of an appropriate type, initialized to the values of the passed in argument Datum. If all fields are of the same type, it will create a Datum of that type; otherwise, it creates a MixedDatum object.


createDatum

public Datum createDatum(Datum d,
                         RecordSpec spec)
Returns a Datum of an appropriate type, initialized to the values of the passed in argument Datum. The RecordSpec is intended to identify the subset of the result Datum. It is NOT applied to the Datum passed as the argument; this is assumed to match the RecordSpec. If the RecordSpec argument is null, all fields of the RecordDescriptor are used. If all fields are of the same type, it will create a Datum of that type; otherwise, it creates a MixedDatum object.


createDatum

public Datum createDatum(Datum d,
                         FieldIDMapper fim)
Returns a Datum of an appropriate type, initialized to the values of the passed in argument Datum. If the FieldIDMapper argument is null, all fields of the RecordDescriptor are used. Only includes fields defined by the toComponent results of the FieldIDMapper. and assumes that the passed in Datum only has those fields!!!! If all fields are of the same type, it will create a Datum of that type; otherwise, it creates a MixedDatum object.


createValues

public Values createValues(int numEntries)
Create a Values object of the appropriate type and size for this RecordDescriptor numEntries is the number of data points, so if there are multiple attributes there needs to be space for all of them


createDataBlock

public DataBlock createDataBlock(ISBounds bnds)
Creates a DataBlock that would be efficient to use for this RecordDescriptor. If the attributes are all of the same data type, creates a BasicBlock. If the attributes are of mixed types, it creates a CompositeBlock and assigns all of the attributes of the same type to one of the BasicBlocks inside the CompositeBlock.


createDataBlock

public DataBlock createDataBlock(ISBounds bnds,
                                 RecordSpec rs)
Creates a DataBlock that would be efficient to use for a subset of this RecordDescriptor, based on the RecordSpec. If the RecordSpec argument is null, all fields of the RecordDescriptor are used. If the attributes are all of the same data type, creates a BasicBlock. If the attributes are of mixed types, it creates a CompositeBlock and assigns all of the attributes of the same type to one of the BasicBlocks inside the CompositeBlock.


createDataBlock

public DataBlock createDataBlock(ISBounds bnds,
                                 FieldIDMapper fm)
Creates a DataBlock that would be efficient to use for a subset of this RecordDescriptor, based on the FieldIDMapper. If the FieldIDMapper argument is null, all fields of the RecordDescriptor are used. If the attributes are all of the same data type, creates a BasicBlock. If the attributes are of mixed types, it creates a CompositeBlock and assigns all of the attributes of the same type to one of the BasicBlocks inside the CompositeBlock.


main

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