Package net.sf.clairv.index.util

Examples of net.sf.clairv.index.util.RemoteDocList


              storeOneNodeList(writer, keyword, sourceNodeId,
                  list);
            } else {
              StringBuffer sb = new StringBuffer();
              for (Iterator itr1 = remoteInvertedIndex.iterator(); itr1.hasNext(); ) {
                RemoteDocList docList = (RemoteDocList)itr1.next();
                sb.append(docList.term + " " + docList.idf
                    + "[");
                int i = 0;
                for (Iterator itr2 = docList.docList.iterator(); itr2.hasNext(); ) {
                  RemoteOneNodeList oneNodeList = (RemoteOneNodeList)itr2.next();
                  sb.append(oneNodeList.nodeid + "<");
                  int j = 0;
                  for (Iterator itr3 = oneNodeList.oneNodeDocList.iterator(); itr3.hasNext(); ) {
                    RemoteDoc doc = (RemoteDoc)itr3.next();
                    sb.append(doc.docid + "*" + doc.tf);
                    j++;
                    if (j < oneNodeList.oneNodeDocList
                        .size()) {
                      sb.append("|");
                    } else {
                      sb.append(">");
                    }
                  }
                }
                i++;
                if (i < docList.size()) {
                  sb.append(":");
                } else {
                  sb.append("]\n");
                }
              }
View Full Code Here


      String oneTerm = br.readLine();
      if (oneTerm == null) {
        return null;
      }
      while (oneTerm != null) {
        RemoteDocList list = new RemoteDocList();
        oneTerm = oneTerm.trim();
        int i = oneTerm.indexOf("[");
        token = new StringTokenizer(oneTerm.substring(0, i));
        list.term = token.nextToken();
        list.idf = Float.parseFloat(token.nextToken());

        oneTerm = oneTerm.substring(i + 1, oneTerm.length() - 1);
        token = new StringTokenizer(oneTerm, ":");
        RemoteOneNodeList nodeList = new RemoteOneNodeList();
        while (token.hasMoreTokens()) {
          String oneNodeList = token.nextToken();
          i = oneNodeList.indexOf("<");
          String nodeid = oneNodeList.substring(0, i);
          nodeList.nodeid = nodeid;
          token = new StringTokenizer(oneNodeList.substring(i + 1,
              oneNodeList.length() - 1), "|");
          while (token.hasMoreTokens()) {
            String oneDoc = token.nextToken();
            oneDoc = oneDoc.trim();
            StringTokenizer id_token = new StringTokenizer(oneDoc,
                "*");
            RemoteDoc doc = new RemoteDoc(Integer.parseInt(id_token
                .nextToken()), Float.parseFloat(id_token
                .nextToken()));
            nodeList.add(doc);
          }
          list.add(nodeList);
        }
        remoteInvertedIndex.add(list);
        oneTerm = br.readLine();
      }
    } catch (FileNotFoundException e) {
View Full Code Here

    if (remoteInvertedIndex == null) {
      return true;
    }
    int index = 0;
    for (; index < remoteInvertedIndex.size(); index++) {
      RemoteDocList list = (RemoteDocList)remoteInvertedIndex.get(index);
      if (term.equals(list.term)) {
        for (int i = 0; i < list.docList.size(); i++) {
          RemoteOneNodeList nodeList = list.get(i);
          if (nodeid.equals(nodeList.nodeid)) {
            Set oldSet = new TreeSet();
            oldSet.addAll(nodeList.oneNodeDocList);
            Set newSet = new TreeSet();
            newSet.addAll(doclist);
            if (oldSet.equals(newSet)) {
              list.remove(i);
              list.add(i, new RemoteOneNodeList(nodeid, doclist));
              return true;
            }
          }
        }
        return false;
      }
    }
    RemoteDocList newDocList = new RemoteDocList(term, getIdf(nodeid), null);
    newDocList.add(new RemoteOneNodeList(nodeid, doclist));
    remoteInvertedIndex.add(index, newDocList);
    return true;
  }
View Full Code Here

    lock.lock();
    try {
      if (treeHandle != null) {
        String docListStr = Db.bt_Get(treeHandle, keyword);
        if (docListStr != null) {
          RemoteDocList docList = parseDocList(docListStr);
          boolean exist = false;
          for (Iterator itr = docList.docList.iterator(); itr.hasNext(); ) {
            RemoteOneNodeList oneNodeList = (RemoteOneNodeList)itr.next();
            if (sourceNodeId.equals(oneNodeList.nodeid)) {
              oneNodeList.add(list);
              exist = true;
            }
          }
          if (!exist) {
            docList.add(new RemoteOneNodeList(sourceNodeId, list));
            docList.idf = docList.idf + getIdf();
          }
          Db.bt_Rem(treeHandle, keyword);
          Db.bt_Put(treeHandle, keyword, parseString(docList));
        } else {
View Full Code Here

      lock.unlock();
    }
  }

  private RemoteDocList parseDocList(String docListStr) {
    RemoteDocList docList = new RemoteDocList();
    docListStr = docListStr.trim();
    int i = docListStr.indexOf("[");
    StringTokenizer token = new StringTokenizer(docListStr.substring(0, i));
    docList.term = token.nextToken();
    docList.idf = Float.parseFloat(token.nextToken());

    docListStr = docListStr.substring(i + 1, docListStr.length() - 1);
    token = new StringTokenizer(docListStr, ":");
    RemoteOneNodeList nodeList = new RemoteOneNodeList();
    while (token.hasMoreTokens()) {
      String oneNodeList = token.nextToken();
      i = oneNodeList.indexOf("<");
      String nodeid = oneNodeList.substring(0, i);
      nodeList.nodeid = nodeid;
      token = new StringTokenizer(oneNodeList.substring(i + 1,
          oneNodeList.length() - 1), "|");
      while (token.hasMoreTokens()) {
        String oneDoc = token.nextToken();
        oneDoc = oneDoc.trim();
        StringTokenizer id_token = new StringTokenizer(oneDoc, "*");
        RemoteDoc doc = new RemoteDoc(Integer.parseInt(id_token
            .nextToken()), Float.parseFloat(id_token.nextToken()));
        nodeList.add(doc);
      }
      docList.add(nodeList);
    }
    return docList;
  }
View Full Code Here

    return docList;
  }

  private String parseString(String keyword, String sourceNodeId,
      List list) {
    RemoteDocList docList = new RemoteDocList(keyword, getIdf());
    RemoteOneNodeList oneNodeList = new RemoteOneNodeList(sourceNodeId,
        list);
    docList.add(oneNodeList);
    return parseString(docList);
  }
