Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
import java.util.*;
import java.util.Date;
import java.io.*;
import java.sql.*;
//import oracle.jdbc.driver.*;
import java.util.Set;
/* Start time */
Date d=new Date();
long starttime,endtime;
d=new Date();
starttime=d.getTime();
FP.loadCylinderData();
d=new Date();
endtime=d.getTime();
System.out.println("FPGrowth Algorithm takes "+ ((starttime-
endtime)/1000)+ "seconds");
System.out.println("-------------this is the test for output
fptree-----------------");
}
}
class FPGrowth{
// Maintain hashmap<Integer(recordnumber),List<Integers(columnnumbers)>
//HashMap<Integer,List<Integer>> transactionFrequentItems = new
HashMap<Integer,List<Integer>>();
HashMap<Integer,HashMap<Integer,Integer>> transactionFrequentItems = new
HashMap<Integer,HashMap<Integer,Integer>>();
int diskptr=56,diskptr1=56,diskptr2=56;
for(int j=0;j<1257;j++){
for(int intval=0;intval<896;intval++){
try{
rand1.seek(diskptr);
cylinder1[j][intval]=rand1.readInt();
//System.out.println("integer value "+cylinder1[intval]);
diskptr+=4;
}
catch(IOException e){
System.out.println(e.getMessage()); }
}
for(int intval1=896;intval1<1792;intval1++){
try{
rand2.seek(diskptr1);
cylinder1[j][intval1]=rand2.readInt();
diskptr1+=4;
}
catch(IOException e){
System.out.println(e.getMessage()); }
}
for(int intval2=1792;intval2<2048;intval2++){
try{
rand3.seek(diskptr2);
cylinder1[j][intval2]=rand3.readInt();
diskptr2+=4;
}
catch(IOException e){
System.out.println(e.getMessage()); }
}
diskptr+=52; // already incremented 4 bytes in the loop
diskptr1+=52;
diskptr2+=52;
}
for(int cols=0;cols<MAX_CYLINDERS;cols++)//1257
{
for(int colval=0;colval<INTEGERS_IN_CYLINDER;colval++)//2048
{
int firstcolumn=cylinder1[cols][colval];
boolean check = false;
/* Checking whether the intergers are -Ve or +Ve */
if(firstcolumn < 0)
{
firstcolumn = -firstcolumn;
check = true;
}
if(check == true){
countval++;
}
countval += Integer.bitCount(firstcolumn);
}
//System.out.println(cols +" countval is "+
countval);
Cylinder_Count[cols]=countval;
// Minimum support 50 % --- 32766 , 75% -- 49150,
0.01% -6
}
System.out.println("Hash map Values"+ ItemCount);
}
for(int bitval=0;bitval<31;bitval++)
{
if(bitval < leadingZerosCount)
colbits[cols][bitval] = 0;
else
{ //colbits[cols][bitval] =
binary.charAt(index);
Character c= new
Character(binary.charAt(index));
colbits[cols][bitval] =
Integer.parseInt(c.toString());
index++;
}
//System.out.print(colbits[cols][bitval]);
}
}
/*for(int j=0;j<32;j++)
System.out.println( "bit value" +colbits[0][j]);
*/
// Find the frequent items for 32 transactions
frequentItemsMap=transactionFrequentItems.get(transactionId);
//if (frequentItemsList == null)
if (frequentItemsMap == null)
{
//transactionFrequentItems.put(tran
sactionId, frequentItemsList=new ArrayList<Integer>());
frequentItemsMap=new
HashMap<Integer,Integer>();
//frequentItemsMap.put(colnum,ItemC
ount.get(colnum));
transactionFrequentItems.put((Integer)transactionId,
(HashMap<Integer,Integer>)frequentItemsMap);
//System.out.println("Transaction
id value"+ transactionId);
}
//else
//frequentItemsList.add(colnum);
if(ItemCount.get(colnum) != null)
frequentItemsMap.put(colnum,ItemCount.get(colnum));
}
}
transactionId++;
}
}
//ItemCount = null; -- comment on 12.31.2011
//List<Integer> lst = Arrays.asList(cylinder1[]);
//lst.clear();
eachTransaction_FPTreeOrder(transactionFrequentItems); //
commented on sep 25 for testing
// Sort the Each transaction based on the Cylinder count Order and
insert into FP tree-- Added on 7/18/2011
public void
eachTransaction_FPTreeOrder(HashMap<Integer,HashMap<Integer,Integer>>
transactionFrequentItems){
System.out.println("transaction
itemsize"+transactionFrequentItems.size()+" fp tree trans
size"+FP_FrequentItemsets.length);
//fptreeObject.printFPTree();
}
// END - 7/18/2011
public Map<Integer,Integer> sortItems (Map<Integer,Integer>
unsortedItems) {