コード例 #1
0
ファイル: convtest.cpp プロジェクト: IsmaelAli/snap
void test_ints(){
  TTableContext context;
  Schema schema;
  schema.Add(TPair<TStr,TAttrType>("src",atInt));
  schema.Add(TPair<TStr,TAttrType>("dst",atInt));
  TStr wikifilename = "/dfs/scratch0/viswa/wiki_Vote.txt";

  PTable wikitable = TTable::LoadSS(schema, wikifilename, &context, '\t', TBool(false));
  printf("Loaded the table!\n");
  PUNGraph pungraph = TSnap::ToGraph<PUNGraph>(wikitable,schema[0].GetVal1(),schema[1].GetVal1(),aaFirst);
  printf("Made the TUNGraph of %d nodes and %d edges.\n",(*pungraph).GetNodes(),(*pungraph).GetEdges());
  PNGraph pngraph = TSnap::ToGraph<PNGraph>(wikitable,schema[0].GetVal1(),schema[1].GetVal1(),aaFirst);
  printf("Made the TNGraph of %d nodes and %d edges.\n",(*pngraph).GetNodes(),(*pngraph).GetEdges());
  PNGraphMP pngraphmp = TSnap::ToGraphMP<PNGraphMP>(wikitable,schema[0].GetVal1(),schema[1].GetVal1());
  printf("Made the TNGraphMP of %d nodes and %d edges.\n",(*pngraphmp).GetNodes(),(*pngraphmp).GetEdges());

//  PNGraphMP pngraphmp_2 = TSnap::ToGraphMP3<PNGraphMP>(wikitable,schema[0].GetVal1(),schema[1].GetVal1());
//  printf("Made the TNGraphMP of %d nodes and %d edges with MP2.\n",(*pngraphmp_2).GetNodes(),(*pngraphmp_2).GetEdges());

  printf("Tested graph conversion with ints.\n");

  TVec<TStr> emptyattrv;
  PNEANet pneanet = TSnap::ToNetwork<PNEANet>(wikitable,schema[0].GetVal1(),schema[1].GetVal1(),emptyattrv, emptyattrv,emptyattrv,aaFirst);
  printf("Made the PNEANet of %d nodes and %d edges.\n", (*pneanet).GetNodes(),(*pneanet).GetEdges());

  PNEANetMP pneanetmp = TSnap::ToNetworkMP<PNEANetMP>(wikitable,schema[0].GetVal1(),schema[1].GetVal1(),aaFirst);
  printf("Made the PNEANetMP of %d nodes and %d edges.\n", (*pneanetmp).GetNodes(),(*pneanet).GetEdges());

  PNEANetMP pneanetmp2 = TSnap::ToNetworkMP2<PNEANetMP>(wikitable,schema[0].GetVal1(),schema[1].GetVal1(),aaFirst);
  printf("Made the PNEANetMP of %d nodes and %d edges with MP2.\n", (*pneanetmp2).GetNodes(),(*pneanetmp).GetEdges());

  printf("Tested network conversions with ints.\n");

  
}
コード例 #2
0
ファイル: analyzer.cpp プロジェクト: snap-stanford/curis-2012
DCluster::DCluster(TStr LineInput) {
  // Parse start/end date
  TStrV Params;
  LineInput.SplitOnStr("\t", Params);
  Id = TInt(Params[0].GetInt());
  Start = TSecTm::GetDtTmFromYmdHmsStr(Params[1]);
  End = TSecTm::GetDtTmFromYmdHmsStr(Params[2]);
  uint StartDay = Start.GetInUnits(tmuDay);
  uint EndDay = End.GetInUnits(tmuDay);
  DiffDay = EndDay - StartDay + 1;

  // Stats/size
  Unique = TInt(Params[3].GetInt());
  Size = TInt(Params[4].GetInt());
  NumPeaks = TInt(Params[5].GetInt());
  RepStrLen = TInt(Params[6].GetInt());

  // Strings
  RepStr = Params[7];
  RepURL = Params[8];

  // Peak times
  First = TSecTm::GetDtTmFromYmdHmsStr(Params[9]);
  Last = TSecTm::GetDtTmFromYmdHmsStr(Params[10]);
  Peak = TSecTm::GetDtTmFromYmdHmsStr(Params[11]);
  bool ArchiveBool = true;
  Params[12].IsBool(ArchiveBool);
  Archived = TBool(ArchiveBool);
  DiscardState = TInt(Params[13].GetInt());
}
コード例 #3
0
ファイル: CONPICS.CPP プロジェクト: kuailexs/symbiandump-os2
EXPORT_C void CXzeDoor::InternalizeL(RReadStream& aStream)
// Load this picture
//
{
    CXzePicture::InternalizeL(aStream);
    iAlwaysFailToDetach=TBool(aStream.ReadUint8L());
}
コード例 #4
0
void CCntFileManagerMsgHandler::SetDatabaseDriveL(const RMessage2& aMessage)
	{
	// Non file-specific. Does not require manager instance.
	// Parameter 1 is the integer drive 0-25.
	// Parameter 2 in the copy boolean.
	Server().Controller().SetDatabaseDriveL(TDriveNumber(aMessage.Int0()),TBool(aMessage.Int1()));
	aMessage.Complete(KErrNone);
	}
