add hits api

1.2.3
DeffPuzzL 2018-03-14 14:40:10 +08:00
parent 1ad99b893f
commit 4e94e4b96d
3 changed files with 19 additions and 13 deletions

View File

@ -17,9 +17,10 @@ GROUP=group
EXTREME=extreme EXTREME=extreme
TRUNCATE=truncate TRUNCATE=truncate
DROP=drop DROP=drop
CLICK=click
PRESSURE=press_demo PRESSURE=press_demo
all: $(CREATE) $(INSERT) $(SELECT) $(QUERY) $(DELETE) $(UPDATE) $(COUNT) $(GROUP) $(EXTREME) $(TRUNCATE) $(DROP) $(PRESSURE) clean all: $(CREATE) $(INSERT) $(SELECT) $(QUERY) $(DELETE) $(UPDATE) $(COUNT) $(GROUP) $(EXTREME) $(TRUNCATE) $(DROP) $(PRESSURE) $(CLICK) clean
$(CREATE): create.o $(CREATE): create.o
$(CC) -o $@ $< $(LIBDIR) $(CC) -o $@ $< $(LIBDIR)
$(INSERT): insert.o $(INSERT): insert.o
@ -42,6 +43,8 @@ $(TRUNCATE): truncate.o
$(CC) -o $@ $< $(LIBDIR) $(CC) -o $@ $< $(LIBDIR)
$(DROP): drop.o $(DROP): drop.o
$(CC) -o $@ $< $(LIBDIR) $(CC) -o $@ $< $(LIBDIR)
$(CLICK): click.o
$(CC) -o $@ $< $(LIBDIR)
$(PRESSURE): press_demo.o $(PRESSURE): press_demo.o
$(CC) -o $@ $< $(LIBDIR) $(CC) -o $@ $< $(LIBDIR)

View File

@ -318,10 +318,10 @@ void vGetAction(char *s, long *plAction)
*************************************************************************************************/ *************************************************************************************************/
void vPrintFunc(char *s) void vPrintFunc(char *s)
{ {
fprintf(stdout, "\nUsage:\t%s -[tpu][hugldtui]\n", s); fprintf(stdout, "\nUsage:\t%s -[tpr][hugldtui]\n", s);
fprintf(stdout, "\t-t\t\t--table\n"); fprintf(stdout, "\t-t\t\t--table\n");
fprintf(stdout, "\t-p[hugldta]\t--debug\n"); fprintf(stdout, "\t-p[hugldta]\t--debug\n");
fprintf(stdout, "\t-u(ui)\t\t--reset lock\n"); fprintf(stdout, "\t-r\t\t--reset lock\n");
fprintf(stdout, "\n"); fprintf(stdout, "\n");
} }
@ -367,7 +367,7 @@ int main(int argc, char *argv[])
int iChoose = 0, iAction = 0; int iChoose = 0, iAction = 0;
memset(szCom, 0, sizeof(szCom)); memset(szCom, 0, sizeof(szCom));
while(-1 != (iChoose = getopt(argc, argv, "t:p:u::v?::"))) while(-1 != (iChoose = getopt(argc, argv, "t:p:r::v?::")))
{ {
switch(iChoose) switch(iChoose)
{ {
@ -375,11 +375,7 @@ int main(int argc, char *argv[])
iAction |= 1; iAction |= 1;
t = atol(optarg); t = atol(optarg);
break; break;
case 'u': case 'r':
if(!optarg)
strcpy(szCom, "u");
else
strcpy(szCom, optarg);
iAction |= 2; iAction |= 2;
break; break;
case 'p': case 'p':

View File

@ -5256,6 +5256,7 @@ 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 ++; pstTruck->m_lTimes ++;
return RC_SUCC; return RC_SUCC;
} }
@ -5799,7 +5800,6 @@ long _lQueryHash(SATvm *pstSavm, void *pvAddr, TABLE t, size_t *plOut, void *
continue; continue;
} }
pstTruck->m_lTimes ++;
lPos = (++ (*plOut)) * lGetRowSize(t); lPos = (++ (*plOut)) * lGetRowSize(t);
if(NULL == (*ppsvOut = (char *)realloc(*ppsvOut, lPos))) if(NULL == (*ppsvOut = (char *)realloc(*ppsvOut, lPos)))
{ {
@ -5867,7 +5867,6 @@ long _lQueryGroup(SATvm *pstSavm, void *pvAddr, TABLE t, size_t *plOut, void
continue; continue;
} }
pstTruck->m_lTimes ++;
lPos = (++ (*plOut)) * lGetRowSize(t); lPos = (++ (*plOut)) * lGetRowSize(t);
if(NULL == (*ppsvOut = (char *)realloc(*ppsvOut, lPos))) if(NULL == (*ppsvOut = (char *)realloc(*ppsvOut, lPos)))
{ {
@ -7296,6 +7295,7 @@ long _lUpdateIndex(SATvm *pstSavm, void *pvAddr, TABLE t, void *pvUpdate)
} }
pstSavm->pstVoid = pvUpdate; pstSavm->pstVoid = pvUpdate;
pstTruck->m_lTimes ++;
SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NULL); SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NULL);
if(!memcmp(szIdx, szOld, MAX_INDEX_LEN)) if(!memcmp(szIdx, szOld, MAX_INDEX_LEN))
{ {
@ -9977,16 +9977,23 @@ long lMountTable(SATvm *pstSavm, char *pszFile)
goto MOUNT_ERROR; goto MOUNT_ERROR;
} }
lEffect ++;
if(RC_SUCC != __lInsert(pstSavm, pstRun->m_pvAddr, pstSavm->tblName, uTimes)) if(RC_SUCC != __lInsert(pstSavm, pstRun->m_pvAddr, pstSavm->tblName, uTimes))
{
fprintf(stderr, "=>警告, 导入表:%s 第(%ld)条记录错误, %s, 跳过..\n",
sGetTableName(stTde.m_table), lEffect, sGetTError(pstSavm->m_lErrno));
continue; continue;
}
lEffect ++; pstSavm->m_lEffect ++;
} }
fclose(fp); fclose(fp);
TFree(pvData); TFree(pvData);
pstSavm->m_lEffect = lEffect;
pthread_rwlock_unlock(prwLock); pthread_rwlock_unlock(prwLock);
vTblDisconnect(pstSavm, pstSavm->tblName); vTblDisconnect(pstSavm, pstSavm->tblName);
fprintf(stdout, "导入表:%s 有效记录:%ld, completed successfully !!\n",
sGetTableName(stTde.m_table), lEffect);
return RC_SUCC; return RC_SUCC;
MOUNT_ERROR: MOUNT_ERROR: