edu.utdallas.paged.mem.cache
Class CacheBase

java.lang.Object
  extended by edu.utdallas.paged.mem.cache.CacheBase
Direct Known Subclasses:
CacheObject, CachePredicate, CacheSEfficient, CacheSubject, CacheSubjectObject, CacheSubjectPredicateObject, CacheSubjectRandomAlgorithm

public abstract class CacheBase
extends java.lang.Object

Abstract class that defines the base methods for any buffer

Author:
vaibhav

Field Summary
 int delayFactor
          The delay factor determines the amount of triples to be left in memory
static int graphId
          The graph id
 java.util.LinkedHashMap<java.lang.Object,CacheAlgorithmBase> hashMap
          The actual buffer is maintained as a hash map
 int id
          An identifier that determines the position of a given URI in a Lucene index
 boolean isFileCreated
          A variable to test if Lucene indexes are already created
 boolean isObjFileCreated
          A variable to test if Lucene indexes are already created
 boolean isPredFileCreated
          A variable to test if Lucene indexes are already created
 boolean isSubFileCreated
          A variable to test if Lucene indexes are already created
 PagedNTripleWriter luceneWriter
          A N-Triple writer to write triples to a Lucene index
 java.io.File objF
          The temporary object Lucene index
 org.apache.lucene.index.IndexWriter objWriter
          An index writer to create the object Lucene index
 java.io.File predF
          The temporary predicate Lucene index
 org.apache.lucene.index.IndexWriter predWriter
          An index writer to create the predicate Lucene index
static int size
          The size of the current buffer
 java.io.File subF
          The temporary subject Lucene index
 org.apache.lucene.index.IndexWriter subWriter
          An index writer to create the subject Lucene index
 long timestamp
          The current timestamp value
 boolean writeObject
          Check if the object Lucene index is created
 boolean writeSubject
          Check if the subject Lucene index is created
 
Constructor Summary
CacheBase()
          Constructor initializes the hash map with the key as the node (as an Object) and the memory management algorithm as the value
 
Method Summary
 void calculateIndividualClustering(java.util.List<CacheAlgorithmBase> o, edu.utdallas.paged.mem.PagedNodeToTriplesMapBase subjects, edu.utdallas.paged.mem.PagedNodeToTriplesMapBase predicates, edu.utdallas.paged.mem.PagedNodeToTriplesMapBase objects, boolean isPredicateUsed, boolean isObjectUsed)
          Method to calculate the individual clustering coefficient for every node
 void calculateTransitiveClustering(java.util.List<CacheAlgorithmBase> o, edu.utdallas.paged.mem.PagedNodeToTriplesMapBase subjects, edu.utdallas.paged.mem.PagedNodeToTriplesMapBase predicates, edu.utdallas.paged.mem.PagedNodeToTriplesMapBase objects, boolean isPredicateUsed, boolean isObjectUsed)
          Method to calculate the transitive clustering coefficient for every node
 CacheAlgorithmBase createCacheEntry(CacheAlgorithmBase algo)
          Method to create a new cache or update an existing cache entry based on the updated connections of this node and the current time
abstract  java.lang.Object[] getFiles()
          Method that returns the files used by this cache
 java.lang.Object getKeyFromValue(java.util.LinkedHashMap<java.lang.Object,CacheAlgorithmBase> hm, CacheAlgorithmBase value)
          Method to get the key value from the cache based on a value
 java.util.ArrayList<com.hp.hpl.jena.graph.Triple> getTriples(java.lang.Object key, edu.utdallas.paged.mem.PagedHashedTripleBunch subTb, edu.utdallas.paged.mem.PagedHashedTripleBunch predTb, edu.utdallas.paged.mem.PagedHashedTripleBunch objTb)
          Method to create an arraylist from the triples taken from the subject, predicate, and object memory structures
 java.lang.String removePunctuation(java.lang.String input)
          Method to remove punctuations
 int removeTripleBunch(edu.utdallas.paged.mem.PagedNodeToTriplesMapBase nodes, edu.utdallas.paged.mem.PagedHashedTripleBunch tb, int index)
          Method to remove the triples from memory and return the new size of the nodes structure
abstract  void updateCache(edu.utdallas.paged.mem.PagedNodeToTriplesMapBase subjects, edu.utdallas.paged.mem.PagedNodeToTriplesMapBase predicates, edu.utdallas.paged.mem.PagedNodeToTriplesMapBase objects, CacheAlgorithmBase algoSub, CacheAlgorithmBase algoPred, CacheAlgorithmBase algoObj, com.hp.hpl.jena.graph.Triple t)
          Method that updates the cache based on the current view of subjects and objects, the given algorithm, and, the triple t
 java.util.Calendar updateTime()
          Method to return the current time with homogenized to seconds
abstract  void writeToDisk(edu.utdallas.paged.mem.PagedNodeToTriplesMapBase subjects, edu.utdallas.paged.mem.PagedNodeToTriplesMapBase predicates, edu.utdallas.paged.mem.PagedNodeToTriplesMapBase objects)
          Method that writes the triples to disk based on the accumulator size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hashMap

public java.util.LinkedHashMap<java.lang.Object,CacheAlgorithmBase> hashMap
The actual buffer is maintained as a hash map


size

