ObjectType integer = ssn().getRoot().getObjectType("global.Integer"); if (integer == null) { integer = ssn().getRoot().getObjectType("Integer"); } Signature sig = new Signature() { public Query makeQuery(Expression e) { Query q = new Query(e); q.fetch (MAX, new Static("RAW[max](" + m_index.getName() + ")")); return q; } public String getColumn(Path p) { return MAX; } public boolean isFetched(Path p) { return true; } }; sig.addSource(integer, Path.get(MAX)); sig.addPath(MAX); DataSet ds = new DataSet(ssn(), sig, elements()); Cursor c = ds.getCursor(); try { if (c.next()) { Integer size = (Integer) c.get(MAX); if (size == null) { return 0; } else { return size.intValue() + 1; } } else { throw new IllegalStateException ("size query returned no rows"); } } finally { c.close(); }
return elements.size();
    public int size() {        // XXX: fix this        ObjectType integer = ssn().getRoot().getObjectType("global.Integer");        if (integer == null) {            integer = ssn().getRoot().getObjectType("Integer");        }        Signature sig = new Signature() {            public Query makeQuery(Expression e) {                Query q = new Query(e);                q.fetch                    (MAX, new Static("RAW[max](" + m_index.getName() + ")"));                return q;            }            public String getColumn(Path p) {                return MAX;            }            public boolean isFetched(Path p) {                return true;            }        };        sig.addSource(integer, Path.get(MAX));        sig.addPath(MAX);        DataSet ds = new DataSet(ssn(), sig, elements());        Cursor c = ds.getCursor();        try {            if (c.next()) {                Integer size = (Integer) c.get(MAX);                if (size == null) {                    return 0;                } else {                    return size.intValue() + 1;                }            } else {                throw new IllegalStateException                    ("size query returned no rows");            }        } finally {            c.close();        }    }