Java Code Examples for org.pentaho.di.core.row.ValueMeta#getTypeDesc()

The following examples show how to use org.pentaho.di.core.row.ValueMeta#getTypeDesc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HBaseValueMeta.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
/**
 * Get the type of this field as a string
 *
 * @return the type of this field as a string
 */
public String getHBaseTypeDesc() {
  if ( isInteger() ) {
    return ( getIsLongOrDouble() ? "Long" : "Integer" );
  }
  if ( isNumber() ) {
    return ( getIsLongOrDouble() ? "Double" : "Float" );
  }

  return ValueMeta.getTypeDesc( getType() );
}
 
Example 2
Source File: MongodbInputDiscoverFieldsImpl.java    From pentaho-mongodb-plugin with Apache License 2.0 4 votes vote down vote up
private static void processRecord( BasicDBObject rec, String path, String name, Map<String, MongoField> lookup ) {
  for ( String key : rec.keySet() ) {
    Object fieldValue = rec.get( key );

    if ( fieldValue instanceof BasicDBObject ) {
      processRecord( (BasicDBObject) fieldValue, path + "." + key, name + "." + //$NON-NLS-1$ //$NON-NLS-2$
          key, lookup );
    } else if ( fieldValue instanceof BasicDBList ) {
      processList( (BasicDBList) fieldValue, path + "." + key, name + "." + //$NON-NLS-1$ //$NON-NLS-2$
          key, lookup );
    } else {
      // some sort of primitive
      String finalPath = path + "." + key; //$NON-NLS-1$
      String finalName = name + "." + key; //$NON-NLS-1$
      if ( !lookup.containsKey( finalPath ) ) {
        MongoField newField = new MongoField();
        int kettleType = mongoToKettleType( fieldValue );
        // Following suit of mongoToKettleType by interpreting null as String type
        newField.m_mongoType = String.class;
        if ( fieldValue != null ) {
          newField.m_mongoType = fieldValue.getClass();
        }
        newField.m_fieldName = finalName;
        newField.m_fieldPath = finalPath;
        newField.m_kettleType = ValueMeta.getTypeDesc( kettleType );
        newField.m_percentageOfSample = 1;

        lookup.put( finalPath, newField );
      } else {
        // update max indexes in array parts of name
        MongoField m = lookup.get( finalPath );
        Class<?> fieldClass = String.class;
        if ( fieldValue != null ) {
          fieldClass = fieldValue.getClass();
        }
        if ( !m.m_mongoType.isAssignableFrom( fieldClass ) ) {
          m.m_disparateTypes = true;
        }
        m.m_percentageOfSample++;
        updateMinMaxArrayIndexes( m, finalName );
      }
    }
  }
}
 
Example 3
Source File: MongodbInputDiscoverFieldsImpl.java    From pentaho-mongodb-plugin with Apache License 2.0 4 votes vote down vote up
private static void processList( BasicDBList list, String path, String name, Map<String, MongoField> lookup ) {

    if ( list.size() == 0 ) {
      return; // can't infer anything about an empty list
    }

    String nonPrimitivePath = path + "[-]"; //$NON-NLS-1$
    String primitivePath = path;

    for ( int i = 0; i < list.size(); i++ ) {
      Object element = list.get( i );

      if ( element instanceof BasicDBObject ) {
        processRecord( (BasicDBObject) element, nonPrimitivePath, name + "[" + i + //$NON-NLS-1$
            ":" + i + "]", lookup ); //$NON-NLS-1$ //$NON-NLS-2$
      } else if ( element instanceof BasicDBList ) {
        processList( (BasicDBList) element, nonPrimitivePath, name + "[" + i + //$NON-NLS-1$
            ":" + i + "]", lookup ); //$NON-NLS-1$ //$NON-NLS-2$
      } else {
        // some sort of primitive
        String finalPath = primitivePath + "[" + i + "]"; //$NON-NLS-1$ //$NON-NLS-2$
        String finalName = name + "[" + i + "]"; //$NON-NLS-1$ //$NON-NLS-2$
        if ( !lookup.containsKey( finalPath ) ) {
          MongoField newField = new MongoField();
          int kettleType = mongoToKettleType( element );
          // Following suit of mongoToKettleType by interpreting null as String type
          newField.m_mongoType = String.class;
          if ( element != null ) {
            newField.m_mongoType = element.getClass();
          }
          newField.m_fieldName = finalPath;
          newField.m_fieldPath = finalName;
          newField.m_kettleType = ValueMeta.getTypeDesc( kettleType );
          newField.m_percentageOfSample = 1;

          lookup.put( finalPath, newField );
        } else {
          // update max indexes in array parts of name
          MongoField m = lookup.get( finalPath );
          Class<?> elementClass = String.class;
          if ( element != null ) {
            elementClass = element.getClass();
          }
          if ( !m.m_mongoType.isAssignableFrom( elementClass ) ) {
            m.m_disparateTypes = true;
          }
          m.m_percentageOfSample++;
          updateMinMaxArrayIndexes( m, finalName );
        }
      }
    }
  }
 
Example 4
Source File: XMLField.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public String getTypeDesc() {
  return ValueMeta.getTypeDesc( type );
}
 
Example 5
Source File: XMLField.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public String getTypeDesc() {
  return ValueMeta.getTypeDesc( type );
}
 
Example 6
Source File: GetXMLDataField.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public String getTypeDesc() {
  return ValueMeta.getTypeDesc( type );
}
 
Example 7
Source File: XMLInputSaxField.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public String getTypeDesc() {
  return ValueMeta.getTypeDesc( type );
}
 
Example 8
Source File: XMLInputField.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public String getTypeDesc() {
  return ValueMeta.getTypeDesc( type );
}