Search in sources :

Example 26 with ValueMetaNumber

use of org.apache.hop.core.row.value.ValueMetaNumber in project hop by apache.

the class RandomValueMeta method getFields.

@Override
public void getFields(IRowMeta row, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
    for (int i = 0; i < fieldName.length; i++) {
        IValueMeta v;
        switch(fieldType[i]) {
            case TYPE_RANDOM_NUMBER:
                v = new ValueMetaNumber(fieldName[i], 10, 5);
                break;
            case TYPE_RANDOM_INTEGER:
                v = new ValueMetaInteger(fieldName[i], 10, 0);
                break;
            case TYPE_RANDOM_STRING:
                v = new ValueMetaString(fieldName[i], 13, 0);
                break;
            case TYPE_RANDOM_UUID:
                v = new ValueMetaString(fieldName[i], 36, 0);
                break;
            case TYPE_RANDOM_UUID4:
                v = new ValueMetaString(fieldName[i], 36, 0);
                break;
            case TYPE_RANDOM_MAC_HMACMD5:
                v = new ValueMetaString(fieldName[i], 100, 0);
                break;
            case TYPE_RANDOM_MAC_HMACSHA1:
                v = new ValueMetaString(fieldName[i], 100, 0);
                break;
            default:
                v = new ValueMetaNone(fieldName[i]);
                break;
        }
        v.setOrigin(name);
        row.addValueMeta(v);
    }
}
Also used : IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) ValueMetaNone(org.apache.hop.core.row.value.ValueMetaNone) ValueMetaNumber(org.apache.hop.core.row.value.ValueMetaNumber) ValueMetaInteger(org.apache.hop.core.row.value.ValueMetaInteger)

Example 27 with ValueMetaNumber

use of org.apache.hop.core.row.value.ValueMetaNumber in project hop by apache.

the class FuzzyMatchMeta method getFields.

@Override
public void getFields(IRowMeta inputRowMeta, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
    // Add match field
    IValueMeta v = new ValueMetaString(variables.resolve(getOutputMatchField()));
    v.setOrigin(name);
    v.setStorageType(IValueMeta.STORAGE_TYPE_NORMAL);
    inputRowMeta.addValueMeta(v);
    String mainField = variables.resolve(getOutputValueField());
    if (!Utils.isEmpty(mainField) && isGetCloserValue()) {
        switch(getAlgorithmType()) {
            case FuzzyMatchMeta.OPERATION_TYPE_DAMERAU_LEVENSHTEIN:
            case FuzzyMatchMeta.OPERATION_TYPE_LEVENSHTEIN:
                v = new ValueMetaInteger(mainField);
                v.setLength(IValueMeta.DEFAULT_INTEGER_LENGTH);
                break;
            case FuzzyMatchMeta.OPERATION_TYPE_JARO:
            case FuzzyMatchMeta.OPERATION_TYPE_JARO_WINKLER:
            case FuzzyMatchMeta.OPERATION_TYPE_PAIR_SIMILARITY:
                v = new ValueMetaNumber(mainField);
                break;
            default:
                // Phonetic algorithms
                v = new ValueMetaString(mainField);
                break;
        }
        v.setStorageType(IValueMeta.STORAGE_TYPE_NORMAL);
        v.setOrigin(name);
        inputRowMeta.addValueMeta(v);
    }
    boolean activateAdditionalFields = isGetCloserValue() || (getAlgorithmType() == FuzzyMatchMeta.OPERATION_TYPE_DOUBLE_METAPHONE) || (getAlgorithmType() == FuzzyMatchMeta.OPERATION_TYPE_SOUNDEX) || (getAlgorithmType() == FuzzyMatchMeta.OPERATION_TYPE_REFINED_SOUNDEX) || (getAlgorithmType() == FuzzyMatchMeta.OPERATION_TYPE_METAPHONE);
    if (activateAdditionalFields) {
        if (info != null && info.length == 1 && info[0] != null) {
            for (int i = 0; i < valueName.length; i++) {
                v = info[0].searchValueMeta(value[i]);
                if (v != null) {
                    // Configuration error/missing resources...
                    v.setName(valueName[i]);
                    v.setOrigin(name);
                    v.setStorageType(// Only normal storage goes into the cache
                    IValueMeta.STORAGE_TYPE_NORMAL);
                    inputRowMeta.addValueMeta(v);
                } else {
                    throw new HopTransformException(BaseMessages.getString(PKG, "FuzzyMatchMeta.Exception.ReturnValueCanNotBeFound", value[i]));
                }
            }
        } else {
            for (int i = 0; i < valueName.length; i++) {
                v = new ValueMetaString(valueName[i]);
                v.setOrigin(name);
                inputRowMeta.addValueMeta(v);
            }
        }
    }
}
Also used : IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) ValueMetaNumber(org.apache.hop.core.row.value.ValueMetaNumber) ValueMetaInteger(org.apache.hop.core.row.value.ValueMetaInteger) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) HopTransformException(org.apache.hop.core.exception.HopTransformException)

Aggregations

ValueMetaNumber (org.apache.hop.core.row.value.ValueMetaNumber)27 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)18 ValueMetaInteger (org.apache.hop.core.row.value.ValueMetaInteger)11 ValueMetaBinary (org.apache.hop.core.row.value.ValueMetaBinary)7 IRowMeta (org.apache.hop.core.row.IRowMeta)5 IValueMeta (org.apache.hop.core.row.IValueMeta)5 HopException (org.apache.hop.core.exception.HopException)4 RowMeta (org.apache.hop.core.row.RowMeta)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 RowMetaAndData (org.apache.hop.core.RowMetaAndData)3 ValueMetaDate (org.apache.hop.core.row.value.ValueMetaDate)3 ILogChannel (org.apache.hop.core.logging.ILogChannel)2 DriverCqlRowHandler (org.apache.hop.databases.cassandra.datastax.DriverCqlRowHandler)2 DriverKeyspace (org.apache.hop.databases.cassandra.datastax.DriverKeyspace)2 ITransform (org.apache.hop.pipeline.transform.ITransform)2 Column (com.epam.parso.Column)1 ColumnFormat (com.epam.parso.ColumnFormat)1 SasFileProperties (com.epam.parso.SasFileProperties)1