コード例 #5
0
TBool TBluetoothHciCommands::operator[](TInt aOffset) const
	{
	if (aOffset > KBluetoothHciCommandsBytes * 8)
		{
		CommandsPanic(ERangeTooLarge);
		}
	TInt byte = aOffset / 8;
	TInt offset = aOffset - (byte * 8);
	TUint8 byteval = iCommands[byte];
	return TBool(iCommands[byte] & (1<<offset));
	}
コード例 #6
0
void CCntItemMsgHandler::SetAsyncActivityL(const RMessage2& aMessage)
	{
	CheckForManagerL();
	TBool asyncActivity = TBool(aMessage.Int0());
	// Create and then process appropriate request using state machine.
	CCntRequest* request = NULL;
	if (asyncActivity)
		{
		request = CReqAsyncActivity::NewLC(iSessionId, aMessage, iTimeOut);
		}
	else
		{
		request = CReqNoAsyncActivity::NewLC(iSessionId, aMessage, iTimeOut);
		}
	iManager->StateMachineL().ProcessRequestL(request); // ownership transferred
	
	// ProcessRequestL received ownership of the request, the request only need
	// to be popped from CleanupStack.		
	CleanupStack::Pop(request);
	}
コード例 #7
0
ファイル: analyzer.cpp プロジェクト: snap-stanford/curis-2012
TStr DCluster::GetClusterString(TQuoteBase *QB, TDocBase *DB, TCluster& C, TFreqTripleV &FreqV, TInt NumPeaks, TStr &End) {
  TStr Response;
  TSecTm Start;
  TStr RepStr, RepURL;
  C.GetBirthDate(Start);
  C.GetRepresentativeQuoteString(RepStr, QB);
  C.GetRepresentativeQuoteURL(QB, DB, RepURL);
  TStrV QuoteV;
  RepStr.SplitOnStr(" ", QuoteV);

  TSecTm First, Last, Peak;
  DCluster::GetFMP(FreqV, First, Last, Peak, RepStr);

  Response = C.GetId().GetStr() + "\t" + Start.GetDtYmdStr() + "\t" + End + "\t";
  Response += C.GetNumUniqueQuotes().GetStr() + "\t" + C.GetNumQuotes().GetStr() + "\t";
  Response += NumPeaks.GetStr() + "\t" + TInt(QuoteV.Len()).GetStr() + "\t";
  Response += RepStr + "\t" + RepURL + "\t";
  Response += First.GetYmdTmStr() + "\t" + Last.GetYmdTmStr() + "\t" + Peak.GetYmdTmStr() + "\t";
  Response += TBool::GetStr(TBool(C.IsArchived())) + "\t" + C.GetDiscardState().GetStr();

  return Response;
}
コード例 #8
0
ファイル: VWSSESSN.CPP プロジェクト: cdaffara/symbiandump-mw1
void CVwsSession::EnableServerEventTimeOut(const RMessage2& aMessage)
	{
	iServer.EnableServerEventTimeOut(TBool(REINTERPRET_CAST(TInt32,aMessage.Ptr0())));
	}
