Example usage for org.apache.lucene.index IndexCommit equals

List of usage examples for org.apache.lucene.index IndexCommit equals

Introduction

In this page you can find the example usage for org.apache.lucene.index IndexCommit equals.

Prototype

@Override
public boolean equals(Object other) 

Source Link

Document

Two IndexCommits are equal if both their Directory and versions are equal.

Usage

From source file:org.eu.bitzone.Leia.java

License:Apache License

private void showCommits() throws Exception {
    final Object commitsTable = find("commitsTable");
    removeAll(commitsTable);//from   ww w.  j  a v  a 2 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.eu.bitzone.Leia.java

License:Apache License

public void openCommit(final Object commitsTable) throws IOException {
    final Object row = getSelectedItem(commitsTable);
    if (row == null) {
        showStatus("No commit point selected.");
        return;//from w  w w . j  a v  a 2s.c  o m
    }
    final IndexCommit commit = (IndexCommit) getProperty(row, "commit");
    if (commit == null) {
        showStatus("Can't retrieve commit point (application error)");
        return;
    }
    final IndexCommit current = ir instanceof DirectoryReader ? ((DirectoryReader) ir).getIndexCommit() : null;
    if (commit.equals(current)) {
        showStatus("Already open at this commit point.");
        return;
    }
    ir.close();
    IndexDeletionPolicy policy;
    if (keepCommits) {
        policy = new KeepAllIndexDeletionPolicy();
    } else {
        policy = new KeepLastIndexDeletionPolicy();
    }
    ir = DirectoryReader.open(commit);
    initOverview();
}

From source file:org.getopt.luke.Luke.java

License:Apache License

private void showCommits() throws Exception {
    Object commitsTable = find("commitsTable");
    removeAll(commitsTable);// w ww .  j av  a  2  s  .com
    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);
            }
        }
    }
}

From source file:org.getopt.luke.Luke.java

License:Apache License

public void openCommit(Object commitsTable) throws IOException {
    Object row = getSelectedItem(commitsTable);
    if (row == null) {
        showStatus("No commit point selected.");
        return;//from www . ja v a 2  s . c o  m
    }
    IndexCommit commit = (IndexCommit) getProperty(row, "commit");
    if (commit == null) {
        showStatus("Can't retrieve commit point (application error)");
        return;
    }
    IndexCommit current = ir instanceof DirectoryReader ? ((DirectoryReader) ir).getIndexCommit() : null;
    if (commit.equals(current)) {
        showStatus("Already open at this commit point.");
        return;
    }
    ir.close();
    IndexDeletionPolicy policy;
    if (keepCommits) {
        policy = new KeepAllIndexDeletionPolicy();
    } else {
        policy = new KeepLastIndexDeletionPolicy();
    }
    ir = DirectoryReader.open(commit);
    initOverview();
}