EMMA Coverage Report (generated Sun Mar 01 22:06:14 CET 2015)
[all classes][org.h2.index]

COVERAGE SUMMARY FOR SOURCE FILE [RangeIndex.java]

nameclass, %method, %block, %line, %
RangeIndex.java100% (1/1)19%  (3/16)58%  (68/118)52%  (15/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RangeIndex100% (1/1)19%  (3/16)58%  (68/118)52%  (15/29)
add (Session, Row): void 0%   (0/1)0%   (0/3)0%   (0/1)
canGetFirstOrLast (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
checkRename (): void 0%   (0/1)0%   (0/3)0%   (0/1)
close (Session): void 0%   (0/1)0%   (0/1)0%   (0/1)
findFirstOrLast (Session, boolean): Cursor 0%   (0/1)0%   (0/18)0%   (0/2)
getCreateSQL (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getDiskSpaceUsed (): long 0%   (0/1)0%   (0/2)0%   (0/1)
getRowCount (Session): long 0%   (0/1)0%   (0/4)0%   (0/1)
getRowCountApproximation (): long 0%   (0/1)0%   (0/4)0%   (0/1)
needRebuild (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
remove (Session): void 0%   (0/1)0%   (0/3)0%   (0/1)
remove (Session, Row): void 0%   (0/1)0%   (0/3)0%   (0/1)
truncate (Session): void 0%   (0/1)0%   (0/3)0%   (0/1)
RangeIndex (RangeTable, IndexColumn []): void 100% (1/1)100% (14/14)100% (4/4)
find (Session, SearchRow, SearchRow): Cursor 100% (1/1)100% (52/52)100% (10/10)
getCost (Session, int [], TableFilter, SortOrder): double 100% (1/1)100% (2/2)100% (1/1)

1/*
2 * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (http://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6package org.h2.index;
7 
8import org.h2.engine.Session;
9import org.h2.message.DbException;
10import org.h2.result.Row;
11import org.h2.result.SearchRow;
12import org.h2.result.SortOrder;
13import org.h2.table.IndexColumn;
14import org.h2.table.RangeTable;
15import org.h2.table.TableFilter;
16 
17/**
18 * An index for the SYSTEM_RANGE table.
19 * This index can only scan through all rows, search is not supported.
20 */
21public class RangeIndex extends BaseIndex {
22 
23    private final RangeTable rangeTable;
24 
25    public RangeIndex(RangeTable table, IndexColumn[] columns) {
26        initBaseIndex(table, 0, "RANGE_INDEX", columns,
27                IndexType.createNonUnique(true));
28        this.rangeTable = table;
29    }
30 
31    @Override
32    public void close(Session session) {
33        // nothing to do
34    }
35 
36    @Override
37    public void add(Session session, Row row) {
38        throw DbException.getUnsupportedException("SYSTEM_RANGE");
39    }
40 
41    @Override
42    public void remove(Session session, Row row) {
43        throw DbException.getUnsupportedException("SYSTEM_RANGE");
44    }
45 
46    @Override
47    public Cursor find(Session session, SearchRow first, SearchRow last) {
48        long min = rangeTable.getMin(session), start = min;
49        long max = rangeTable.getMax(session), end = max;
50        long step = rangeTable.getStep(session);
51        try {
52            start = Math.max(min, first == null ? min : first.getValue(0).getLong());
53        } catch (Exception e) {
54            // error when converting the value - ignore
55        }
56        try {
57            end = Math.min(max, last == null ? max : last.getValue(0).getLong());
58        } catch (Exception e) {
59            // error when converting the value - ignore
60        }
61        return new RangeCursor(start, end, step);
62    }
63 
64    @Override
65    public double getCost(Session session, int[] masks, TableFilter filter,
66            SortOrder sortOrder) {
67        return 1;
68    }
69 
70    @Override
71    public String getCreateSQL() {
72        return null;
73    }
74 
75    @Override
76    public void remove(Session session) {
77        throw DbException.getUnsupportedException("SYSTEM_RANGE");
78    }
79 
80    @Override
81    public void truncate(Session session) {
82        throw DbException.getUnsupportedException("SYSTEM_RANGE");
83    }
84 
85    @Override
86    public boolean needRebuild() {
87        return false;
88    }
89 
90    @Override
91    public void checkRename() {
92        throw DbException.getUnsupportedException("SYSTEM_RANGE");
93    }
94 
95    @Override
96    public boolean canGetFirstOrLast() {
97        return true;
98    }
99 
100    @Override
101    public Cursor findFirstOrLast(Session session, boolean first) {
102        long pos = first ? rangeTable.getMin(session) : rangeTable.getMax(session);
103        return new RangeCursor(pos, pos);
104    }
105 
106    @Override
107    public long getRowCount(Session session) {
108        return rangeTable.getRowCountApproximation();
109    }
110 
111    @Override
112    public long getRowCountApproximation() {
113        return rangeTable.getRowCountApproximation();
114    }
115 
116    @Override
117    public long getDiskSpaceUsed() {
118        return 0;
119    }
120}

[all classes][org.h2.index]
EMMA 2.0.5312 (C) Vladimir Roubtsov