/*
	Try to index if it is/was an openDML file
	with super Index

	audTrack is the index in Tracks of the audio track
	audioTrackNumber is either 0-> First track
				   1-> Second track
				   
	In case of openml file, audioTrack is enough
	In case of avi file, audioTrackNumber is used.				
	
*/
uint8_t		OpenDMLHeader::indexODML(uint32_t vidTrack)
{
uint32_t total;
	
	printf("Building odml video track\n");
	if(!scanIndex(vidTrack,&_idx,&total))
        {
                printf("Odml video index failed\n");
		return 0;
        }
 	_videostream.dwLength= _mainaviheader.dwTotalFrames=total;
	printf("\nBuilding odm audio tracks\n");
	for(int i=0;i<_nbAudioTracks;i++)
        {
		printf("\nDoing track %d of %d\n",i,_nbAudioTracks);
                if(!scanIndex(     _audioTracks[i].trackNum,
                                &(_audioTracks[i].index),
                                &(_audioTracks[i].nbChunks)))
                {
                        printf("Odml audio %d tracknum %d, index failed\n",i,_audioTracks[i].trackNum);
                        return 0;
                }
        }
        printf("Odml indexing succeeded\n");
	return 1;
}
/*
	Try to index if it is/was an openDML file
	with super Index

	audTrack is the index in Tracks of the audio track
	audioTrackNumber is either 0-> First track
				   1-> Second track
				   
	In case of openml file, audioTrack is enough
	In case of avi file, audioTrackNumber is used.				
	
*/
uint8_t		OpenDMLHeader::indexODML(uint32_t vidTrack,uint32_t audTrack,uint32_t audioTrackNumber)
{
uint32_t total;
	
	printf("Building odml video track\n");
	if(!scanIndex(vidTrack,&_idx,&total))
		return 0;
 	_videostream.dwLength= _mainaviheader.dwTotalFrames=total;
	if(audTrack!=0xff)
	{
		printf("Building odml audio track\n");
		if(!scanIndex(audTrack,&_audioIdx,&total))
		{
			_isaudiopresent=0;
			printf("Problem indexing audio!\n");
			return 1;		
		}
 		_nbAudioChunk=total;
	
	}
	return 1;
}
示例#3
0
Status Operators::IndexSelect(const string& result,       // Name of the output relation
                              const int projCnt,          // Number of attributes in the projection
                              const AttrDesc projNames[], // Projection list (as AttrDesc)
                              const AttrDesc* attrDesc,   // Attribute in the selection predicate
                              const Operator op,          // Predicate operator
                              const void* attrValue,      // Pointer to the literal value in the predicate
                              const int reclen)           // Length of a tuple in the output relation
{
  cout << "Algorithm: Index Select" << endl;
  
  /* Your solution goes here */
  Status indexStatus;
  Index scanIndex(attrDesc->relName, attrDesc->attrOffset, attrDesc->attrLen, (Datatype)attrDesc->attrType, 0, indexStatus);
  if (indexStatus != OK)
      return indexStatus;
  
  HeapFile indexHeapFile(result, indexStatus);
  if (indexStatus != OK)
      return indexStatus;
  HeapFileScan indexHeapScan (attrDesc->relName, indexStatus);
  if (indexStatus != OK)
      return indexStatus;
  Record newRecord, oldRecord;
  newRecord.length = reclen;
  newRecord.data = malloc (reclen);
  
  RID rid1, rid2;
  
  scanIndex.startScan(attrValue);
  while(scanIndex.scanNext(rid1)==OK){
      int offset = 0;
      indexStatus = indexHeapScan.getRandomRecord(rid1, oldRecord);
      if (indexStatus != OK){
          free(newRecord.data);
          return indexStatus;
      }
      for (int i = 0; i < projCnt; i++){
          memcpy((char*)(newRecord.data) + offset, (char*)(oldRecord.data) + projNames[i].attrOffset, projNames[i].attrLen);
          offset += projNames[i].attrLen;
      }
      indexStatus = indexHeapFile.insertRecord(newRecord, rid2);
      if (indexStatus != OK){
          free(newRecord.data);
          return indexStatus;
      }    
  }
  scanIndex.endScan();
  free(newRecord.data);
  return OK;
}
vector<pair<T_ID, uint32> > InvertedIndexMulDim::rangeQuery(vector<int>& queryLow, vector<int>& queryHigh, uint32 threshold){

	map<T_ID,uint32> counter;
	scanIndex(queryLow, queryHigh, counter);
	std::map<T_ID,uint32>::iterator cit;
	vector<pair<T_ID, uint32> > res;

	for(cit=counter.begin();cit!=counter.end();cit++){
		if(cit->second>=threshold){
			res.push_back(pair<T_ID,uint32>(cit->first,cit->second));
		}
	}

	cout<<"topk.size():"<<res.size()<<endl;

	return res;
}
vector<pair<T_ID, uint32> > InvertedIndexMulDim::topkQuery(vector<int>& queryLow, vector<int>& queryHigh, uint32 k){

	map<T_ID,uint32> counter;
	scanIndex(queryLow, queryHigh, counter);

	vector<pair<T_ID, uint32> > topk(k);

	partial_sort_copy(counter.begin(),
					counter.end(),
					topk.begin(),
					topk.end(),
					compfunc);

	cout<<"topk.size():"<<topk.size()<<endl;

	return topk;
}