private ByteBuffer convertValueByFunction(Tree functionCall, CfDef columnFamily, ByteBuffer columnName, boolean withUpdate)
    {
        String functionName = functionCall.getChild(0).getText();
        Tree argumentTree = functionCall.getChild(1);
        String functionArg  = (argumentTree == null) ? "" : CliUtils.unescapeSQLString(argumentTree.getText());
        AbstractType<?> validator = getTypeByFunction(functionName);

        try
        {

            ByteBuffer value;

            if (functionArg.isEmpty())
            {
                if (validator instanceof TimeUUIDType)
                {
                    value = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes());
                }
                else if (validator instanceof LexicalUUIDType)
                {
                    value = ByteBuffer.wrap(UUIDGen.decompose(UUID.randomUUID()));
                }
                else if (validator instanceof BytesType)
                {
                    value = ByteBuffer.wrap(new byte[0]);
                }
                else
                {
                    throw new RuntimeException(String.format("Argument for '%s' could not be empty.", functionName));
                }
            }
            else
            {
                value = getBytesAccordingToType(functionArg, validator);
            }

            // performing ColumnDef local validator update
            if (withUpdate)
            {
                updateColumnMetaData(columnFamily, columnName, validator.toString());
            }

            return value;
        }
        catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }
private ByteBuffer convertValueByFunction ( Tree functionCall , CfDef columnFamily , ByteBuffer columnName , boolean withUpdate ) { String functionName = functionCall . getChild ( 0 ) . getText ( ) ; Tree argumentTree = functionCall . getChild ( 1 ) ; String functionArg = ( argumentTree == null ) ? "" : CliUtils . unescapeSQLString ( argumentTree . getText ( ) ) ; AbstractType < ? > validator = getTypeByFunction ( functionName ) ; try { ByteBuffer value ; if ( functionArg . isEmpty ( ) ) { if ( validator instanceof TimeUUIDType ) { value = ByteBuffer . wrap ( UUIDGen . getTimeUUIDBytes ( ) ) ; } else if ( validator instanceof LexicalUUIDType ) { value = ByteBuffer . wrap ( UUIDGen . decompose ( UUID . randomUUID ( ) ) ) ; } else if ( validator instanceof BytesType ) { value = ByteBuffer . wrap ( new byte [ 0 ] ) ; } else { throw new RuntimeException ( String . format ( "Argument for '%s' could not be empty." , functionName ) ) ; } } else { value = getBytesAccordingToType ( functionArg , validator ) ; } if ( withUpdate ) { updateColumnMetaData ( columnFamily , columnName , validator . toString ( ) ) ; } return value ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Used to convert value (function argument, string) into byte[]
@param functionCall - tree representing function call ^(FUNCTION_CALL function_name value)
@param columnFamily - column family definition (CfDef)
@param columnName   - column name as byte[] (used to update CfDef)
@param withUpdate   - also updates column family metadata for given column
@return byte[] - string value as byte[]