public class DMOSignatureHelper
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static interface |
DMOSignatureHelper.IteratorProvider<T>
Helper for anonymous functions used in identifying a suitable character for a specified data type.
|
(package private) static interface |
DMOSignatureHelper.TypeIdentifierProvider
Helper for anonymous functions used in identifying a suitable character for a specified data type.
|
Modifier and Type | Field and Description |
---|---|
private static char |
CHAR_MANDANTORY
The character used for representing a mandatory property
|
private static char |
CHAR_PROPERTY_ID_DELIMITER
The character used as delimiter between the property ids in the same group (ex: unique constraint)
|
private static char |
CHAR_UNIQUE_CONSTRAINT_DELIMITER
The character used as delimiter between unique constraints which are encoded
as a sequence of property ids
|
private static DMOSignatureHelper.TypeIdentifierProvider |
findAnyCandidate
A helper to select any unused character for a specified data type.
|
private static DMOSignatureHelper.TypeIdentifierProvider |
findSuitableCandidate
A helper to select a suitable unused character for a specified data type.
|
private static java.lang.String |
FORMATTED_CONSTRAINT_DELIMITER
A string based delimiter (regex friendly) used for splitting a signature into separate constraints
|
private static java.lang.String |
FORMATTED_PROPERTY_DELIMITER
A string based delimiter (regex friendly) used for splitting a propriety id group
into separate property ids
|
private static java.util.logging.Logger |
LOG
Logger
|
private static char |
PROPERTY_NAME_DELIMITER_FINISH
The character used after appending a property name to the signature.
|
private static char |
PROPERTY_NAME_DELIMITER_START
The character used before appending a property name to the signature.
|
private static java.util.Map<java.lang.Class<? extends BaseDataType>,java.lang.Character> |
typeMapping
A map statically initialized with the classic JVM data type single-char representation.
|
Constructor and Description |
---|
DMOSignatureHelper() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
buildExplicitSignature(DMOSignatureHelper.IteratorProvider<Property> it,
java.util.List<java.util.List<Property>> uniqueConstraints,
boolean tempTable,
java.util.Map<java.lang.Integer,java.lang.Integer> idToPos) |
private static boolean |
buildPropertySignature(DMOSignatureHelper.IteratorProvider<Property> itProvider,
boolean tempTable,
boolean explicit,
java.util.Map<java.lang.Integer,java.lang.Integer> idToPos,
java.lang.StringBuilder sb)
This is responsible for encoding the properties and append them to the provided string builder.
|
private static java.lang.String |
buildQuickSignature(DMOSignatureHelper.IteratorProvider<Property> it,
java.util.List<java.util.List<Property>> uniqueConstraints,
boolean tempTable)
This builds a string which structurally represents a DMO.
|
private static java.lang.String |
buildSchemaSignature(DmoMeta meta)
Build a signature to match the DMO schema with another one.
|
(package private) static DmoSignature |
buildSignature(DmoMeta meta)
This builds a signature which represents a DMO.
|
private static boolean |
buildUniqueConstraintsSignature(java.util.List<java.util.List<Property>> uniqueConstraints,
java.util.Map<java.lang.Integer,java.lang.Integer> idToPos,
java.lang.StringBuilder sb)
This is responsible for encoding the unique constraints and append them to the provided string builder.
|
static boolean |
exactPropertyOrder(DmoSignature srcSignature,
DmoSignature dstSignature)
Check if two signatures are compatible from properties name order point of view.
|
private static java.lang.Character |
getTypeEncoding(java.lang.Class<? extends BaseDataType> type)
Provide a single character encoding for a certain base data type.
|
private static boolean |
isConstraint(char ch)
Check if the provided character is suitable for constraint encoding in the signature.
|
private static boolean |
isDigit(char ch)
Check if the provided character is a base-10 digit.
|
private static boolean |
isType(char ch)
Check if the provided character is suitable for data type encoding in the signature.
|
private static boolean |
processFieldConstraints(Property prop,
boolean tempTable,
java.lang.StringBuilder sb)
Helper which sets restrictions like mandatory or unique to a specified field.
|
private static boolean |
processFieldName(Property prop,
boolean tempTable,
java.lang.StringBuilder sb) |
private static boolean |
propertiesMatch(java.lang.String src,
java.lang.String dst)
Check if two signatures are compatible in terms of properties data types, extent and field-level
constraints.
|
private static boolean |
strongerUniqueConstraint(java.lang.String firstConstraint,
java.lang.String secondConstraint)
Check if having the first unique constraint will automatically determine that the second unique
constraint will be satisfied.
|
private static boolean |
uniqueConstraintsMatch(java.lang.String src,
java.lang.String dst)
Check if the second set of unique constraints (encoded in the destination signature) can be implied
by the first set of unique constraints.
|
static boolean |
validBufferCopy(DmoSignature src,
DmoSignature dst)
Check if the source and destination are compatible for a fast buffer-copy.
|
static boolean |
validTempTableBulkCopy(DmoSignature src,
DmoSignature dst,
boolean looseCopy)
Check if the destination signature is less restrictive than the source signature.
|
private static final java.util.Map<java.lang.Class<? extends BaseDataType>,java.lang.Character> typeMapping
private static final char CHAR_MANDANTORY
private static final char CHAR_UNIQUE_CONSTRAINT_DELIMITER
private static final char CHAR_PROPERTY_ID_DELIMITER
private static final char PROPERTY_NAME_DELIMITER_START
private static final char PROPERTY_NAME_DELIMITER_FINISH
private static final java.lang.String FORMATTED_CONSTRAINT_DELIMITER
private static final java.lang.String FORMATTED_PROPERTY_DELIMITER
private static final java.util.logging.Logger LOG
private static final DMOSignatureHelper.TypeIdentifierProvider findSuitableCandidate
private static final DMOSignatureHelper.TypeIdentifierProvider findAnyCandidate
static DmoSignature buildSignature(DmoMeta meta)
meta
- The DMO meta instance. WARNING: this is called from the c'tor
.public static boolean exactPropertyOrder(DmoSignature srcSignature, DmoSignature dstSignature)
srcSignature
- The source signature which should be checked.dstSignature
- The destination signature which should be checked.true
if the DMO signatures shuffled the property names in the explicit signatures
in the same order. This means that, if the explicit signature match and this returns
true
, it means that they have the same order of the properties name/types/extents/
constraints etc. Otherwise, they only have the same property names but in different order,
case in which this returns false
.public static boolean validBufferCopy(DmoSignature src, DmoSignature dst)
src
- The signature of the source DMO.dst
- The signature of the destination DMO.true
if the explicit signatures are equal, so they have the same property names
(not always in the same order).public static boolean validTempTableBulkCopy(DmoSignature src, DmoSignature dst, boolean looseCopy)
src
- The signature of the source DMO.dst
- The signature of the destination DMO.looseCopy
- Flag which indicates if the DMO signatures are compatible in loose-copy-mode.true
if the signatures are compatible.private static java.lang.String buildSchemaSignature(DmoMeta meta)
The rules use the field's data-type in the order they are defined, without extent or mandatory.
For indexes, the signature will contain each index, in order of definition, and each will have: the index type (unique, primary, word), followed by the components (which are the field index in the definition), sort order, and field's case-sensitivity, in case of character.
meta
- The DMO meta.private static java.lang.String buildQuickSignature(DMOSignatureHelper.IteratorProvider<Property> it, java.util.List<java.util.List<Property>> uniqueConstraints, boolean tempTable)
it
- An iterator to the whole collection of properties for the processed DMO.uniqueConstraints
- A list of multiple properties which together should be unique.tempTable
- A flag to indicate that that the properties are for a temp-table.private static java.lang.String buildExplicitSignature(DMOSignatureHelper.IteratorProvider<Property> it, java.util.List<java.util.List<Property>> uniqueConstraints, boolean tempTable, java.util.Map<java.lang.Integer,java.lang.Integer> idToPos)
private static boolean propertiesMatch(java.lang.String src, java.lang.String dst)
src
- The signature of the source DMO.dst
- The signature of the destination DMO.true
if the signatures are compatible.private static boolean uniqueConstraintsMatch(java.lang.String src, java.lang.String dst)
src
- The signature of the source's unique constraints.dst
- The signature of the destination's unique constraints.true
if the constraints in the destination are satisfied by the unique constraints
in the source.private static boolean strongerUniqueConstraint(java.lang.String firstConstraint, java.lang.String secondConstraint)
firstConstraint
- The first unique constraint signature which is checked.secondConstraint
- The second unique constraint signature which is checked.true
if the first unique constraint is included in the second, which means
that is stronger and can imply the second unique constraint.private static boolean buildPropertySignature(DMOSignatureHelper.IteratorProvider<Property> itProvider, boolean tempTable, boolean explicit, java.util.Map<java.lang.Integer,java.lang.Integer> idToPos, java.lang.StringBuilder sb)
itProvider
- An iterator to a collection of properties which should be encoded.tempTable
- A flag indicating that the signature is created for a temp-table specific DMO.explicit
- A flag indicating that this property signature is done for an explicit signature.
This means that the property names should be included, and the property ordered.idToPos
- A valid map which will be filled with the correspondence between property id and
their order in the generated signature. This is required only if the explicit
flag is set on true - as only explicit signatures have a different ordering of the props.sb
- The string builder onto which the signature should be appended.true
if the properties could be encoded in a signature.private static boolean buildUniqueConstraintsSignature(java.util.List<java.util.List<Property>> uniqueConstraints, java.util.Map<java.lang.Integer,java.lang.Integer> idToPos, java.lang.StringBuilder sb)
uniqueConstraints
- A list of unique constrains (each being a list of properties).idToPos
- A mapping from the property ids to their position in the signature. This should be
null
for quick signatures (as their ids match the position}, which this should be
not null
null in explicit signatures, where the order doesn't always match.sb
- The string builder onto which the signature should be appended.true
if the unique constraints could be converted to a signatureprivate static java.lang.Character getTypeEncoding(java.lang.Class<? extends BaseDataType> type)
type
- The base data type for which the encoding is to be retrieved.private static boolean isType(char ch)
ch
- The character which is checked.true
if the character is suitable.private static boolean isDigit(char ch)
ch
- The character which is checked.true
if the character is a digit.private static boolean isConstraint(char ch)
ch
- The character which is checked.true
if the character is suitable.private static boolean processFieldConstraints(Property prop, boolean tempTable, java.lang.StringBuilder sb)
prop
- The property for which the restriction analysis is done.tempTable
- Flag which indicates that the property is part of a temporary table.sb
- The string builder which should be completed with the found restrictions.true
if we could process the constraints of the propertyprivate static boolean processFieldName(Property prop, boolean tempTable, java.lang.StringBuilder sb)