コード例 #1
0
 public void addAttribute(DeweyID deweyID, String qName, int parentCID, boolean qNameFound)
     throws IOException, Exception {
   // parentCID is curNode's CID
   //        logManager.LogManager.log(6,qName);
   //        logManager.LogManager.log(6,"Attrib: "+deweyID.toString());
   //        logManager.LogManager.log(6,String.valueOf(deweyID.getCID()));
   //        }
   //         elemIndex.insert(deweyID.getCID(),deweyID);
   //         bTreeIndex.insert(deweyID,deweyID.getCID(),qName);
   if (!qNameFound) {
     // structSumIndex.add(deweyID.getCID(),qName,parentCID);
     try {
       if (con != null) {
         String sqlQuery = "INSERT INTO \"OrderedByCID\" (\"CID\", \"DeweyID\") VALUES (?, ?);";
         PreparedStatement pst = con.prepareStatement(sqlQuery);
         pst.setInt(1, deweyID.getCID());
         pst.setString(2, deweyID.toString());
         //                    pst.setString(3, String.v);
         pst.executeUpdate();
         pst.close();
       }
     } catch (SQLException e) {
       System.out.println("JDBC Driver is not Configured Correctly !");
       e.printStackTrace();
       return;
     }
   }
   // checkBufPool();
 }
コード例 #2
0
  public void addValue(DeweyID deweyID, String value, int parentCID) throws IOException, Exception {
    // we may have problem here
    // maybe we should update previously inserted attributes instead of insert new one

    // FOR ATTrib Values (Actually they are behaved the same as text contents)
    // text contents are not added to element index,thier CID shouldn be Zero
    // elemIndex.insert(0,deweyID);
    // bTreeIndex.insert(deweyID,-1,value);
    logManager.LogManager.log(6, value);
    logManager.LogManager.log(6, "Value: " + deweyID.toString());
    try {
      if (con != null) {
        String sqlQuery =
            "INSERT INTO \"OrderedByCID\" (\"CID\", \"DeweyID\" , \"Value\") VALUES (?, ? ,?);";
        PreparedStatement pst = con.prepareStatement(sqlQuery);
        pst.setInt(1, deweyID.getCID());
        pst.setString(2, deweyID.toString());
        pst.setString(3, value);
        pst.executeUpdate();
        pst.close();
      }
    } catch (SQLException e) {
      System.out.println("JDBC Driver is not Configured Correctly !");
      e.printStackTrace();
      return;
    }

    // structSumIndex.add(-1,value,parentCID);THIS IS NOT NEEDED!
    // checkBufPool();
  }
コード例 #3
0
 public void addContent(DeweyID deweyID, StringBuilder contentBuilder, int parentCID)
     throws IOException, Exception {
   String content = new String(contentBuilder);
   try {
     if (con != null) {
       String sqlQuery =
           "INSERT INTO \"OrderedByCID\" (\"CID\", \"DeweyID\" , \"Value\") VALUES (?, ? ,?);";
       PreparedStatement pst = con.prepareStatement(sqlQuery);
       pst.setInt(1, deweyID.getCID());
       pst.setString(2, deweyID.toString());
       pst.setString(3, content);
       pst.executeUpdate();
       pst.close();
     }
   } catch (SQLException e) {
     System.out.println("JDBC Driver is not Configured Correctly !");
     e.printStackTrace();
     return;
   }
   // text contents are not added to element index,thier CID shouldn be Zero
   // elemIndex.insert(0,deweyID);
   //         bTreeIndex.insert(deweyID,-2,content);
   //         System.out.println("CID: -2");
   // structSumIndex.add(-2,content,parentCID);THIS IS NOT NEEDED
   // checkBufPool();
 }
コード例 #4
0
  public int internalNodeSearch(DeweyID deweyId) {
    // page: pagestate,nextpage,freeoffset
    // ps,isroot,isleaf,number of keys in this
    // page,freeoff,nextp(leftmost),deweyId,nextp,deweyId,nextp(rightmost)
    int pagePointer = -1; // null
    int length;
    byte[] curId;
    DeweyID curDId = null;
    DeweyID result = null;
    InternalBuffer.position(Settings.dataStartPos); // 3+4+4 ps+isL+isR+freeOff+numOf
    // if(IsRoot() & IsLeaf()& freeOffset==Settings.dataStartPos)
    if (numOfKeys > 0) {
      for (int i = 0; i < numOfKeys; i++) {
        pagePointer = InternalBuffer.getInt(); // next page adrs
        length = InternalBuffer.getInt();
        curId = new byte[length];
        InternalBuffer.get(curId, 0, length);
        curDId = new DeweyID();
        curDId.setDeweyId(curId);
        result = curDId;
        if (!(curDId.notGreaterThan(deweyId))) {
          break;
        }
      }
      if (curDId.notGreaterThan(deweyId)) // baraye akharin curID(rightMost)
      {
        pagePointer = InternalBuffer.getInt(); // the last (right most)pointer
      }
    }
    return pagePointer; // page i ro bar migardune k result max un hast.
    // ki<k<ki+1

  }
コード例 #5
0
 public void addElement(DeweyID deweyID, String qName, int parentCID, boolean qNameFound)
     throws IOException, Exception, SQLException {
   try {
     if (con != null) {
       String sqlQuery = "INSERT INTO \"OrderedByCID\" (\"CID\", \"DeweyID\") VALUES (?, ?);";
       PreparedStatement pst = con.prepareStatement(sqlQuery);
       pst.setInt(1, deweyID.getCID());
       pst.setString(2, deweyID.toString());
       pst.executeUpdate();
       pst.close();
     }
   } catch (SQLException e) {
     System.out.println("JDBC Driver is not Configured Correctly !");
     e.printStackTrace();
     return;
   }
 }