1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.mavibot.btree; 21 22 23 import java.util.List; 24 25 26 /** 27 * The result of an insert operation, when the page has been split. It contains 28 * the new pivotal value, plus the reference on the two new pages. 29 * 30 * @param <K> The type for the Key 31 * @param <V> The type for the stored value 32 * 33 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 34 */ 35 /* No qualifier*/class SplitResult<K, V> extends AbstractResult<K, V> implements InsertResult<K, V> 36 { 37 /** The left child */ 38 protected Page<K, V> leftPage; 39 40 /** The right child */ 41 protected Page<K, V> rightPage; 42 43 /** The key pivot */ 44 protected K pivot; 45 46 47 /** 48 * The default constructor for SplitResult. 49 * @param pivot The new key to insert into the parent 50 * @param leftPage The new left page 51 * @param rightPage The new right page 52 */ 53 public SplitResult( K pivot, Page<K, V> leftPage, Page<K, V> rightPage ) 54 { 55 super(); 56 this.pivot = pivot; 57 this.leftPage = leftPage; 58 this.rightPage = rightPage; 59 } 60 61 62 /** 63 * A constructor for SplitResult with copied pages. 64 * 65 * @param copiedPages the list of copied pages 66 * @param pivot The new key to insert into the parent 67 * @param leftPage The new left page 68 * @param rightPage The new right page 69 */ 70 public SplitResult( List<Page<K, V>> copiedPages, K pivot, Page<K, V> leftPage, Page<K, V> rightPage ) 71 { 72 super( copiedPages ); 73 this.pivot = pivot; 74 this.leftPage = leftPage; 75 this.rightPage = rightPage; 76 } 77 78 79 /** 80 * @return the leftPage 81 */ 82 public Page<K, V> getLeftPage() 83 { 84 return leftPage; 85 } 86 87 88 /** 89 * @return the rightPage 90 */ 91 public Page<K, V> getRightPage() 92 { 93 return rightPage; 94 } 95 96 97 /** 98 * @return the pivot 99 */ 100 public K getPivot() 101 { 102 return pivot; 103 } 104 105 106 /** 107 * @see Object#toString() 108 */ 109 public String toString() 110 { 111 StringBuilder sb = new StringBuilder(); 112 113 sb.append( "SplitResult, new pivot = " ).append( pivot ); 114 sb.append( "\n leftPage = " ).append( leftPage ); 115 sb.append( "\n rightPage = " ).append( rightPage ); 116 sb.append( super.toString() ); 117 118 return sb.toString(); 119 } 120 }