AMashenkov commented on a change in pull request #468: URL: https://github.com/apache/ignite-3/pull/468#discussion_r764755028
########## File path: modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/SortedIndexStorage.java ########## @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.storage.index; + +import org.apache.ignite.internal.storage.SearchRow; +import org.apache.ignite.internal.util.Cursor; + +/** + * Storage for a Sorted Index. + * + * <p>This storage serves as a sorted mapping from a subset of a table's columns (a.k.a. index columns) to a {@link SearchRow} + * from a {@link org.apache.ignite.internal.storage.PartitionStorage} from the same table. + * + * @see org.apache.ignite.schema.definition.index.SortedIndexDefinition + */ +public interface SortedIndexStorage extends AutoCloseable { + /** + * Returns a factory for creating index keys for this storage. + */ + IndexKeyFactory indexKeyFactory(); + + /** + * Returns the Index Descriptor of this storage. + */ + SortedIndexDescriptor indexDescriptor(); + + /** + * Adds the given index key and {@link SearchRow} to the index. + * + * <p>Putting a new value under the same key will overwrite the previous associated value. + */ + void put(IndexKey key, SearchRow value); + + /** + * Removes the given key from the index. + * + * <p>Removing a non-existent key is a no-op. + */ + void remove(IndexKey key); + + /** + * Returns a range of index values between the lower bound (inclusive) and the upper bound (inclusive). + */ + // TODO: add options https://issues.apache.org/jira/browse/IGNITE-16059 + Cursor<SearchRow> range(IndexKeyPrefix lowerBound, IndexKeyPrefix upperBound); Review comment: Can we have smth like this. ```suggestion /** * Adds the given index row to the index. */ void put(IndexRow row); /** * Removes the given row from the index. */ void remove(IndexRow row); /** * Returns a range of index rows between the lower bound (inclusive) and the upper bound (inclusive). */ // TODO: add options https://issues.apache.org/jira/browse/IGNITE-16059 Cursor<IndexRow> range(IndexSearchRow lowerBound, IndexSearchRow upperBound); ``` 1. Actually, there is no keys in index. All rows are unique because they contains full keys. I'm not sure any value are needed here (in terms of key-value store), just keys. Can we write just empty byte[] as value if 'null'-value is not supported. 2. Put/remove will contains all the fields: indexed and key fields. Foreseeing a transactional support, the version might be part of key, and remove operation might be able to clean-up certain version of row. 3. Agree with separate class for range args (I'd call it "IndexSearchRow" for now), because it's structure may differs. 4. I'd hide "SearchRow" under the get method: e.g. IndexRow.getDataRowKey(). Maybe we will store a whole key "as is" inside the IndexRow. 5. Most likely we will want to get indexed columns values from an IndexRow. It is required for index-only scans, when we could return column value without retrieving a DataRow from storage. @tledkov-gridgain any objections from your side? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