public static int size
The size of the current buffer


isFileCreated

public boolean isFileCreated
A variable to test if Lucene indexes are already created


isSubFileCreated

public boolean isSubFileCreated
A variable to test if Lucene indexes are already created


isPredFileCreated

public boolean isPredFileCreated
A variable to test if Lucene indexes are already created


isObjFileCreated

public boolean isObjFileCreated
A variable to test if Lucene indexes are already created


writeObject

public boolean writeObject
Check if the object Lucene index is created


writeSubject

public boolean writeSubject
Check if the subject Lucene index is created


subF

public java.io.File subF
The temporary subject Lucene index


predF

public java.io.File predF
The temporary predicate Lucene index


objF

public java.io.File objF
The temporary object Lucene index


subWriter

public org.apache.lucene.index.IndexWriter subWriter
An index writer to create the subject Lucene index


predWriter

public org.apache.lucene.index.IndexWriter predWriter
An index writer to create the predicate Lucene index


objWriter

public org.apache.lucene.index.IndexWriter objWriter
An index writer to create the object Lucene index


delayFactor

public int delayFactor
The delay factor determines the amount of triples to be left in memory


graphId

public static int graphId
The graph id


timestamp

public long timestamp
The current timestamp value


id

public int id
An identifier that determines the position of a given URI in a Lucene index


luceneWriter

public PagedNTripleWriter luceneWriter
A N-Triple writer to write triples to a Lucene index

Constructor Detail

CacheBase

public CacheBase()
Constructor initializes the hash map with the key as the node (as an Object) and the memory management algorithm as the value

Method Detail

getFiles

public abstract java.lang.Object[] getFiles()
Method that returns the files used by this cache


updateCache

public abstract void updateCache(edu.utdallas.paged.mem.PagedNodeToTriplesMapBase subjects,
                                 edu.utdallas.paged.mem.PagedNodeToTriplesMapBase predicates,
                                 edu.utdallas.paged.mem.PagedNodeToTriplesMapBase objects,
                                 CacheAlgorithmBase algoSub,
                                 CacheAlgorithmBase algoPred,
                                 CacheAlgorithmBase algoObj,
                                 com.hp.hpl.jena.graph.Triple t)
Method that updates the cache based on the current view of subjects and objects, the given algorithm, and, the triple t


writeToDisk

public abstract void writeToDisk(edu.utdallas.paged.mem.PagedNodeToTriplesMapBase subjects,
                                 edu.utdallas.paged.mem.PagedNodeToTriplesMapBase predicates,
                                 edu.utdallas.paged.mem.PagedNodeToTriplesMapBase objects)
Method that writes the triples to disk based on the accumulator size


updateTime

public java.util.Calendar updateTime()
Method to return the current time with homogenized to seconds

Returns:
A Calendar instance with the current time with the millisecond field cleared

createCacheEntry

public CacheAlgorithmBase createCacheEntry(CacheAlgorithmBase algo)
Method to create a new cache or update an existing cache entry based on the updated connections of this node and the current time

Parameters:
algo - - the memory management algorithm that we want to use with this buffer
Returns:
the updated cache entry

removePunctuation

public java.lang.String removePunctuation(java.lang.String input)
Method to remove punctuations


getKeyFromValue

public java.lang.Object getKeyFromValue(java.util.LinkedHashMap<java.lang.Object,CacheAlgorithmBase> hm,
                                        CacheAlgorithmBase value)
Method to get the key value from the cache based on a value


removeTripleBunch

public int removeTripleBunch(edu.utdallas.paged.mem.PagedNodeToTriplesMapBase nodes,
                             edu.utdallas.paged.mem.PagedHashedTripleBunch tb,
                             int index)
Method to remove the triples from memory and return the new size of the nodes structure


getTriples

public java.util.ArrayList<com.hp.hpl.jena.graph.Triple> getTriples(java.lang.Object key,
                                                                    edu.utdallas.paged.mem.PagedHashedTripleBunch subTb,
                                                                    edu.utdallas.paged.mem.PagedHashedTripleBunch predTb,
                                                                    edu.utdallas.paged.mem.PagedHashedTripleBunch objTb)
Method to create an arraylist from the triples taken from the subject, predicate, and object memory structures


calculateIndividualClustering

public void calculateIndividualClustering(java.util.List<CacheAlgorithmBase> o,
                                          edu.utdallas.paged.mem.PagedNodeToTriplesMapBase subjects,
                                          edu.utdallas.paged.mem.PagedNodeToTriplesMapBase predicates,
                                          edu.utdallas.paged.mem.PagedNodeToTriplesMapBase objects,
                                          boolean isPredicateUsed,
                                          boolean isObjectUsed)
Method to calculate the individual clustering coefficient for every node


calculateTransitiveClustering

public void calculateTransitiveClustering(java.util.List<CacheAlgorithmBase> o,
                                          edu.utdallas.paged.mem.PagedNodeToTriplesMapBase subjects,
                                          edu.utdallas.paged.mem.PagedNodeToTriplesMapBase predicates,
                                          edu.utdallas.paged.mem.PagedNodeToTriplesMapBase objects,
                                          boolean isPredicateUsed,
                                          boolean isObjectUsed)
Method to calculate the transitive clustering coefficient for every node