Skip to content

Commit 537cbb1

Browse files
committed
unify the interface and exception handling of index
1 parent 66f5576 commit 537cbb1

File tree

5 files changed

+116
-112
lines changed

5 files changed

+116
-112
lines changed

pixels-common/src/main/java/io/pixelsdb/pixels/common/index/IndexService.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,25 @@ public interface IndexService
2828
/**
2929
* Allocate a batch of continuous row ids for the primary index on a table.
3030
* These row ids are to be put into the primary index by the client (e.g., retina or sink)
31-
* @param tableId the table id of the table
31+
*
32+
* @param tableId the table id of the table
3233
* @param numRowIds the number of row ids to allocate
3334
* @return the allocated row ids
35+
* @throws IndexException if failed to allocate row ids
3436
*/
35-
IndexProto.RowIdBatch allocateRowIdBatch(long tableId, int numRowIds);
37+
IndexProto.RowIdBatch allocateRowIdBatch(long tableId, int numRowIds) throws IndexException;
3638

3739
/**
3840
* Lookup a unique index.
3941
* @param key the index key
40-
* @return the row location or null if the index entry is not found.
42+
* @return the row location or null if the index entry is not found
4143
*/
4244
IndexProto.RowLocation lookupUniqueIndex(IndexProto.IndexKey key) throws IndexException;
4345

4446
/**
4547
* Lookup a non-unique index.
4648
* @param key the index key
47-
* @return the row locations or null if the index entry is not found.
49+
* @return the row locations or null if the index entry is not found
4850
*/
4951
List<IndexProto.RowLocation> lookupNonUniqueIndex(IndexProto.IndexKey key) throws IndexException;
5052

@@ -86,13 +88,15 @@ boolean putSecondaryIndexEntries(long tableId, long indexId,
8688
* Delete an entry from the primary index. The deleted index entry is marked as deleted using a tombstone.
8789
* @param key the index key
8890
* @return the row location of the deleted index entry
91+
* @throws IndexException if no existing entry to delete
8992
*/
9093
IndexProto.RowLocation deletePrimaryIndexEntry(IndexProto.IndexKey key) throws IndexException;
9194

9295
/**
9396
* Delete entry(ies) from the secondary index. Each deleted index entry is marked as deleted using a tombstone.
9497
* @param key the index key
9598
* @return the row id(s) of the deleted index entry(ies)
99+
* @throws IndexException if no existing entry(ies) to delete
96100
*/
97101
List<Long> deleteSecondaryIndexEntry(IndexProto.IndexKey key) throws IndexException;
98102

@@ -102,6 +106,7 @@ boolean putSecondaryIndexEntries(long tableId, long indexId,
102106
* @param indexId the index id of the index
103107
* @param keys the keys of the entries to delete
104108
* @return the row locations of the deleted index entries
109+
* @throws IndexException if no existing entry(ies) to delete
105110
*/
106111
List<IndexProto.RowLocation> deletePrimaryIndexEntries(long tableId, long indexId,
107112
List<IndexProto.IndexKey> keys) throws IndexException;
@@ -112,6 +117,7 @@ List<IndexProto.RowLocation> deletePrimaryIndexEntries(long tableId, long indexI
112117
* @param indexId the index id of the index
113118
* @param keys the keys of the entries to delete
114119
* @return the row ids of the deleted index entries
120+
* @throws IndexException if no existing entry(ies) to delete
115121
*/
116122
List<Long> deleteSecondaryIndexEntries(long tableId, long indexId,
117123
List<IndexProto.IndexKey> keys) throws IndexException;
@@ -120,13 +126,15 @@ List<Long> deleteSecondaryIndexEntries(long tableId, long indexId,
120126
* Update the entry of a primary index.
121127
* @param indexEntry the index entry to update
122128
* @return the previous row location of the index entry
129+
* @throws IndexException if no existing entry to update
123130
*/
124131
IndexProto.RowLocation updatePrimaryIndexEntry(IndexProto.PrimaryIndexEntry indexEntry) throws IndexException;
125132

126133
/**
127134
* Update the entry of a secondary index.
128135
* @param indexEntry the index entry to update
129136
* @return the previous row id(s) of the index entry
137+
* @throws IndexException if no existing entry(ies) to update
130138
*/
131139
List<Long> updateSecondaryIndexEntry(IndexProto.SecondaryIndexEntry indexEntry) throws IndexException;
132140

@@ -136,6 +144,7 @@ List<Long> deleteSecondaryIndexEntries(long tableId, long indexId,
136144
* @param indexId the index id of the primary index
137145
* @param indexEntries the index entries to update
138146
* @return the previous row locations of the index entries
147+
* IndexException if no existing entry(ies) to update
139148
*/
140149
List<IndexProto.RowLocation> updatePrimaryIndexEntries(long tableId, long indexId,
141150
List<IndexProto.PrimaryIndexEntry> indexEntries) throws IndexException;
@@ -146,6 +155,7 @@ List<IndexProto.RowLocation> updatePrimaryIndexEntries(long tableId, long indexI
146155
* @param indexId the index id of the secondary index
147156
* @param indexEntries the index entries to update
148157
* @return the previous row ids of the index entries
158+
* IndexException if no existing entry(ies) to update
149159
*/
150160
List<Long> updateSecondaryIndexEntries(long tableId, long indexId,
151161
List<IndexProto.SecondaryIndexEntry> indexEntries) throws IndexException;

0 commit comments

Comments
 (0)