modify hotspot

pull/1/head
deffpuzzl 2018-06-01 14:24:23 +08:00
parent 1ce47a8d64
commit 6808328888
5 changed files with 145 additions and 10 deletions

View File

@ -121,6 +121,7 @@ extern long lTvmConnect(SATvm *pstSavm, char *pszIp, long lPort, int times
extern long lTvmTruncate(SATvm *pstSavm, TABLE t); extern long lTvmTruncate(SATvm *pstSavm, TABLE t);
extern long lTvmGroup(SATvm *pstSavm, size_t *plOut, void **ppvOut); extern long lTvmGroup(SATvm *pstSavm, size_t *plOut, void **ppvOut);
extern long lTvmCount(SATvm *pstSavm, size_t *plCount); extern long lTvmCount(SATvm *pstSavm, size_t *plCount);
extern long lTvmClick(SATvm *pstSavm, ulong *puHits);
extern long lTvmInsert(SATvm *pstSavm); extern long lTvmInsert(SATvm *pstSavm);
extern long lTvmSelect(SATvm *pstSavm, void *pvOut); extern long lTvmSelect(SATvm *pstSavm, void *pvOut);
extern long lTvmQuery(SATvm *pstSavm, size_t *plOut, void **ppvOut); extern long lTvmQuery(SATvm *pstSavm, size_t *plOut, void **ppvOut);

View File

@ -96,6 +96,7 @@ typedef long CREATE;
#define OPERATE_ROLWORK 34 #define OPERATE_ROLWORK 34
#define OPERATE_CMTWORK 35 #define OPERATE_CMTWORK 35
#define OPERATE_ENDWORK 36 #define OPERATE_ENDWORK 36
#define OPERATE_CLICK 37
#define OPERATE_EXEEXIT 99 #define OPERATE_EXEEXIT 99
#define OPERATE_DEFAULT (OPERATE_SELECT | OPERATE_UPDATE | OPERATE_DELETE | OPERATE_INSERT) #define OPERATE_DEFAULT (OPERATE_SELECT | OPERATE_UPDATE | OPERATE_DELETE | OPERATE_INSERT)

View File

@ -1859,6 +1859,7 @@ long _lSelectField(SATvm *pstSavm, char *p, long lCount, TField *pstField, SQ
memset(szField, 0, sizeof(szField)); memset(szField, 0, sizeof(szField));
strncpy(szField, sfieldvalue(p, ",", i + 1), MAX_FIELD_LEN); strncpy(szField, sfieldvalue(p, ",", i + 1), MAX_FIELD_LEN);
strimall(szField); strimall(szField);
strimabout(szField, "(", ")");
if((!strcasecmp(szField, "count(*)") || if((!strcasecmp(szField, "count(*)") ||
!strcasecmp(szField, "count(1)"))) !strcasecmp(szField, "count(1)")))
@ -2215,6 +2216,42 @@ long _lCountSelect(SATvm *pstSavm, TIndex *pstIndex, char *pvData, bool bRmt)
return RC_SUCC; return RC_SUCC;
} }
/*************************************************************************************************
descriptionexecute SQL-click
parameters
return
RC_SUCC --success
RC_FAIL --failure
*************************************************************************************************/
long _lExeClick(SATvm *pstSavm, TIndex *pstIndex, char *pvData, bool bRmt)
{
ulong ulHits = 0;
long lRet, lTime = lGetTiskTime();
pstSavm->pstVoid = (void *)pvData;
pstSavm->tblName = pstIndex->m_table;
pstSavm->lSize = pstIndex->m_lRowSize;
if(bRmt)
lRet = lTvmClick(pstSavm, &ulHits);
else
lRet = lClick(pstSavm, &ulHits);
if(lRet != RC_SUCC)
{
fprintf(stderr, "count table (%s) failure, %s\n", pstIndex->m_szTable,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
lTime -= lGetTiskTime();
fprintf(stdout, "HITSPOT\n");
fprintf(stdout, "%zu\n", ulHits);
fflush(stdout);
fprintf(stdout, "---(%ld) records selected, ep(%d), %s---\n", pstSavm->m_lEffect,
pstSavm->m_lEType, sGetCostTime(-1 * lTime));
return RC_SUCC;
}
/************************************************************************************************* /*************************************************************************************************
descriptionexecute SQL-group descriptionexecute SQL-group
parameters parameters
@ -2853,6 +2890,17 @@ long _lParseSelect(SATvm *pstSavm, char *pszTable, char *pszField, char *pszW
TFree(pvWhere); TFree(pvWhere);
return RC_SUCC; return RC_SUCC;
} }
else if(!strcasecmp(pszField, "click"))
{
if(RC_SUCC != _lExeClick(pstSavm, &stIndex, pvWhere, bRmt))
goto ERR_SELECT;
vDestroyFiled(pstRoot);
pstRoot = NULL;
TFree(pstField);
TFree(pvWhere);
return RC_SUCC;
}
if(RC_SUCC != _lSelectField(pstSavm, pszField, lOut, pstField, &pstRoot)) if(RC_SUCC != _lSelectField(pstSavm, pszField, lOut, pstField, &pstRoot))
{ {
@ -4327,7 +4375,7 @@ void vInitialCustom()
//select nextval from SEQUENCE@SEQ_TEST //select nextval from SEQUENCE@SEQ_TEST
snprintf(g_stCustom.m_pszWord, ALLOC_CMD_LEN, "SET,FROM,WHERE,COUNT(1),MAX,MIN,NEXTVAL," snprintf(g_stCustom.m_pszWord, ALLOC_CMD_LEN, "SET,FROM,WHERE,COUNT(1),MAX,MIN,NEXTVAL,"
"ORDER BY,GROUP BY,SEQUENCE@,SYS_TVM_FIELD,SYS_TVM_DOMAIN,SYS_TVM_SEQUE,TABLE,INTO," "ORDER BY,GROUP BY,SEQUENCE@,SYS_TVM_FIELD,SYS_TVM_DOMAIN,SYS_TVM_SEQUE,TABLE,INTO,"
"ON,INFO,INDEX,VALUES,DEBUG [ON|OFF],SHOWMODE [ROW|COLUMN],SHOWSIZE [NUM],"); "ON,INFO,INDEX,VALUES,DEBUG [ON|OFF],SHOWMODE [ROW|COLUMN],SHOWSIZE [NUM],CLICK,");
g_stCustom.m_lWord = lgetstrnum(g_stCustom.m_pszWord, ","); g_stCustom.m_lWord = lgetstrnum(g_stCustom.m_pszWord, ",");
rl_attempted_completion_function = pMatchCompletion; rl_attempted_completion_function = pMatchCompletion;

View File

@ -1479,6 +1479,20 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace)); lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace));
return RC_SUCC; return RC_SUCC;
case OPERATE_CLICK:
if(RC_SUCC != lClick(pstSavm, (ulong *)pvData))
{
pstFace->m_lErrno = pstSavm->m_lErrno;
lData = sizeof(TFace);
}
else
{
lData = pstFace->m_lDLen + sizeof(ulong);
pstFace->m_lDLen = pstSavm->m_lEType;
}
lSendBuffer(pstCon->m_skSock, (void *)pstFace, lData);
return RC_SUCC;
case OPERATE_SELSEQ: case OPERATE_SELSEQ:
if(RC_SUCC != lSelectSeque(pstSavm, (char *)pvData, (ulong *)pvData)) if(RC_SUCC != lSelectSeque(pstSavm, (char *)pvData, (ulong *)pvData))
{ {
@ -3890,6 +3904,7 @@ void* pParsePacket(SATvm *pstSavm, void *pstVoid, TFace *pstFace, void *pvBuf
case OPERATE_TRCATE: case OPERATE_TRCATE:
case OPERATE_GROUP: case OPERATE_GROUP:
case OPERATE_COUNT: case OPERATE_COUNT:
case OPERATE_CLICK:
case OPERATE_EXTREM: case OPERATE_EXTREM:
memcpy(&pstCond->uFldcmp, pvData, sizeof(uint)); memcpy(&pstCond->uFldcmp, pvData, sizeof(uint));
for(i = 0, pvData += sizeof(uint); i < pstCond->uFldcmp; i ++) for(i = 0, pvData += sizeof(uint); i < pstCond->uFldcmp; i ++)
@ -4969,6 +4984,73 @@ long lTvmRenameTable(SATvm *pstSavm, TABLE to, TABLE tn)
return RC_SUCC; return RC_SUCC;
} }
/*************************************************************************************************
descriptionAPI - click
parameters:
pstSavm --stvm handle
plcount --count
return:
RC_SUCC --success
RC_FAIL --failure
*************************************************************************************************/
long lTvmClick(SATvm *pstSavm, ulong *pulHits)
{
RunTime *pstRun;
TFace *pstFace;
uint lWrite = sizeof(TFace);
if(!pstSavm || !pulHits)
{
pstSavm->m_lErrno = CONDIT_IS_NIL;
return RC_FAIL;
}
pstRun = (RunTime *)pGetRunTime(pstSavm, 0);
if(!pstRun->pstVoid)
{
pstSavm->m_lErrno = DOM_NOT_INITL;
return RC_FAIL;
}
pstFace = (TFace *)pstRun->pstVoid;
pstFace->m_lFind = pstSavm->lFind;
pstFace->m_lDLen = pstSavm->lSize;
pstFace->m_lErrno = TVM_DONE_SUCC;
pstFace->m_enum = OPERATE_CLICK;
pstFace->m_table = pstSavm->tblName;
checkbuffer(pstSavm, pstRun, 1);
vBuildPacket(pstRun->pstVoid, pstSavm->pstVoid, &pstSavm->stCond, &lWrite);
vAppendCond(pstRun->pstVoid, &pstSavm->stUpdt, &lWrite);
pstFace->m_lRows = lWrite - sizeof(TFace);
if(lWrite != lSendBuffer(pstSavm->m_skSock, (char *)pstRun->pstVoid, lWrite))
{
pstSavm->m_lErrno = SOCK_COM_EXCP;
return RC_FAIL;
}
if(sizeof(TFace) != lRecvBuffer(pstSavm->m_skSock, (char *)pstRun->pstVoid, sizeof(TFace)))
{
pstSavm->m_lErrno = SOCK_COM_EXCP;
return RC_FAIL;
}
pstSavm->m_lErrno = pstFace->m_lErrno;
if(0 != pstSavm->m_lErrno)
return RC_FAIL;
pstSavm->m_lEType = pstFace->m_lDLen;
if(sizeof(ulong) != lRecvBuffer(pstSavm->m_skSock, (void *)pstRun->pstVoid, sizeof(ulong)))
{
pstSavm->m_lErrno = SOCK_COM_EXCP;
return RC_FAIL;
}
memcpy((void *)pulHits, pstRun->pstVoid, sizeof(ulong));
return RC_SUCC;
}
/************************************************************************************************* /*************************************************************************************************
descriptionAPI - selectseque descriptionAPI - selectseque
parameters: parameters:

View File

@ -5271,6 +5271,7 @@ long _lSelectHash(SATvm *pstSavm, void *pvAddr, TABLE t, void *psvOut, size_t
return RC_FAIL; return RC_FAIL;
} }
pstTruck->m_lTimes ++;
*plData = pstList->m_lData; *plData = pstList->m_lData;
pvData = pstTruck->m_pvData; pvData = pstTruck->m_pvData;
if(FIRST_ROW & pstSavm->lFind) break; if(FIRST_ROW & pstSavm->lFind) break;
@ -5288,7 +5289,6 @@ long _lSelectHash(SATvm *pstSavm, void *pvAddr, TABLE t, void *psvOut, size_t
memcpy(psvOut, pvData, lGetRowSize(pstSavm->tblName)); memcpy(psvOut, pvData, lGetRowSize(pstSavm->tblName));
pthread_rwlock_unlock(prwLock); pthread_rwlock_unlock(prwLock);
pstTruck->m_lTimes ++;
return RC_SUCC; return RC_SUCC;
} }
@ -5350,6 +5350,7 @@ long _lSelectGroup(SATvm *pstSavm, void *pvAddr, TABLE t, void *psvOut, size_
return RC_FAIL; return RC_FAIL;
} }
pstTruck->m_lTimes ++;
*plData = pstList->m_lData; *plData = pstList->m_lData;
pvData = pstTruck->m_pvData; pvData = pstTruck->m_pvData;
if(FIRST_ROW & pstSavm->lFind) break; if(FIRST_ROW & pstSavm->lFind) break;
@ -5367,7 +5368,6 @@ long _lSelectGroup(SATvm *pstSavm, void *pvAddr, TABLE t, void *psvOut, size_
memcpy(psvOut, pvData, lGetRowSize(pstSavm->tblName)); memcpy(psvOut, pvData, lGetRowSize(pstSavm->tblName));
pthread_rwlock_unlock(prwLock); pthread_rwlock_unlock(prwLock);
pstTruck->m_lTimes ++;
return RC_SUCC; return RC_SUCC;
} }
@ -5424,6 +5424,7 @@ long _lSelectTruck(SATvm *pstSavm, void *pvAddr, TABLE t, void *psvOut, size_
*plData = lOffset; *plData = lOffset;
lOffset+= lGetRowTruck(t); lOffset+= lGetRowTruck(t);
pstTruck->m_lTimes ++;
pvData = pstTruck->m_pvData; pvData = pstTruck->m_pvData;
if(FIRST_ROW & pstSavm->lFind) break; if(FIRST_ROW & pstSavm->lFind) break;
} }
@ -5437,7 +5438,6 @@ long _lSelectTruck(SATvm *pstSavm, void *pvAddr, TABLE t, void *psvOut, size_
memcpy(psvOut, pvData, lGetRowSize(pstSavm->tblName)); memcpy(psvOut, pvData, lGetRowSize(pstSavm->tblName));
pthread_rwlock_unlock(prwLock); pthread_rwlock_unlock(prwLock);
pstTruck->m_lTimes ++;
return RC_SUCC; return RC_SUCC;
} }
@ -5989,6 +5989,7 @@ long _lQueryHash(SATvm *pstSavm, void *pvAddr, TABLE t, size_t *plOut, void *
return RC_FAIL; return RC_FAIL;
} }
pstTruck->m_lTimes ++;
memcpy(*ppsvOut + (lPos - lGetRowSize(t)), pstTruck->m_pvData, lGetRowSize(t)); memcpy(*ppsvOut + (lPos - lGetRowSize(t)), pstTruck->m_pvData, lGetRowSize(t));
if(SELF_POS_UNUSE == pstList->m_lNext) break; if(SELF_POS_UNUSE == pstList->m_lNext) break;
} }
@ -6056,6 +6057,7 @@ long _lQueryGroup(SATvm *pstSavm, void *pvAddr, TABLE t, size_t *plOut, void
return RC_FAIL; return RC_FAIL;
} }
pstTruck->m_lTimes ++;
memcpy(*ppsvOut + (lPos - lGetRowSize(t)), pstTruck->m_pvData, lGetRowSize(t)); memcpy(*ppsvOut + (lPos - lGetRowSize(t)), pstTruck->m_pvData, lGetRowSize(t));
if(SELF_POS_UNUSE == pstList->m_lNext) break; if(SELF_POS_UNUSE == pstList->m_lNext) break;
} }
@ -6110,6 +6112,7 @@ long _lQueryTruck(SATvm *pstSavm, void *pvAddr, TABLE t, size_t *plOut, void
return RC_FAIL; return RC_FAIL;
} }
pstTruck->m_lTimes ++;
memcpy(*ppsvOut + (lPos - lGetRowSize(t)), pstTruck->m_pvData, lGetRowSize(t)); memcpy(*ppsvOut + (lPos - lGetRowSize(t)), pstTruck->m_pvData, lGetRowSize(t));
lOffset += lGetRowTruck(t); lOffset += lGetRowTruck(t);
} }
@ -9842,6 +9845,7 @@ long _lClickGroup(SATvm *pstSavm, void *pvAddr, TABLE t, ulong *puHits)
} }
pvData = pstTruck->m_pvData; pvData = pstTruck->m_pvData;
*puHits = pstTruck->m_lTimes;
if(FIRST_ROW & pstSavm->lFind) break; if(FIRST_ROW & pstSavm->lFind) break;
} }
@ -9856,7 +9860,6 @@ long _lClickGroup(SATvm *pstSavm, void *pvAddr, TABLE t, ulong *puHits)
} }
pthread_rwlock_unlock(prwLock); pthread_rwlock_unlock(prwLock);
*puHits = pstTruck->m_lTimes;
return RC_SUCC; return RC_SUCC;
} }
@ -9914,6 +9917,7 @@ long _lClickHash(SATvm *pstSavm, void *pvAddr, TABLE t, ulong *puHits)
} }
pvData = pstTruck->m_pvData; pvData = pstTruck->m_pvData;
*puHits = pstTruck->m_lTimes;
if(FIRST_ROW & pstSavm->lFind) break; if(FIRST_ROW & pstSavm->lFind) break;
} }
@ -9928,7 +9932,6 @@ long _lClickHash(SATvm *pstSavm, void *pvAddr, TABLE t, ulong *puHits)
} }
pthread_rwlock_unlock(prwLock); pthread_rwlock_unlock(prwLock);
*puHits = pstTruck->m_lTimes;
return RC_SUCC; return RC_SUCC;
} }
@ -9982,6 +9985,7 @@ long _lClickTruck(SATvm *pstSavm, void *pvAddr, TABLE t, ulong *puHits)
} }
lOffset+= lGetRowTruck(t); lOffset+= lGetRowTruck(t);
*puHits = pstTruck->m_lTimes;
pvData = pstTruck->m_pvData; pvData = pstTruck->m_pvData;
if(FIRST_ROW & pstSavm->lFind) break; if(FIRST_ROW & pstSavm->lFind) break;
} }
@ -9994,7 +9998,6 @@ long _lClickTruck(SATvm *pstSavm, void *pvAddr, TABLE t, ulong *puHits)
} }
pthread_rwlock_unlock(prwLock); pthread_rwlock_unlock(prwLock);
*puHits = pstTruck->m_lTimes;
return RC_SUCC; return RC_SUCC;
} }