예제 #1
0
 /**
  * Creates an index of the specified type for the specified field. A unique ID is assigned to this
  * index, and its information is stored in the idxcat table.
  *
  * @param idxName the name of the index
  * @param tblName the name of the indexed table
  * @param fldName the name of the indexed field
  * @param idxType the index type of the indexed field
  * @param tx the calling transaction
  */
 public void createIndex(
     String idxName, String tblName, String fldName, int idxType, Transaction tx) {
   RecordFile rf = ti.open(tx);
   rf.insert();
   rf.setVal(ICAT_IDXNAME, new VarcharConstant(idxName));
   rf.setVal(ICAT_TBLNAME, new VarcharConstant(tblName));
   rf.setVal(ICAT_FLDNAME, new VarcharConstant(fldName));
   rf.setVal(ICAT_IDXTYPE, new IntegerConstant(idxType));
   rf.close();
 }
예제 #2
0
 /**
  * Returns a map containing the index info for all indexes on the specified table.
  *
  * @param tblName the name of the table
  * @param tx the calling transaction
  * @return a map of IndexInfo objects, keyed by their field names
  */
 public Map<String, IndexInfo> getIndexInfo(String tblName, Transaction tx) {
   Map<String, IndexInfo> result = new HashMap<String, IndexInfo>();
   RecordFile rf = ti.open(tx);
   rf.beforeFirst();
   while (rf.next())
     if (((String) rf.getVal(ICAT_TBLNAME).asJavaVal()).equals(tblName)) {
       String idxname = (String) rf.getVal(ICAT_IDXNAME).asJavaVal();
       String fldname = (String) rf.getVal(ICAT_FLDNAME).asJavaVal();
       int idxtype = (Integer) rf.getVal(ICAT_IDXTYPE).asJavaVal();
       IndexInfo ii = new IndexInfo(idxname, tblName, fldname, idxtype);
       result.put(fldname, ii);
     }
   rf.close();
   return result;
 }