question

DGuy@BitsAtPlay avatar image
DGuy@BitsAtPlay asked

Is getLatestNumberList().getValues() broken or am I confused?

I'm not understanding the order of values returned by [i]getLatestNumberList().getValues()[/i] 1) I create 3 SyncableNumberList using [i]getHighNumberList()[/i], [i]getLowNumberList()[/i] & [i]getLatestNumberList()[/i] 2) I add the following values, in the order shown, to each list: [i]1, 10, 2, 9, 3, 8, 4, 7, 5, 6[/i] 3a) [i]getHighNumberList().values()[/i] returns [i]10, 9, 8, 7, 6[/i] (as expected) 3b) [i]getLowNumberList().values()[/i] returns [i]1, 2, 3, 4, 5[/i] (as expected) 3b) [i]getLatestNumberList().values()[/i] returns [i]1, 2, 3, 4, 5[/i] (??? - Shouldn't it return [i]6, 5, 7, 4, 8[/i] ?) So, is something broken or am I confused?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DGuy@BitsAtPlay avatar image
DGuy@BitsAtPlay answered
=== ADDENDUM === I'm getting similarly strange results when testing [i]getLatestStringList().getValues()[/i] When I create a new SyncableStringList and add the same values as above, [i]getLatestStringList().getValues()[/i] returns [i]"1", "10", "2", "3", "4"[/i]
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bipin@Amazon avatar image
Bipin@Amazon answered
I took a SyncableNumberList and kept on adding random value to it by setting the maxsize 10. when i have pull the SyncableNumberList objects.getValues()[i] loop from index 0,1,2....8,9. below is the result as expected getHighNumberList---Retrieves the high number list associated with the given name. (9,8,8,7,6,6,6,5,4,4) getLowNumberList--- Retrieves the low number list associated with the given name. (0,1,1,1,1,2,2,3,3,3) getLatestNumberList---Retrieves the latest number list associated with the given name.(1,1,9,1,3,2,4,6,0,5) Latest Number list will return the latest added number to the SyncableNumberList
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DGuy@BitsAtPlay avatar image
DGuy@BitsAtPlay answered
Thanks for the reply. I do think 'getLastestNumberList()', on Android, is broken in some way because it's behavior does not match it's description. [u]GameCircle SDK:[/u] 2.2.1 - Android [u]Android OS:[/u] 4.2.2 [u]Test Code:[/u] SyncableNumberList numList = AmazonGamesClient.getWhispersyncClient().getGameData().getLatestNumberList( "numlist" ); numList.add( 1 ); // ... more calls to numList.add() ... SyncableNumberElement[] vals = numList.getValues(); for( int n = 0; n < vals.length; n++ ) { // output 'vals[ n ].asInt()' } [u]Test Results (Numbers added (in order shown) --> Expected Output --> Actual Output):[/u] A) 1,2,3,4,5,6,7,8,9,10 --> 10,9,8,7,6 --> 1,2,3,4,5 B) 1,1,1,1,1,10,10,10,10,10 --> 10,10,10,10,10 --> 1,10 C) 1,1,1,1,1,1,1,1,1,1 --> 1,1,1,1,1 --> 1 D) 111, 999 --> 999,111 --> 111,999 Firstly, I'm assuming by "Latest" it is meant "Most Recent" - Am I correct in that assumption? If my assumption in correct, then the actual output is wrong and getLastestNumberList() and/or the add() method, is broken. It seems getLastestNumberList() is behaving like getLowestNumberList() and also like a Set (i.e. allowing each value to be added only once.)
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bipin@Amazon avatar image
Bipin@Amazon answered
I have rough code snippet, which has two button one to add the random number to SyncableNumberList another button to pull score from the SyncableNumberList of gameDataMap Button pullScore = (Button) findViewById(R.id.buttonwisper); pullScore.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SyncableNumberList LatestNumberList = gameDataMap.getLatestNumberList("SyncableNumberList"); Log.i(TAG, "LatestNumberList -"); for(int i=0; i < LatestNumberList.getValues().length; i++ ){ Log.i(TAG, LatestNumberList.getValues()[i].asInt()+","); } } }); Button submitscore = (Button) findViewById(R.id.buttonrand); submitscore.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int rand = new Random().nextInt(10); SyncableNumberList syncableNumberList = gameDataMap.getLatestNumberList("SyncableNumberList"); syncableNumberList.setMaxSize(20); syncableNumberList.add(rand); } });
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DGuy@BitsAtPlay avatar image
DGuy@BitsAtPlay answered
I know you are trying to be helpful but I feel I am not asking my question clearly enough ... THE SDK: GameCircle SDK 2.2.1 (Android) THE DOCUMENTATION: getLatestNumberList: A list of numbers in latest order (ex. List of N most recent scores) THE SETUP: 1) I create a new SyncableNumberList using getLatestNumberList (leaving it's max-size at the default of 5) 2) I add the following numbers, in the order shown, to the new list: 1,2,3,4,5,6,7,8,9 3) I call getValues() and get back: [1,2,3,4,5] THE PROBLEM: [1,2,3,4,5] are NOT the MOST RECENT values in LATEST ORDER, they are the OLDEST values in OLDEST-TO-NEWER ORDER According to the documentation, getValues should return: [9,8,7,6,5] THE QUESTION: Am I misunderstanding something, is the documentation wrong or is getLatestNumberList broken?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bipin@Amazon avatar image
Bipin@Amazon answered
Whispersync uses a timestamp (granular to one second) to determine the "Latest" values when added to the List, which is backed by a TreeSet for Android. When adding multiple values within the same second, they will each have the same timestamp. In the event of a tie, values are sorted by their natural sort order (lowest to highest). If spread out over more than a second apart, they will sort in the correct order. The intended use case for LatestNumberList and LatestStringList is that values added at different times across multiple devices are sorted as closely as possible to the order in which they were added in real-life. For example, a game may want to track the the most recent levels played or the most recent character configurations. Since multiple devices can be played at the same time and some devices may be offline during game play, sorting is done using a timestamp that we do our best effort to adjust by measured device clock-skew. We will update the documentation to make this more clear.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DGuy@BitsAtPlay avatar image
DGuy@BitsAtPlay answered
[i]> Whispersync uses a timestamp (granular to one second) ...[/i] Ahhh ... that explains it! :)
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.