View Full Code Here

      if (conn != null) {
        try {
          queryStatement.setString(1, keyword);
          ResultSet rs = queryStatement.executeQuery();
          if (rs.next()) {
            RemoteDocList docList = parseDocList(rs
                .getString("list"));
            boolean exist = false;
            for (Iterator itr = docList.docList.iterator(); itr.hasNext(); ) {
              RemoteOneNodeList oneNodeList = (RemoteOneNodeList)itr.next();
              if (sourceNodeId.equals(oneNodeList.nodeid)) {
                oneNodeList.add(list);
                exist = true;
              }
            }
            if (!exist) {
              docList.add(new RemoteOneNodeList(sourceNodeId,
                  list));
              docList.idf = docList.idf + getIdf();
            }
            // updateStatement.setString(1, parseString(docList));
            // updateStatement.setString(2, keyword);
            // updateStatement.addBatch();
            commitBatchThread.addJob(new BatchJob(keyword, docList,
                false));
          } else {
            // insertStatement.setString(1, keyword);
            // insertStatement.setString(2, parseString(keyword,
            // sourceNodeId, list));
            // insertStatement.addBatch();
            RemoteDocList l = new RemoteDocList(keyword, getIdf());
            RemoteOneNodeList oneNodeList = new RemoteOneNodeList(
                sourceNodeId, list);
            l.add(oneNodeList);
            commitBatchThread
                .addJob(new BatchJob(keyword, l, true));
          }
          if (commitBatchThread.getState() == Thread.State.NEW) {
            commitBatchThread.start();
View Full Code Here

      lock.unlock();
    }
  }

  private RemoteDocList parseDocList(String docListStr) {
    RemoteDocList docList = new RemoteDocList();
    docListStr = docListStr.trim();
    int i = docListStr.indexOf("[");
    StringTokenizer token = new StringTokenizer(docListStr.substring(0, i));
    docList.term = token.nextToken();
    docList.idf = Float.parseFloat(token.nextToken());

    docListStr = docListStr.substring(i + 1, docListStr.length() - 1);
    token = new StringTokenizer(docListStr, ":");
    RemoteOneNodeList nodeList = new RemoteOneNodeList();
    while (token.hasMoreTokens()) {
      String oneNodeList = token.nextToken();
      i = oneNodeList.indexOf("<");
      String nodeid = oneNodeList.substring(0, i);
      nodeList.nodeid = nodeid;
      token = new StringTokenizer(oneNodeList.substring(i + 1,
          oneNodeList.length() - 1), "|");
      while (token.hasMoreTokens()) {
        String oneDoc = token.nextToken();
        oneDoc = oneDoc.trim();
        StringTokenizer id_token = new StringTokenizer(oneDoc, "*");
        RemoteDoc doc = new RemoteDoc(Integer.parseInt(id_token
            .nextToken()), Float.parseFloat(id_token.nextToken()));
        nodeList.add(doc);
      }
      docList.add(nodeList);
    }
    return docList;
  }
View Full Code Here

      if (job.insert) {
        if (prev != null) {
          if (prev.insert) {
            log
                .info("Merging an insert job with another insert job");
            RemoteDocList prevDocList = prev.list;
            RemoteDocList curDocList = job.list;
            for (Iterator itr = curDocList.docList.iterator(); itr.hasNext(); ) {
              RemoteOneNodeList oneNodeList = (RemoteOneNodeList)itr.next();
              prevDocList.add(oneNodeList);
            }
          } else {
            log
                .warn("Found an update job prior to an insert job; ignored");
          }
        } else {
          batchJobs.put(job.key, job);
        }
      } else {
        if (prev != null) {
          if (!prev.insert) {
            log
                .info("Merging an update job with another update job");
            RemoteDocList prevDocList = prev.list;
            RemoteDocList curDocList = job.list;
            for (Iterator itr = curDocList.docList.iterator(); itr.hasNext(); ) {
              RemoteOneNodeList oneNodeList = (RemoteOneNodeList)itr.next();
              prevDocList.add(oneNodeList);
            }
          } else {
View Full Code Here

TOP

Related Classes of net.sf.clairv.index.util.RemoteDocList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.