IndexManager
Class WindsurfRegMtreeWrapper

java.lang.Object
  extended by IndexManager.WindsurfRegMtreeWrapper

public class WindsurfRegMtreeWrapper
extends java.lang.Object

Class implementing operations for invoking native functions for managing the region M-tree.


Constructor Summary
WindsurfRegMtreeWrapper()
           
 
Method Summary
static boolean close()
          Closes the region M-tree.
static boolean closeCursors()
          Deletes the previously created region cursors for sorted access.
static boolean create(java.lang.String featureFile)
          Creates a new M-tree index from a file containing region features.
static boolean createCursors(int id, int size, int regions, double[] sizes, double[] centroids, double[] covariance)
          Creates cursors for performing sorted access on the index using all the regions of a given image.
static boolean delete(int id, int size, double[] centroid, double[] covariance)
          Deletes a region from the M-tree index.
static int getCount()
          Gets the distance counter for the region index.
static double[] getNext(int index)
          Performs a sorted access on one of the existing region cursors.
static boolean init(java.lang.String indexFile)
          Initializes the region M-tree.
static boolean insert(int id, int size, double[] centroid, double[] covariance)
          Inserts a new region in the M-tree index.
static double[] queryKnn(int k, int size, double[] centroid, double[] covariance)
          Creates a new k-NN query based on the given region using this index.
static double[] queryRange(double r, int size, double[] centroid, double[] covariance)
          Creates a new range query based on the given region using this index.
static boolean resetCount()
          Resets the distance counter for the region index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WindsurfRegMtreeWrapper

public WindsurfRegMtreeWrapper()
Method Detail

init

public static boolean init(java.lang.String indexFile)
Initializes the region M-tree.

Parameters:
indexFile - Absolute path of the file containing the M-tree index.
Returns:
true if the index was successfully initialized, false otherwise.

create

public static boolean create(java.lang.String featureFile)
Creates a new M-tree index from a file containing region features.

Parameters:
featureFile - Absolute path of the features file.
Returns:
true if the index was successfully created, false otherwise.

close

public static boolean close()
Closes the region M-tree.

Returns:
true if the index was successfully closed, false otherwise.

insert

public static boolean insert(int id,
                             int size,
                             double[] centroid,
                             double[] covariance)
Inserts a new region in the M-tree index.

Parameters:
id - Region ID.
size - Number of pixels in the region.
centroid - Region centroid.
covariance - Region covariance matrix.
Returns:
true if the region was successfully inserted, false otherwise.

delete

public static boolean delete(int id,
                             int size,
                             double[] centroid,
                             double[] covariance)
Deletes a region from the M-tree index.

Parameters:
id - Region ID.
size - Number of pixels in the region.
centroid - Region centroid.
covariance - Region covariance matrix.
Returns:
true if the region was successfully deleted, false otherwise.

queryKnn

public static double[] queryKnn(int k,
                                int size,
                                double[] centroid,
                                double[] covariance)
Creates a new k-NN query based on the given region using this index.

Parameters:
k - Number of requested results.
size - Number of pixels in the region.
centroid - Region centroid.
covariance - Region covariance matrix.
Returns:
Array of query results as (ID,distance) couples.

queryRange

public static double[] queryRange(double r,
                                  int size,
                                  double[] centroid,
                                  double[] covariance)
Creates a new range query based on the given region using this index.

Parameters:
r - Radius of the query.
size - Number of pixels in the region.
centroid - Region centroid.
covariance - Region covariance matrix.
Returns:
Array of query results as (ID,distance) couples.

createCursors

public static boolean createCursors(int id,
                                    int size,
                                    int regions,
                                    double[] sizes,
                                    double[] centroids,
                                    double[] covariance)
Creates cursors for performing sorted access on the index using all the regions of a given image.

Parameters:
id - Image ID.
size - Number of pixels in the image.
regions - Number of image regions.
sizes - Array of regions sizes.
centroids - Array of regions centroids.
covariance - Array of regions covariance matrices.
Returns:
true if the cursors were successfully created, false otherwise.

closeCursors

public static boolean closeCursors()
Deletes the previously created region cursors for sorted access.

Returns:
true if the cursors were successfully deleted, false otherwise.

getNext

public static double[] getNext(int index)
Performs a sorted access on one of the existing region cursors.

Parameters:
index - The cursor that should perform the sorted access.
Returns:
Array containing a couple of (ID,distance) for the next region of the requested cursor.

resetCount

public static boolean resetCount()
Resets the distance counter for the region index.

Returns:
true if the counter was successfully reset, false otherwise.

getCount

public static int getCount()
Gets the distance counter for the region index.

Returns:
Number of computed distances up to now.