Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
what is the bifference between these three autonumber autonumber128 autonumber256
wher the output gives same only
example
RegionSales:
LOAD *,
AutoNumber(Region&Year&Month) as RYMkey;
LOAD * INLINE
[ Region, Year, Month, Sales
North, 2014, May, 245
North, 2014, May, 347
North, 2014, June, 127
South, 2014, June, 645
South, 2013, May, 367
South, 2013, May, 221
];
output:
RYMkey
1
1
2
3
4
4
output is same for autonumber autonumber128 autonumber256
i agree that it calculates 128 bit for autonumber128 similar to the autonumber256 also it calculates 256bit and finally gives unique interger number similar to the autonumber
what these calculation pls explain
The functions are named: AutoNumber, AutoNumberHash128 and AutoNumberHash256
AutoNumber creates a temporary table during the execution of your load script with the full expression parameter value and a corresponding number. So if the same full expression parameter value comes up later in the iterations of the load or another load in the same load script execution it will return the same number.
AutoNumberHash128 use a 128-bit hash in the temporary table to be able to save space. This is probably only necessary if your values are much larger than 22 bytes/characters and you have a lot of rows/records that you generate autonumbers for.
AutoNumberHash256 use a 256-bit hash which makes it much less likely to fail or generate same hash for non-identical input values. There is always a risk albeit small for any hash to have collisions. So the 256 variant is safer but needs twice as much storage during the load script execution. For this to use less storage than a pure AutoNumber the combinded input values have to exceed 43 bytes/characters by a bit.
So yes the three functions should or could return the same numbers with the same input parameter(s). So it is more a matter of speed and memory consumption that differentiates the three functions from each other.
Nice explanation !!!
besides that, the autonumberhash128/256 functions allow having multiple (also 3 or more) expressions as input.
Autonumber allows only max 2 expressions as input (if you define the autonumber_id as an input expression ... ).
So you don't need the worry about a separator like "|" ... and dual() values won't be "converted" to text values...
For example, a composite key like:
Region&"|"&Year&"|"&Month
is a text value, so the numerical representation is lost...
but you could use
autonumberhash128(Region,Year, Month) for example.
So I think using the autonumberhash function is more convenient... ok there could be a hash collision ...
The hash collision are very unlikely anyway - and it is easy to calculate the likelihood for them.
I like the way AutonumberHash allows for multiple parameters without a separator. But...it doesn't allow for the AutoId parameter which I consider to be a "best practice". So when I want the convenience of multiple parameters or need to save RAM as Petter suggested, I code it this way.
Autonumber(Hash128(p1,p2,p3), 'AutoId')
-Rob
thanks rob, peter,robin