result set index fragmentation problem
-
anandkanatt
- Posts: 51
- Joined: 24 Nov 2006, 14:48
result set index fragmentation problem
Hi all,
I am stuck with an interesting problem;
STEP 1. I query 81 rows from DB
STEP2. I get the query done properly
STEP3. I send the result object back to the called extention.
STEP4. I get the result at client side.
Now when I print the Array which contains my 81 records i see that the order of the records has changed(at server end the order is proper). Why is this happening ?? is there a workaround ??
i could not notice any specific pattern for index fragmentation but all the time i run the application, same pattern of fragmentation occoured.
And i tried sorting but it dint seem working on my array i used both sort and sortOn methods.
and to make things worser all my smaller result set queries are working properly.
Please help
Regards
Anand
I am stuck with an interesting problem;
STEP 1. I query 81 rows from DB
STEP2. I get the query done properly
STEP3. I send the result object back to the called extention.
STEP4. I get the result at client side.
Now when I print the Array which contains my 81 records i see that the order of the records has changed(at server end the order is proper). Why is this happening ?? is there a workaround ??
i could not notice any specific pattern for index fragmentation but all the time i run the application, same pattern of fragmentation occoured.
And i tried sorting but it dint seem working on my array i used both sort and sortOn methods.
and to make things worser all my smaller result set queries are working properly.
Please help
Regards
Anand
AK
-
anandkanatt
- Posts: 51
- Joined: 24 Nov 2006, 14:48
hey can any one guess why the code given below makes SFS hang ? and also makes the java.exe run as if its has some sort of memory leak ... going on drinking all my memory.
This code is run in an extension at zone level. this code is connected with the 81 row problem because this is what is done to the queried rows in the extension.
What i am trying to achieve here is that, i have a list of rooms in my db and i query it from db; then i am checking if any room is already existing in server that match my room name/id ... if yes i want the object pushed into the response.db to have inRoom set to True.
Please help me with both problems of mine ....
Regards
Anand
Code: Select all
//-------------------------------<getPlots>--------------------\\
if (cmd == "getPlots") {
//Initialising the response object.
var response = {};
//response object command executed trace.
response._cmd = "getPlots";
//response object result = false (Default).
response.ok = false;
//response object errmsg = Error Message if any.
response.errmsg = "";
//response object max block user count if any.
response.max = 0;
//checking if any relations exists with the player or not
sql = "CALL stp_lkdrm_getPlots("+params.idBlock+");";
var queryRes = dbase.executeQuery(sql);
//response object district database data
response.db = [];
if (queryRes.size() != 0) {
// Cycle through all records in the ResultSet
for (var i = 0; i<queryRes.size(); i++) {
// Get a record
var tempRow = queryRes.get(i);
// This object will hold the record data that we'll send to the client
var item = {};
var sTempPlotAddress = params.idDistrict+"."+params.idQuarter+"."+params.idZone+"."+params.idBlock+"."+tempRow.getItem("plot_id");
for (var i in roomList) {
//Checking if plot exists or not ... if yes then we get the usercount
if (roomList[i].getName() == sTempPlotAddress) {
// From the record object we can get each field value
item.name = tempRow.getItem("plot_name");
item.id = tempRow.getItem("plot_id");
item.ucount = roomList[i].getUserCount();
response.max += roomList[i].getUserCount();
//Checking if the user is in the plot .... if yes we need
//to set the inRoom Property to true to render the plot map accordingly
if (roomList[i].getId() == fromRoom) {
item.inRoom = true;
} else {
item.inRoom = false;
}
} else {
// From the record object we can get each field value
item.name = tempRow.getItem("plot_name");
item.id = tempRow.getItem("plot_id");
item.ucount = 0;
item.inRoom = false;
}
} response.db.push(item);
}
response.ok = true;
} else {
response.errmsg = "Could not get the list of plots !";
response.ok = false;
}
_server.sendResponse(response, -1, null, [user]);
//-------------------------------</getPlots>--------------------\\
What i am trying to achieve here is that, i have a list of rooms in my db and i query it from db; then i am checking if any room is already existing in server that match my room name/id ... if yes i want the object pushed into the response.db to have inRoom set to True.
Please help me with both problems of mine ....
Regards
Anand
Last edited by anandkanatt on 28 Mar 2007, 07:33, edited 1 time in total.
AK
-
anandkanatt
- Posts: 51
- Joined: 24 Nov 2006, 14:48
-
anandkanatt
- Posts: 51
- Joined: 24 Nov 2006, 14:48
Hi Lapo ....
I got a partially working fix for my 1st problem .... by adding this sortOn with the above said parameters and casting my return datatype of id field to Number in client gave me the array almost perfect i.e i should have got rows in the order 1 to 81 but now i am getting Notice the Row id 41 comming after 81 and also specifying the Array.DESCENDING in sort and getting the other way
I am confused too about this behaviour of the code ... as i said before i have type casted the value of id to Number ... so now i dont know whats making a problem now 
can u give me some idea why or what is going wrong ??
I got a partially working fix for my 1st problem ....
Code: Select all
aPlotList.sortOn("id", Array.NUMERIC | Array.DESCENDING);Code: Select all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
41can u give me some idea why or what is going wrong ??
AK
-
anandkanatt
- Posts: 51
- Joined: 24 Nov 2006, 14:48
-
anandkanatt
- Posts: 51
- Joined: 24 Nov 2006, 14:48
-
anandkanatt
- Posts: 51
- Joined: 24 Nov 2006, 14:48
any body got any idea how or why this problem occurs ??
to make the problems worse when i make the result set i.e row count to sort from 81 (ODD) to 64(EVEN) i am able to get all the values properly sorted!
Does this error has something to do with off by one bug (O BOB)??
http://en.wikipedia.org/wiki/Off-by-one_error
Or does sorting has to do with odd and even arrays??
please help
Regards
Anand
to make the problems worse when i make the result set i.e row count to sort from 81 (ODD) to 64(EVEN) i am able to get all the values properly sorted!
Does this error has something to do with off by one bug (O BOB)??
http://en.wikipedia.org/wiki/Off-by-one_error
Or does sorting has to do with odd and even arrays??
please help
Regards
Anand
AK