コード例 #9
0
TInt TestTRawDigitiserEvent::TestEvents()
	{
	if(!(iDigitiser3DEvent.Type()==0))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	iDigitiser3DEvent.Set(iType);
	if(!(iDigitiser3DEvent.Type()==iType))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	iDigitiser3DEvent.SetPointerNumber(iPointerNumber);
	if(!(iPointerNumber == iDigitiser3DEvent.PointerNumber()))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	iDigitiser3DEvent.Set(iType,iScanCode);
	//Set the Type temporarily to get through the assertion 
	iDigitiser3DEvent.Set(TRawEvent::EKeyDown);
    if(!(iScanCode==iDigitiser3DEvent.ScanCode()))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	iDigitiser3DEvent.Set(iType,iX,iY);
	//Set the Type temporarily to get through the assertion
	iDigitiser3DEvent.Set(TRawEvent::EPointerMove);
	if(!( (iX==iDigitiser3DEvent.Pos().iX) && (iY==iDigitiser3DEvent.Pos().iY) ))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	iDigitiser3DEvent.Set(iType,iX,iY,iZ);
	//Set the Type temporarily to get through the assertion
	iDigitiser3DEvent.Set(TRawEvent::EPointerMove);
	if(!((iX==iDigitiser3DEvent.Pos3D().iX) && (iY==iDigitiser3DEvent.Pos3D().iY) && (iZ==iDigitiser3DEvent.Pos3D().iZ) ))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	iDigitiser3DEvent.SetTip(iTip);
	if(!(TBool(iTip) == iDigitiser3DEvent.IsTip()))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	iDigitiser3DEvent.SetTilt(iType,iPhi,iTheta);
	//Set the Type temporarily to get through the assertion
	iDigitiser3DEvent.Set(TRawEvent::EPointer3DTilt);
	TAngle3D rawEventAnge3D=iDigitiser3DEvent.Tilt();
	if(!((rawEventAnge3D.iPhi==iPhi) && (rawEventAnge3D.iTheta==iTheta)))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	iDigitiser3DEvent.SetRotation(iType,iAlpha);
	//Set the Type temporarily to get through the assertion
	iDigitiser3DEvent.Set(TRawEvent::EPointer3DRotation);
	if(!(iAlpha == iDigitiser3DEvent.Rotation()))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	iDigitiser3DEvent.Set(iType,iX+1,iY+1,iZ+1,iPhi+1,iTheta+1,iAlpha+1);
	//Set the Type temporarily to get through the assertion
	iDigitiser3DEvent.Set(TRawEvent::EPointer3DTiltAndMove);
	if(!( ((iX+1)==iDigitiser3DEvent.Pos3D().iX) && ((iY+1)==iDigitiser3DEvent.Pos3D().iY) && ((iZ+1)==iDigitiser3DEvent.Pos3D().iZ)))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
    rawEventAnge3D=iDigitiser3DEvent.Tilt();
	if(!((rawEventAnge3D.iPhi==iPhi+1) &&(rawEventAnge3D.iTheta==iTheta+1)))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	if(!((iAlpha+1) == iDigitiser3DEvent.Rotation()))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
#ifndef __X86GMP__
	iDigitiser3DEvent.Set(iType,iX+2,iY+2,iZ+2,static_cast<TUint8>(iPointerNumber+1));
	//Set the Type temporarily to get through the assertion
	iDigitiser3DEvent.Set(TRawEvent::EPointer3DTiltAndMove);
  	if(!(((iX+2)==iDigitiser3DEvent.Pos3D().iX) && ((iY+2)==iDigitiser3DEvent.Pos3D().iY) && ((iZ+2)==iDigitiser3DEvent.Pos3D().iZ)))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
	if(!((iPointerNumber+1) == iDigitiser3DEvent.PointerNumber()))
		{Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;}
#endif //__X86GMP__
	
	NKern::ThreadEnterCS();
	// queue the event
	Kern::AddEvent(iDigitiser3DEvent);
	NKern::ThreadLeaveCS();
	return KErrNone;
	}
