e have a class in our DBMS that implements a b-tree indexing file systemthe
KeyedIndex class. It has two parents:
Keyedrandom access to data by key.
Sortedsequential access to data sorted by key.
Keyed entity is also parent to a
KeyedHash class that implements random access by key using a hashing algorithm.
KeyedHash does not provide sorted access. The
Sorted entity is also parent to a class that implements a general sorting algorithm for non-indexed data. The data produced by the sorting class can only be accessed sequentially, not randomly.
KeyedIndex class requires multiple inheritance, inheriting from both parents
Sorted. When we built the KeyedIndex class in Java, we needed to model at least one parent as an interface. We decided to create the
KeyedIndex class by modeling the
Keyed entity as an abstract class and the
Sorted entity as an interface:
public abstract class Keyed
public interface Sorted
public class KeyedIndex extends Keyed
We chose this design for the following
- Random access by key is the primary use
KeyedIndex, sorted access by key is
Keyed entity is more complex and has
more methods than the Sorted entity.
Keyed entity has common code shared
by derived classes. The
Sorted entity has
Keyed entity utilizes field variables.
Sorted entity has no variables.