concourse
concourse copied to clipboard
Order of values returned in select seems to be incorrect
[default/cash]$ add "baz", 10, 1
Returned 'true' in 0.011 sec
[default/cash]$ add "baz", 9, 1
Returned 'true' in 0.012 sec
[default/cash]$ add "baz", 9, 2
Returned 'true' in 0.01 sec
[default/cash]$ add "baz", 10, 2
Returned 'true' in 0.01 sec
[default/cash]$ select([1L, 2L])
Returned '
+------------------+
| Record | baz |
+------------------+
| 1 | [9, 10] |
| 2 | [9, 10] |
+------------------+
' in 0.027 sec
I thought the order of the values was supposed to be insertion order? but it seems to place them in sort order? Not sure if this is incorrect or not, but we should figure out.
Interesting enough, it always seems to display links in descending order:
+---------------------------------------------------------------------------------------------------------------+
| Record | bar | baz | foo | company | direct_reports | name | title | pi |
+---------------------------------------------------------------------------------------------------------------+
| 1447234653927000 | [1] | [true, @50] | [bar, baz] | null | null | null | null | null |
| 1447234653927006 | null | null | null | [Cinchapi] | [@2, @1] | [Jeff Nelson] | [CEO] | null |
| 1447234653928002 | null | null | null | null | null | null | null | [3] |
+---------------------------------------------------------------------------------------------------------------+
is it solved? for me this is the final result +------------------+ | Record | baz | +------------------+ | 1 | [10, 9] | | 2 | [10, 9] | +------------------+
@chandresh-pancholi can you create a unit test to either repro the bug or confirm it doesn't exist
Actually its not even putting them in descending order.It puts them in random order. For ex. add "baz", 10, 1 add "baz", 9, 1 add "baz", 7, 1 add "baz", 8, 1 add "baz", 9, 2 add "baz", 7, 2 add "baz", 10, 2
select([1L, 2L]) +------------------------+ | Record | baz | +------------------------+ | 1 | [9, 8, 10, 7] | | 2 | [9, 10, 7] | +------------------------+ ' in 0.038 sec
I see, I think in ConcourseServer we need to use a LinkedHashMap instead of a regular HashMap for the select methods
Sent from my iPhone
On Thu, Jun 16, 2016 at 9:01 AM -0400, "Chandresh Pancholi" [email protected] wrote:
Actually its not even putting them in descending order.It puts them in random order.
For ex.
add "baz", 10, 1
add "baz", 9, 1
add "baz", 7, 1
add "baz", 8, 1
add "baz", 9, 2
add "baz", 7, 2
add "baz", 10, 2
select([1L, 2L])
+------------------------+
| Record | baz |
+------------------------+
| 1 | [9, 8, 10, 7] |
| 2 | [9, 10, 7] |
+------------------------+
' in 0.038 sec
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
We are using LinkedHashMap.
@Override
@Atomic
@Batch
@ThrowsThriftExceptions
public Map<Long, Map<String, Set<TObject>>> selectRecords(
List<Long> records, AccessToken creds,
TransactionToken transaction, String environment) throws TException {
checkAccess(creds, transaction);
AtomicSupport store = getStore(transaction, environment);
Map<Long, Map<String, Set<TObject>>> result = Maps.newLinkedHashMap();
AtomicOperation atomic = null;
System.out.println("------------");
while (atomic == null || !atomic.commit()) {
atomic = store.startAtomicOperation();
try {
for (long record : records) {
result.put(record, atomic.select(record));
}
}
catch (AtomicStateException e) {
atomic = null;
}
}
return result;
}
My bad. Check in the classes that extend Store and make sure the select(record) methods are using a LinkedHashSet instead of a HashSet
Sent from my iPhone
On Thu, Jun 16, 2016 at 9:08 AM -0400, "Chandresh Pancholi" [email protected] wrote:
We are using LinkedHashMap.
@Override
@Atomic
@Batch
@ThrowsThriftExceptions
public Map<Long, Map<String, Set<TObject>>> selectRecords(
List<Long> records, AccessToken creds,
TransactionToken transaction, String environment) throws TException {
checkAccess(creds, transaction);
AtomicSupport store = getStore(transaction, environment);
Map<Long, Map<String, Set<TObject>>> result = Maps.newLinkedHashMap();
AtomicOperation atomic = null;
System.out.println("------------");
while (atomic == null || !atomic.commit()) {
atomic = store.startAtomicOperation();
try {
for (long record : records) {
result.put(record, atomic.select(record));
}
}
catch (AtomicStateException e) {
atomic = null;
}
}
return result;
}
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Will changes in concourse.thrift loads when concourse server runs?