コード例 #10
0
ファイル: lsh.cpp プロジェクト: EDzhangjianyu/snap
TLSHash::CosineHash::CosineHash(TRnd &Gen, int Dim) {
  for (int i=0; i<Dim; i++) {
    Hyperplane.Add(TBool(TBool::GetRnd()));
  }
}
コード例 #11
0
ファイル: TableIndexTest.cpp プロジェクト: JohnMatta/snap
void test_strs() {

  TTableContext context;
  Schema schema;
  schema.Add(TPair<TStr,TAttrType>("src",atStr));
  schema.Add(TPair<TStr,TAttrType>("dst",atStr));
  TStr wikifilename = "/dfs/scratch0/viswa/wiki_Vote.txt";

  PTable wikitable = TTable::LoadSS(schema, wikifilename, &context, '\t', TBool(false));

  TIntV rowidx1, rowidx2, rowidx3;
  double delta1, delta2, delta3;
  struct timeval start, end;
  printf("Str: Before indexing ...\n");
  gettimeofday(&start, NULL);
  for (int i = 0 ; i < 100; i++) rowidx1 = wikitable->GetStrRowIdxByMap("src", 7096);
  gettimeofday(&end, NULL);
  delta1 = ((end.tv_sec - start.tv_sec)* 1000000u + end.tv_usec - start.tv_usec)/1.e6;

  gettimeofday(&start, NULL);
  for (int i = 0 ; i < 100; i++) rowidx2 = wikitable->GetStrRowIdxByMap("src", 7114);
  gettimeofday(&end, NULL);
  delta2 = ((end.tv_sec - start.tv_sec)* 1000000u + end.tv_usec - start.tv_usec)/1.e6;

  gettimeofday(&start, NULL);
  for (int i = 0 ; i < 100; i++) rowidx3 = wikitable->GetStrRowIdxByMap("src", 0);
  gettimeofday(&end, NULL);
  delta3 = ((end.tv_sec - start.tv_sec)* 1000000u + end.tv_usec - start.tv_usec)/1.e6;


  printf("Time 1: %f\tTime 2: %f\t Time 3: %f\n", delta1, delta2, delta3);
  printf("%d %d\n", rowidx1[0], rowidx2[0]);

  printf("Row Idx3: ");
  for (int i = 0 ; i < rowidx3.Len() ; i++ ) {
    printf("%d ", rowidx3[i]);
  }
  printf("\n");

  gettimeofday(&start, NULL);
  wikitable->RequestIndexStrMap("src");
  gettimeofday(&end, NULL);
  delta1 = ((end.tv_sec - start.tv_sec)* 1000000u + end.tv_usec - start.tv_usec)/1.e6;
  printf("Str: Time to index: %f\n", delta1);


  printf("Str: After indexing ...\n");
  gettimeofday(&start, NULL);
  for (int i = 0 ; i < 100; i++) rowidx1 = wikitable->GetStrRowIdxByMap("src", 7096);
  gettimeofday(&end, NULL);
  delta1 = ((end.tv_sec - start.tv_sec)* 1000000u + end.tv_usec - start.tv_usec)/1.e6;

  gettimeofday(&start, NULL);
  for (int i = 0 ; i < 100; i++) rowidx2 = wikitable->GetStrRowIdxByMap("src", 7114);
  gettimeofday(&end, NULL);
  delta2 = ((end.tv_sec - start.tv_sec)* 1000000u + end.tv_usec - start.tv_usec)/1.e6;

  gettimeofday(&start, NULL);
  for (int i = 0 ; i < 100; i++) rowidx3 = wikitable->GetStrRowIdxByMap("src", 0);
  gettimeofday(&end, NULL);
  delta3 = ((end.tv_sec - start.tv_sec)* 1000000u + end.tv_usec - start.tv_usec)/1.e6;

  printf("Time 1: %f\tTime 2: %f\t Time 3: %f\n", delta1, delta2, delta3);
  printf("%d %d\n", rowidx1[0], rowidx2[0]);

  printf("Row Idx3: ");
  for (int i = 0 ; i < rowidx3.Len() ; i++ ) {
    printf("%d ", rowidx3[i]);
  }
  printf("\n");

  /*
  int i = 0;
  for (TRowIterator RowI = wikitable->BegRI(); RowI < wikitable->EndRI(); RowI++) {
    if (i > 100000)
    printf("%d %d %d\n", RowI.GetRowIdx(), RowI.GetStrMapByName("src"), RowI.GetStrMapByName("dst"));
    i++;
//    if (i > 10) break;
  }
  */
}
コード例 #12
0
// ---------------------------------------------------------------------------
// CBCTestHeadingPaneCase::TestHeadingPaneL
// ---------------------------------------------------------------------------
//
void CBCTestHeadingPaneCase::TestHeadingPaneL()
    {
    CEikFormattedCellListBox* listBox =
        new( ELeave ) CAknSinglePopupMenuStyleListBox;
    CleanupStack::PushL( listBox );

    CAknPopupList* popupList = CAknPopupList::NewL( listBox,
        R_AVKON_SOFTKEYS_SELECT_BACK,
        AknPopupLayouts::EPopupSNotePopupWindow );
    CleanupStack::PushL( popupList );
    AssertNotNullL( popupList, KAknPopupList );

    listBox->ConstructL( popupList, EAknListBoxMenuList );

    CAknPopupHeadingPane* head = new( ELeave ) CAknPopupHeadingPane();
    CleanupStack::PushL( head );
    AssertNotNullL( head, KAknPopupHeadingPane );
    head->SetContainerWindowL( *iContainer );

    TBufC<KFifteen> bufc( KHeading );
    TPtrC ptrc = bufc.Des();
    // Invoke CAknPopupHeadingPane's ConstructL()
    head->ConstructL( ptrc );
    AssertTrueL( ETrue, KConstructL );

    // Invoke CAknPopupHeadingPane's MinimumSize()
    TSize s = head->MinimumSize();
    AssertTrueL( ETrue, KMinimumSize );    

    // Invoke CAknPopupHeadingPane's HandlePointerEventL()
    TPointerEvent pointEvent;
    pointEvent.iType = TPointerEvent::EButton1Down;
    head->HandlePointerEventL( pointEvent );
    AssertTrueL( ETrue, KHandlePointerEventL );    

    // Invoke CAknPopupHeadingPane's SizeChanged()
    head->SizeChanged();
    AssertTrueL( ETrue, KSizeChanged );

    // Invoke CAknPopupHeadingPane's Prompt()
    head->Prompt();
    AssertTrueL( ETrue, KPrompt );

    // Invoke CAknPopupHeadingPane's PromptText()
    head->PromptText();
    AssertTrueL( ETrue, KPromptText );

    // Invoke CAknPopupHeadingPane's SetTextL()
    TBufC<KTwenty> otherBufc( KOtherHeading );
    TPtrC otherPtrc = otherBufc.Des();
    head->SetTextL( otherPtrc );
    AssertTrueL( ETrue, KSetTextL );

    // Invoke CAknPopupHeadingPane's SetLayout()
    head->SetLayout( CAknPopupHeadingPane::EListHeadingPane );
    AssertTrueL( ETrue, KSetLayout );

    // Invoke CAknPopupHeadingPane's SetHeaderImageL()
    TBuf<KMaxFileName> iconFile;
    iContainer->GetCoeEnv()->ReadResource( iconFile, 
                                           R_BCTESTPOPUPS_ICONFILE );

    CEikImage* image = new( ELeave ) CEikImage;
    CleanupStack::PushL( image ); // image
    CFbsBitmap* bitmap = NULL;
    CFbsBitmap* bitmapM = NULL;
    AknIconUtils::CreateIconL( bitmap,
                               bitmapM,
                               iconFile,
                               EMbmBctestpopupsTel,
                               EMbmBctestpopupsTelm ); 

    CleanupStack::PushL( bitmap ); // bitmap
    CleanupStack::PushL( bitmapM ); // bitmap mask

    image->SetPictureOwnedExternally( TBool( 0 ) );
    image->SetPicture( bitmap, bitmapM );

    head->SetHeaderImageL( image );
    AssertTrueL( ETrue, KSetHeaderImageL );

    CleanupStack::Pop( bitmapM );  
    CleanupStack::Pop( bitmap );
    CleanupStack::Pop( image );

     // Invoke CAknPopupHeadingPane's SetSkinFrameId()
    TAknsItemID aknsItemID;
    head->SetSkinFrameId( aknsItemID );
    AssertTrueL( ETrue, KSetSkinFrameId );

     // Invoke CAknPopupHeadingPane's SetSkinFrameCenterId()
    head->SetSkinFrameCenterId( aknsItemID );
    AssertTrueL( ETrue, KSetSkinFrameCenterId );    
    
    // Invoke CAknPopupHeadingPane's SetHeaderAnimationL()
    head->SetHeaderAnimationL( R_BCTESTPOPUPS_BITMAP_ANIMATION );
    AssertTrueL( ETrue, KSetHeaderAnimationL );    

    // Invoke CAknPopupHeadingPane's StartAnimationL()
    head->StartAnimationL();
    AssertTrueL( ETrue, KStartAnimationL );

    // Invoke CAknPopupHeadingPane's CancelAnimation()
    head->CancelAnimation();
    AssertTrueL( ETrue, KCancelAnimation );
         
    CleanupStack::PopAndDestroy( head ); 
    head = NULL;

    head = new( ELeave ) CAknPopupHeadingPane();
    CleanupStack::PushL( head );

    // Invoke CAknPopupHeadingPane's ConstructFromResourceL()
    TResourceReader reader;
    iContainer->GetCoeEnv()->CreateResourceReaderLC(
        reader, R_BCTESTPOPUPS_AVKON_HEADING );
    head->ConstructFromResourceL( reader );
    AssertTrueL( ETrue, KConstructFromResourceL );
    CleanupStack::PopAndDestroy(); //reader    

    CleanupStack::PopAndDestroy( head );    
    CleanupStack::PopAndDestroy( popupList );
    CleanupStack::PopAndDestroy( listBox );
    
    delete image;
    }