hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abhishek dodda <abhishek.dod...@gmail.com>
Subject Re: Reg:Sequence id generation
Date Thu, 07 Jun 2012 14:39:10 GMT
Actually trying to code this using map reduce program.

On Thu, Jun 7, 2012 at 6:22 AM, shashwat shriparv
<dwivedishashwat@gmail.com> wrote:
> Try something like this :
>
>
> public class MyUniqueNumber
> {
>    private static MyUniqueNumber myUniqueNumber;
>    int number;
>    int seedValue=365432; //custom seed value to begin with
>
>    private MyUniqueNumber(){ //Singleton !!!
>        number=seedValue; //init to zero
>    }
>
>    public static MyUniqueNumber getInstance(){
>        if(myUniqueNumber==null){
>            myUniqueNumber=new MyUniqueNumber();
>        }
>        return myUniqueNumber;
>    }
>
>    public int getUniqueNumber(){
>        number+=1; //simple increment by 1 , you can modify this further
>        return number;
>    }
>    public static void main(String[] args)
>    {
>        MyUniqueNumber myUniqueNumber=MyUniqueNumber.getInstance();
>        for(int n=0;n<=5;n++){
>            System.out.println("read number:
> "+myUniqueNumber.getUniqueNumber());
>        }
>    }
> }
>
>
> On Thu, Jun 7, 2012 at 6:14 PM, abhishek dodda <abhishek.dodda1@gmail.com>wrote:
>
>> hi all,
>>
>>       I have a scenario where i should generate the sequence id . All
>> my tables are in DB2
>>
>
>
>
> --
>
>
> ∞
> Shashwat Shriparv

Mime
View raw message