. The table can be
searched using left-entity id as it is maintained in the
sorted order. Similarly the search can made against the
relation id and it is searched using the instance ids index.
The tuples are maintained in blocks (4KB) and brought to the
main memory on demand. On commit at concept-net level,
the added information are committed to the disk.
Constructor Summary |
RelationTable(java.lang.String dirName,
long cacheSize)
Concept net directory name is provided to
locate the necessary files. |
Method Summary |
void |
close()
Closes the relation table associated files |
void |
commit()
Commits the relation table changes |
int[] |
getAllRelationIds()
Returns all the relation ids of the current array grid |
int |
getLeftEntityId(int relationId)
Returns the left entity id for the given relation id |
Unbound2DIntArray |
getRelationTupleByRelationId(int relationId)
Returns the relation tuple based on the realtion id. |
Unbound2DIntArray |
getRelationTuplesByEntityId(int leftEntityId)
Returns the relation tuples based on the
left entity id. |
int |
getRightEntityId(int relationId)
Returns the right entity id for the given relation id |
boolean |
insert(int leftId,
int relationId,
int rightId)
Inserts the relation tuple into the relation table |
boolean |
removeInstance(int leftId)
Removes the relation tuples based on the
left entity id. |
boolean |
removeRelation(int relationId)
Removes the relation tuple based on the relation id |
boolean |
update(int leftId,
int relationId,
int rightId)
Updates the relation tuple in the relation table. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LEFT_ENTITY_IDX
public static final int LEFT_ENTITY_IDX
- Left entity index
- See Also:
- Constant Field Values
RELATION_IDX
public static final int RELATION_IDX
- Relation index
- See Also:
- Constant Field Values
RIGHT_ENTITY_IDX
public static final int RIGHT_ENTITY_IDX
- Right entity index
- See Also:
- Constant Field Values
RelationTable
public RelationTable(java.lang.String dirName,
long cacheSize)
throws java.io.FileNotFoundException,
java.io.IOException
- Concept net directory name is provided to
locate the necessary files. Also initialzed
with cache size
- Parameters:
dirName
- concept-net directory namecacheSize
- cache size
- Throws:
java.io.FileNotFoundException
java.io.IOException
close
public void close()
- Closes the relation table associated files
commit
public void commit()
- Commits the relation table changes
getAllRelationIds
public int[] getAllRelationIds()
- Returns all the relation ids of the current array grid
- Returns:
- relation ids as integer array
getLeftEntityId
public int getLeftEntityId(int relationId)
- Returns the left entity id for the given relation id
- Parameters:
relationId
- relation id
- Returns:
- left entity id of the relation
getRelationTupleByRelationId
public Unbound2DIntArray getRelationTupleByRelationId(int relationId)
- Returns the relation tuple based on the realtion id.
- Parameters:
relationId
- relation id
- Returns:
- true on success
getRelationTuplesByEntityId
public Unbound2DIntArray getRelationTuplesByEntityId(int leftEntityId)
- Returns the relation tuples based on the
left entity id.
- Parameters:
leftEntityId
- left entity id
- Returns:
- true on success
getRightEntityId
public int getRightEntityId(int relationId)
- Returns the right entity id for the given relation id
- Parameters:
relationId
- relation id
- Returns:
- left entity id of the relation
insert
public boolean insert(int leftId,
int relationId,
int rightId)
- Inserts the relation tuple into the relation table
- Parameters:
leftId
- left entity idrelationId
- relation idrightId
- right entity id
- Returns:
- true on success
removeInstance
public boolean removeInstance(int leftId)
- Removes the relation tuples based on the
left entity id.
- Parameters:
leftId
- left entity id
- Returns:
- true on success
removeRelation
public boolean removeRelation(int relationId)
- Removes the relation tuple based on the relation id
- Parameters:
relationId
- relation id
- Returns:
- true on success
update
public boolean update(int leftId,
int relationId,
int rightId)
- Updates the relation tuple in the relation table.
Relation id is used as key to update the tuple.
- Parameters:
leftId
- left entity idrelationId
- relation idrightId
- right entity id
- Returns:
- true on success