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

COVERAGE SUMMARY FOR SOURCE FILE [MVDelegateIndex.java]

nameclass, %method, %block, %line, %
MVDelegateIndex.java100% (1/1)67%  (12/18)77%  (88/114)76%  (22/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MVDelegateIndex100% (1/1)67%  (12/18)77%  (88/114)76%  (22/29)
addBufferedRows (List): void 0%   (0/1)0%   (0/2)0%   (0/1)
addRowsToBuffer (List, String): void 0%   (0/1)0%   (0/2)0%   (0/1)
close (Session): void 0%   (0/1)0%   (0/1)0%   (0/1)
getDiskSpaceUsed (): long 0%   (0/1)0%   (0/2)0%   (0/1)
getRowCount (Session): long 0%   (0/1)0%   (0/5)0%   (0/1)
getRowCountApproximation (): long 0%   (0/1)0%   (0/4)0%   (0/1)
MVDelegateIndex (MVTable, int, String, MVPrimaryIndex, IndexType): void 100% (1/1)72%  (26/36)86%  (6/7)
add (Session, Row): void 100% (1/1)100% (1/1)100% (1/1)
canGetFirstOrLast (): boolean 100% (1/1)100% (2/2)100% (1/1)
checkRename (): void 100% (1/1)100% (1/1)100% (1/1)
find (Session, SearchRow, SearchRow): Cursor 100% (1/1)100% (21/21)100% (3/3)
findFirstOrLast (Session, boolean): Cursor 100% (1/1)100% (6/6)100% (1/1)
getColumnIndex (Column): int 100% (1/1)100% (10/10)100% (3/3)
getCost (Session, int [], TableFilter, SortOrder): double 100% (1/1)100% (12/12)100% (1/1)
needRebuild (): boolean 100% (1/1)100% (2/2)100% (1/1)
remove (Session): void 100% (1/1)100% (5/5)100% (2/2)
remove (Session, Row): void 100% (1/1)100% (1/1)100% (1/1)
truncate (Session): void 100% (1/1)100% (1/1)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.mvstore.db;
7 
8import java.util.List;
9 
10import org.h2.engine.Session;
11import org.h2.index.BaseIndex;
12import org.h2.index.Cursor;
13import org.h2.index.IndexType;
14import org.h2.message.DbException;
15import org.h2.result.Row;
16import org.h2.result.SearchRow;
17import org.h2.result.SortOrder;
18import org.h2.table.Column;
19import org.h2.table.IndexColumn;
20import org.h2.table.TableFilter;
21import org.h2.value.ValueLong;
22 
23/**
24 * An index that delegates indexing to another index.
25 */
26public class MVDelegateIndex extends BaseIndex implements MVIndex {
27 
28    private final MVPrimaryIndex mainIndex;
29 
30    public MVDelegateIndex(MVTable table, int id, String name,
31            MVPrimaryIndex mainIndex,
32            IndexType indexType) {
33        IndexColumn[] cols = IndexColumn.wrap(new Column[] { table
34                .getColumn(mainIndex.getMainIndexColumn()) });
35        this.initBaseIndex(table, id, name, cols, indexType);
36        this.mainIndex = mainIndex;
37        if (id < 0) {
38            throw DbException.throwInternalError("" + name);
39        }
40    }
41 
42    @Override
43    public void addRowsToBuffer(List<Row> rows, String bufferName) {
44        throw DbException.throwInternalError();
45    }
46 
47    @Override
48    public void addBufferedRows(List<String> bufferNames) {
49        throw DbException.throwInternalError();
50    }
51 
52    @Override
53    public void add(Session session, Row row) {
54        // nothing to do
55    }
56 
57    @Override
58    public boolean canGetFirstOrLast() {
59        return true;
60    }
61 
62    @Override
63    public void close(Session session) {
64        // nothing to do
65    }
66 
67    @Override
68    public Cursor find(Session session, SearchRow first, SearchRow last) {
69        ValueLong min = mainIndex.getKey(first,
70                MVPrimaryIndex.MIN, MVPrimaryIndex.MIN);
71        // ifNull is MIN_VALUE as well, because the column is never NULL
72        // so avoid returning all rows (returning one row is OK)
73        ValueLong max = mainIndex.getKey(last,
74                MVPrimaryIndex.MAX, MVPrimaryIndex.MIN);
75        return mainIndex.find(session, min, max);
76    }
77 
78    @Override
79    public Cursor findFirstOrLast(Session session, boolean first) {
80        return mainIndex.findFirstOrLast(session, first);
81    }
82 
83    @Override
84    public int getColumnIndex(Column col) {
85        if (col.getColumnId() == mainIndex.getMainIndexColumn()) {
86            return 0;
87        }
88        return -1;
89    }
90 
91    @Override
92    public double getCost(Session session, int[] masks, TableFilter filter,
93            SortOrder sortOrder) {
94        return 10 * getCostRangeIndex(masks,
95                mainIndex.getRowCountApproximation(), filter, sortOrder);
96    }
97 
98    @Override
99    public boolean needRebuild() {
100        return false;
101    }
102 
103    @Override
104    public void remove(Session session, Row row) {
105        // nothing to do
106    }
107 
108    @Override
109    public void remove(Session session) {
110        mainIndex.setMainIndexColumn(-1);
111    }
112 
113    @Override
114    public void truncate(Session session) {
115        // nothing to do
116    }
117 
118    @Override
119    public void checkRename() {
120        // ok
121    }
122 
123    @Override
124    public long getRowCount(Session session) {
125        return mainIndex.getRowCount(session);
126    }
127 
128    @Override
129    public long getRowCountApproximation() {
130        return mainIndex.getRowCountApproximation();
131    }
132 
133    @Override
134    public long getDiskSpaceUsed() {
135        return 0;
136    }
137 
138}

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