Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX - |
Contents
Index
![]() ![]() |
Part 2 Developing Applications by APIs | > Chapter 11 Developing C Applications | > 11.2 How to Use C APIs | > 11.2.2 Data Searches |
The response performance of the sort or aggregation can be stable by setting the maximum value of number of hits. If the number of hits exceeds the maximum value, the sort or aggregation process will be stopped and the number of hits corresponding to the search condition will be returned.
Add a condition to the search expression and narrow the scope of the search for sort or aggregation to prevent the number of hits exceeding the maximum value.
Use the ShunSetStatementAttr function to set the maximum value of number of hits.
The following diagram shows the flow of setting the maximum value of number of hits.
SHUNHSTMT StmtH; /* Allocate data manipulation handle */ ShunAllocHandle(ConH, &StmtH); /* Set the maximum value of number of hits */ ShunSetStatementAttr(StmtH, SHUN_ATTR_HIT_COUNT_LIMIT,10000); (1) /* Specify sort expressions and execute the search */ ShunSearch(StmtH, 1, NULL, 0, 30, "/document/base/prefecture == 'Sydney'", "/document/base/name, /document/base/price", "/document/base/price/text() DESC", &Hit_Cnt, &Return_Cnt, &Returnable_Cnt, &Rec_Id_Out, &Data, &First_Pos, &Last_Pos); /* Check whether the number of hits exceeds the maximum value */ ShunGetStatementAttr(StmtH, SHUN_ATTR_HIT_COUNT_LIMIT_OVER,&Attr_Value); (2) if(Attr_Value == SHUN_TRUE) { printf("The number of hits has exceeded the maximum value.\n"); printf("Number of hits = %d\n", Hit_Cnt); (3) } else { /* Extract search results */ printf("Number of hits = %d\n", Hit_Cnt); if(Hit_Cnt > 0) { for (i = 0; i < Return_Cnt; i++) { printf("[Result] Item No. %d = %s\n", i+1, Data[i].Data); } } } /* Release data manipulation handle */ ShunFreeHandle(StmtH); |
Set the maximum value of number of hits at the parameter in the ShunSetStatementAttr function.
If the sort expression is not set, the error will occur when executing the ShunSearch function.
Use the ShunGetStatementAttr function to check whether the number of hits exceeds the maximum value.
If the number of hits has exceeded the maximum value, only the number of hits can be extracted.
Contents
Index
![]() ![]() |