📄 apitest.cpp
字号:
fclose(Infile);
Infile = NULL;
printf("\nFile Successfully Closed");
break;
case 5:
/*
If we are going to be doing some searching, we
need to start a retrieval session. (This causes
all parts of the index to be loaded into memory.)
If we are done searching, then we end the retrieval
session.
We decide which to do by watching the flag:
RetrievalSessinoOngoingFlag.
*/
if(RetrievalSessionOngoingFlag == BooleanTrue ) {
/* End the retrieval session. */
ixEndRetrievalSession(IndexManager,&Status);
if(Status < 0) {
printf("\nError Ending Retrieval Session :%d",Status);
}
RetrievalSessionOngoingFlag = BooleanFalse;
break;
}
/* Start the retrieval session. */
ixStartRetrievalSession(IndexManager,&Status);
if(Status < 0) {
printf("\nError Starting Retrieval Session: %d",Status);
}
else
RetrievalSessionOngoingFlag = BooleanTrue;
break;
case 6:
/*
If we have a distributed index then we need to set
the filename as to where we want to store the current
index data to. This must be done sometime during
the indexing and before the call to ixEndIndexingSession()
or ixFinalProcessIndex().
*/
printf("\nIndex Directory Location :");
gets(Choice);
strcpy(ScratchBuff, Choice);
printf("\nIndex File Name :");
gets(Choice);
ixSetFinalIndexDataFileNameAndPosition(Indexer,ScratchBuff, Choice, &Status);
if(Status < 0) {
printf("\nError: %d",Status);
}
break;
case 7:
/*
We are going to conduct a search. We'll store the results
in the result vector array allowing us to deal with multiple
result lists at once.
*/
printf("\nPlace Result Vector Where? (1-50) :");
gets(Choice);
VecPos1 = atoi(Choice);
printf("\nBoolean Query :");
fgets(TextQueryString,80,stdin);
strtok(TextQueryString,"\n\r");
/* Convert the query from the user's form to the standardized hex form. */
ixConvertQuery((UCharT *)TextQueryString,(UCharT *)HexQueryString);
printf("\nRanked Query :");
fgets(TextQueryString,80,stdin);
strtok(TextQueryString,"\n\r");
/* Convert the query from the user's form to the standardized hex form. */
ixConvertQuery((UCharT *)TextQueryString,(UCharT *)RankedHexQueryString);
/* Perform the actual query and store the results in the results array.*/
if(strlen(RankedHexQueryString) == 0)
Vector[VecPos1] = ixProcessQuery(IndexManager,NULL,(UCharT *)HexQueryString,&Status);
if(strlen(HexQueryString) == 0)
Vector[VecPos1] = ixProcessQuery(IndexManager,(UCharT *)RankedHexQueryString,NULL,&Status);
if(strlen(RankedHexQueryString) != 0 && strlen(HexQueryString) != 0)
Vector[VecPos1] = ixProcessQuery(IndexManager,(UCharT *)RankedHexQueryString,(UCharT *)HexQueryString,&Status);
break;
case 8:
/*
Now we are going to navigate the wordlist.
Before we can do that, we must call FindWord on a word to
position the wordlist cursor at a position within the wordlist.
*/
printf("\n1) Find Word");
printf("\n2) Current Word");
printf("\n3) Previous Word");
printf("\n4) Next Word\n:");
fgets(Choice,80,stdin);
strtok(Choice,"\n\r");
Result2 = atoi(Choice);
switch(Result2) {
case 1: printf("\nWord to Find :");
/* Get the word.*/
fgets(Choice,80,stdin);
strtok(Choice,"\n\r");
Length = strlen(Choice);
/* Make a pascal string out of the word. */
memmove(Choice+1,Choice,Length);
Choice[0] = Length;
/* Find the word. */
ixFindKey(IndexManager,&Cursor,(UCharT *)Choice,&Found, &NumRecords, &NumWords, &Status);
if(Status < 0)
printf("\nError :%d",Status);
if(Found == BooleanTrue) {
printf("\nWord Found");
}
else {
printf("\nWord Not Found");
}
break;
case 2:
/* Display the current key. */
ixCurrentKey(IndexManager,&Cursor,(UCharT *)Choice,&NumRecords, &NumWords,&Status);
Choice[Choice[0] +1] = 0;
if(Status < 0)
printf("\nError :%d",Status);
printf("\nCurrent Word : %s NumRecords : %ld, Num Words : %ld",Choice+1, NumRecords, NumWords);
break;
case 3:
/* Display the previous key. */
ixPreviousKey(IndexManager,&Cursor, (UCharT *)Choice,&NumRecords, &NumWords,&Status);
Choice[Choice[0] +1] = 0;
if(Status < 0)
printf("\nError :%d",Status);
printf("\nCurrent Word : %s NumRecords : %ld, Num Words : %ld",Choice +1, NumRecords, NumWords);
break;
case 4:
/* Display the next key. */
ixNextKey(IndexManager,&Cursor, (UCharT *)Choice,&NumRecords, &NumWords,&Status);
Choice[Choice[0] +1] = 0;
if(Status < 0)
printf("\nError :%d",Status);
printf("\nCurrent Word : %s NumRecords : %ld, Num Words : %ld",Choice+1, NumRecords, NumWords);
break;
};
break;
case 9:
/* Display the number of records in the index. */
ixNumberOfRecordsInIndex(IndexManager,&NumRecords,&Status);
printf("\nThe Number of Records is %ld",NumRecords);
break;
case 10:
/* Rewind a result vector in the results array.*/
printf("\nVector To Rewind (1-50) :");
gets(Choice);
VecPos1 = atoi(Choice);
ixVectorRewind(Vector[VecPos1],&Status);
if(Status < 0)
printf("\nError Rewinding Vector :%d",Status);
break;
case 11:
/* Get the current hit from the results vector.*/
printf("\nWhich Vector ? (1-50)");
gets(Choice);
VecPos1 = atoi(Choice);
ixVectorCurrentHit(Vector[VecPos1], &RecordNum, &WordNum, &CountNum, &HitWeight, &Status);
if(Status < 0) {
printf("\n Error %d",Status);
break;
}
printf("\nRecord Num = %ld, WordNum = %ld",RecordNum, WordNum);
break;
case 12:
/* Get the next hit in the results vector. */
printf("\nWhich Vector ? (1-50)");
gets(Choice);
VecPos1 = atoi(Choice);
ixVectorNextHit(Vector[VecPos1], &RecordNum, &WordNum, &CountNum, &HitWeight, &Status);
if(Status < 0) {
printf("\n Error %d",Status);
break;
}
printf("\nRecord Num = %ld, WordNum = %ld",RecordNum, WordNum);
break;
case 13:
/* Get the number of hits within the results list. */
printf("\nWhich Vector? (1-50)");
fgets(Choice,80,stdin);
strtok(Choice,"\n\r");
Result2 = atoi(Choice);
ixNumHits(Vector[Result2],&NumbHits,&NumRecords,&NumWords,&Status);
if(Status < 0) {
printf("\nError :%d",Status);
}
printf("\nNumHits = %ld, NumRecords = %ld, NumWords = %ld",NumbHits,NumRecords,NumWords);
break;
case 14:
/*
Delete a record number.
*/
printf("\nRecord Number To Delete :");
gets(Choice);
Result2 = atoi(Choice);
ixDeleteRecordNum(IndexManager,Result2,&Status);
printf("\nRecord %ld Deleted");
break;
case 15:
/*
Undelete a record number.
*/
printf("\nRecord Number To Undelete :");
gets(Choice);
Result2 = atoi(Choice);
ixUnDeleteRecordNum(IndexManager,Result2,&Status);
printf("\nRecord %ld Undeleted");
break;
case 16:
/*
Check to see if a specific record number has
been deleted.
*/
printf("\nRecord Number :");
gets(Choice);
Result2 = atoi(Choice);
Result2 = ixIsRecordDeleted(IndexManager,Result2,&Status);
if(Result2 == 1)
printf("\nRecord IS Deleted");
else
if(Result2 == 0)
printf("\nRecord is NOT Deleted");
else
printf("\nWeird Value Returned.");
break;
case 17:
/*
This outputs a stats file for the index.
This file is intended for use with some
upcoming products from Lextek International.
To output the stats file, you need to have
a retrieval session in progress on an opened
index.
*/
printf("\nStats DB File Name :");
fgets(Choice,80,stdin);
strtok(Choice,"\n\r");
ixOutputStatsFile(IndexManager,Choice,&Status);
if(Status == 0) {
printf("\nStats File Output Succesfully");
}
if(Status < 0) {
printf("\nError %d Outputting Stats File",Status);
}
break;
case 18:
/*
Get the results vector associated with the
current word in the wordlist cursor.
*/
printf("\nPlace Query Vector Where ? (1-50) :");
fgets(Choice,80,stdin);
strtok(Choice,"\n\r");
Result2 = atoi(Choice);
Vector[Result2] = ixGetCurrentQueryVector(IndexManager,&Cursor,&Status);
break;
case 19:
/*
Find a record ID from a record number. In order for this to
work, the record IDs must have been stored.
*/
printf("\nRecord Number Of ID To Get :");
fgets(Choice,80,stdin);
strtok(Choice,"\n\r");
Result2 = atol(Choice);
if(Result2 == 0)
Result2 = 1;
ixRetrieveRecordID(IndexManager,(unsigned char *)ScratchBuff,80,&BuffOffset,(unsigned char *) HexQueryString,Result2,&Status);
ScratchBuff[BuffOffset] = 0x00;
printf("\nRecord ID For Record %d Is: %s",Result2,ScratchBuff);
break;
case 20:
/*
Find a record number from a record ID. In order for this
to work, the record IDs must have been indexed.
*/
printf("\nRecord ID :");
fgets(Choice,80,stdin);
strtok(Choice,"\n\r");
strcpy(HexQueryString,"0x");
for(Counter = 0; Choice[Counter] != 0x00; Counter ++) {
ixCharToHex(Choice[Counter],(unsigned char *)ScratchBuff);
ScratchBuff[2] = 0x00;
strcat(HexQueryString,ScratchBuff);
}
ixFindRecordID(IndexManager,(unsigned char *)HexQueryString,&RecordNum,&Status);
printf("\nRecord Number Is :%ld",RecordNum);
break;
case 21:
/*
Retrieve text associated with a given record.
*/
printf("\nRecord Number of Text :");
fgets(Choice,80,stdin);
strtok(Choice,"\n\r");
Result2 = atoi(Choice);
ixRetrieveRecordData(IndexManager,(unsigned char *)ScratchBuff,80,&BuffOffset,Result2,&DataCursor,&Status);
ScratchBuff[BuffOffset] = 0;
printf("\nRecord Text :%s",ScratchBuff);
if(DataCursor.Done == BooleanTrue)
printf("\nRecord Done");
else
printf("\nRecord Not Done");
break;
case 22:
/*
Retrieve more record text with a given record. Note, you
need to call the above command to get record text first
to get the first chunk of text with a record.
*/
ixRetrieveMoreRecordData(IndexManager,(unsigned char *)ScratchBuff,80,&BuffOffset,&DataCursor,&Status);
ScratchBuff[BuffOffset] = 0;
printf("\nRecord Text :%s",ScratchBuff);
if(DataCursor.Done == BooleanTrue)
printf("\nRecord Done");
else
printf("\nRecord Not Done");
break;
case 23:
/*
This returns the status message associated with the current error code.
*/
printf("\nWhat is the error code :");
fgets(Choice,80,stdin);
strtok(Choice,"\n\r");
Result2 = atoi(Choice);
ixGetStatusMessage((StatusCodeT*) &Result2,Choice, 80);
printf("\n%s",Choice);
break;
case 24:
/*
This returns the amount of temporary disk space currently
used by the indexing process. This does not work after a
call to ixEndIndexingSession() or ixFinalProcessIndex().
However, it will let you know how much disk space is used.
You should not allow the amount of disk space used to be more
than 1/2 of the available disk space.
*/
ixGetTempDiskSpaceUsage(Indexer, &TempFileLength,&Status);
printf("\nTemp File Disk Usage :%ld",TempFileLength);
break;
case 0:
free(Buffer1);
free(Buffer2);
free(Buffer3);
delete IndexManager;
exit(1);
}; // End switch()
} // end for(;;)
return 1;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -