List of usage examples for org.apache.lucene.index IndexCommit isDeleted
public abstract boolean isDeleted();
From source file:org.elasticsearch.index.engine.CombinedDeletionPolicy.java
License:Apache License
private void setLastCommittedTranslogGeneration(List<? extends IndexCommit> commits) throws IOException { // when opening an existing lucene index, we currently always open the last commit. // we therefore use the translog gen as the one that will be required for recovery final IndexCommit indexCommit = commits.get(commits.size() - 1); assert indexCommit.isDeleted() == false : "last commit is deleted"; long minGen = Long.parseLong(indexCommit.getUserData().get(Translog.TRANSLOG_GENERATION_KEY)); translogDeletionPolicy.setMinTranslogGenerationForRecovery(minGen); }
From source file:org.eu.bitzone.Leia.java
License:Apache License
private void showCommits() throws Exception { final Object commitsTable = find("commitsTable"); removeAll(commitsTable);// ww w . java2 s .c o m if (dir == null) { final Object row = create("row"); final Object cell = create("cell"); setString(cell, "text", "<not available>"); setBoolean(cell, "enabled", false); add(row, cell); add(commitsTable, row); return; } final List<IndexCommit> commits = DirectoryReader.listCommits(dir); final IndexCommit current = ir instanceof DirectoryReader ? ((DirectoryReader) ir).getIndexCommit() : null; // commits are ordered from oldest to newest ? final Iterator<IndexCommit> it = commits.iterator(); int rowNum = 0; while (it.hasNext()) { final IndexCommit commit = it.next(); // figure out the name of the segment files final Collection<String> files = commit.getFileNames(); final Iterator<String> itf = files.iterator(); final Object row = create("row"); final boolean enabled = rowNum < commits.size() - 1; final Color color = Color.BLUE; rowNum++; add(commitsTable, row); putProperty(row, "commit", commit); if (enabled) { putProperty(row, "commitDeletable", Boolean.TRUE); } Object cell = create("cell"); final String gen = String.valueOf(commit.getGeneration()); setString(cell, "text", gen); add(row, cell); cell = create("cell"); setString(cell, "text", commit.isDeleted() ? "Y" : "N"); add(row, cell); cell = create("cell"); setString(cell, "text", String.valueOf(commit.getSegmentCount())); add(row, cell); cell = create("cell"); final Map userData = commit.getUserData(); if (userData != null && !userData.isEmpty()) { setString(cell, "text", userData.toString()); } else { setString(cell, "text", ""); } add(row, cell); if (commit.equals(current)) { final Object[] cells = getItems(row); for (final Object c : cells) { setColor(c, "foreground", color); } } } }
From source file:org.getopt.luke.Luke.java
License:Apache License
private void showCommits() throws Exception { Object commitsTable = find("commitsTable"); removeAll(commitsTable);/*from w w w .jav a 2s.co m*/ if (dir == null) { Object row = create("row"); Object cell = create("cell"); setString(cell, "text", "<not available>"); setBoolean(cell, "enabled", false); add(row, cell); add(commitsTable, row); return; } List<IndexCommit> commits = DirectoryReader.listCommits(dir); IndexCommit current = ir instanceof DirectoryReader ? ((DirectoryReader) ir).getIndexCommit() : null; // commits are ordered from oldest to newest ? Iterator<IndexCommit> it = commits.iterator(); int rowNum = 0; while (it.hasNext()) { IndexCommit commit = (IndexCommit) it.next(); // figure out the name of the segment files Collection<String> files = commit.getFileNames(); Iterator<String> itf = files.iterator(); Object row = create("row"); boolean enabled = rowNum < commits.size() - 1; Color color = Color.BLUE; rowNum++; add(commitsTable, row); putProperty(row, "commit", commit); if (enabled) { putProperty(row, "commitDeletable", Boolean.TRUE); } Object cell = create("cell"); String gen = String.valueOf(commit.getGeneration()); setString(cell, "text", gen); add(row, cell); cell = create("cell"); setString(cell, "text", commit.isDeleted() ? "Y" : "N"); add(row, cell); cell = create("cell"); setString(cell, "text", String.valueOf(commit.getSegmentCount())); add(row, cell); cell = create("cell"); Map userData = commit.getUserData(); if (userData != null && !userData.isEmpty()) { setString(cell, "text", userData.toString()); } else { setString(cell, "text", ""); } add(row, cell); if (commit.equals(current)) { Object[] cells = getItems(row); for (Object c : cells) { setColor(c, "foreground", color); } } } }