Five Stars

Numeric.sequence with Long

Good Morning,

 

I want to create a sequence which can go until 9999999999 which is actually over the int limit.

 

I tried to pass a Long value to this dedicated Talend function "Numeric.sequence()", but it appears to be not implemented.

It needs an int and it works if I submit my variable applying intValue(), but it has side effects : it doesn't increment properly at a certain point.

 

How can I go until this top value of "9 999 999 999" ?

 

Thank You.

 

note : I'm using Talend Real-Time Big Data  Platform 6.2.1 with a Talend Administration Console to launch the jobs.

 

 

Tags (2)
2 ACCEPTED SOLUTIONS

Accepted Solutions
Twelve Stars

Re: Numeric.sequence with Long

You can easily implement this yourself. Go to Code--> Routines-->system in your project tree and find the Numeric routine. Take a look in there for the sequence method. Simply copy this and convert it to use Long in your own routine.

Rilhia Solutions
Five Stars

Re: Numeric.sequence with Long

Thank You.

 

I'll do that as it seems to be the best way to achieve this until Talend implement it Smiley Happy

5 REPLIES
Twelve Stars

Re: Numeric.sequence with Long

You can easily implement this yourself. Go to Code--> Routines-->system in your project tree and find the Numeric routine. Take a look in there for the sequence method. Simply copy this and convert it to use Long in your own routine.

Rilhia Solutions
Five Stars

Re: Numeric.sequence with Long

Thank You.

 

I'll do that as it seems to be the best way to achieve this until Talend implement it Smiley Happy

Twelve Stars

Re: Numeric.sequence with Long

To be honest, I think the routines that Talend supply are more a useful example of what you can do. I wouldn't expect them to update these too often. It is very useful to build up your own routines (classes) of useful functionality.

Rilhia Solutions
Five Stars

Re: Numeric.sequence with Long

I think You're right, but we tend to use Talend bundled components and routines.

 

Then there is less specific developments to maintain.

 

By the way, there is the code I've adapted in case it could be useful to anyone :


 

private static final java.util.Map<String, Long> seq_Hash = new java.util.HashMap<String, Long>();
      public static Long LongSequence(String seqName, Long startValue, int step) {
        if (seq_Hash.containsKey(seqName)) {
            seq_Hash.put(seqName, seq_Hash.get(seqName) + step);
                  if(seq_Hash.get(seqName)>9999999999L){
                        seq_Hash.put(seqName, 0L);
                  }
            return seq_Hash.get(seqName);
        } else {
            seq_Hash.put(seqName, startValue);
            return startValue;
        }
    }

 

Twelve Stars

Re: Numeric.sequence with Long

@Jacky_Siveton you have left a couple of method out that you *might* need....

 

    /**
     * create a sequence if not exists and put a new startValue
     *
     * {Category} Numeric
     *
     * {param} string("s1") sequence identifier
     *
     * {param} long(1) start value
     *
     * {example} sequence("s1", 1)
     *
     */

    public static void resetSequence(String seqName, long startValue) {
        seq_Hash.put(seqName, startValue);
    }

    /**
     * remove a sequence
     *
     * {Category} Numeric
     *
     * {param} string("s1") sequence identifier
     *
     * {example} sequence("s1")
     *
     */

    public static void removeSequence(String seqName) {
        if (seq_Hash.containsKey(seqName)) {
            seq_Hash.remove(seqName);
        }
    }
Rilhia Solutions