001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.fusesource.hawtdb.api; 018 019 import java.util.Arrays; 020 import java.util.Comparator; 021 import java.util.List; 022 023 /** 024 * Interface used to selectively visit the entries in a BTree. 025 * 026 * @param <Key> 027 * @param <Value> 028 * @author <a href="http://hiramchirino.com">Hiram Chirino</a> 029 */ 030 public interface IndexVisitor<Key,Value> { 031 032 /** 033 * Do you want to visit the range of BTree entries between the first and and second key? 034 * 035 * @param first if null indicates the range of values before the second key. 036 * @param second if null indicates the range of values after the first key. 037 * @param comparator the Comparator configured for the index, may be null. 038 * 039 * @return true if you want to visit the values between the first and second key. 040 */ 041 boolean isInterestedInKeysBetween(Key first, Key second, Comparator comparator); 042 043 /** 044 * The keys and values of an index node. 045 * 046 * @param keys 047 * @param comparator the Comparator configured for the index, may be null. 048 * @param values 049 */ 050 void visit(List<Key> keys, List<Value> values, Comparator comparator); 051 052 /** 053 * @return true if the visitor has quenched it's thirst for more results 054 */ 055 boolean isSatiated(); 056 057 }