public void list(PrintStream output) throws IOException { int indexSize = indexInput.readInt(); output.println("Memory indexsize = " + indexSize); StringBuilder findWord = new StringBuilder(); for (int k = 0; k < indexSize; k++) { String string = new String(indexInput.readUString()); long inputOffset = indexInput.readLong(); // output.println("word="+string+" ,"+ inputOffset); BufferedFileInput postingInput = new BufferedFileInput( IndexFileNames.getRevisionDir(dir, rev), IndexFileNames.getSearchPostingFileName(id)); BufferedFileInput clone = postingInput.clone(); IndexFieldOption indexFieldOption = new IndexFieldOption(clone.readInt()); // output.println("offset:" + inputOffset); clone.seek(inputOffset); int len = 0, postingCount = 0, lastDocNo = 0; // List<Integer> postingList = new ArrayList<Integer>(); try { len = clone.readVInt(); postingCount = clone.readInt(); lastDocNo = clone.readInt(); int postingRemain = postingCount; int prevId = -1; boolean isStorePosition = indexFieldOption.isStorePosition(); for (int i = 0; postingRemain > 0; i++) { int docId = -1; int readed = clone.readVInt(); if (prevId >= 0) { docId = readed + prevId + 1; } else { docId = readed; } if (findDocNo == docId) { findWord.append("\"").append(string).append("\", "); } int tf = clone.readVInt(); if (tf > 0 && isStorePosition) { int prevPosition = -1; for (int j = 0; j < tf; j++) { int position = 0; if (prevPosition >= 0) { position = clone.readVInt() + prevPosition + 1; } else { position = clone.readVInt(); } prevPosition = position; } } // postingList.add(docId); postingRemain--; prevId = docId; } } catch (IOException ex) { ex.printStackTrace(); } postingInput.close(); // output.println("poosting len : " + len + " postingCount : " // + postingCount + " / lastDocNo : " + lastDocNo); // output.println("postingList:"+postingList); if (findDocNo != -1) { // output.println("findDocNo:"+findDocNo+" // "+(postingList.contains(findDocNo)?"CONTAINS":"NOT")); } } output.println("docNo [" + findDocNo + "] has word " + findWord); }