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 * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a> 33 */ 34 /* No qualifier */class SplitResult<K, V> extends AbstractResult<K, V> implements InsertResult<K, V> 35 { 36 /** The left child */ 37 protected Page<K, V> leftPage; 38 39 /** The right child */ 40 protected Page<K, V> rightPage; 41 42 /** The key pivot */ 43 protected K pivot; 44 45 46 /** 47 * The default constructor for SplitResult. 48 * @param pivot The new key to insert into the parent 49 * @param leftPage The new left page 50 * @param rightPage The new right page 51 */ 52 /* No qualifier */SplitResult( K pivot, Page<K, V> leftPage, Page<K, V> rightPage ) 53 { 54 super(); 55 this.pivot = pivot; 56 this.leftPage = leftPage; 57 this.rightPage = rightPage; 58 } 59 60 61 /** 62 * A constructor for SplitResult with copied pages. 63 * 64 * @param copiedPages the list of copied pages 65 * @param pivot The new key to insert into the parent 66 * @param leftPage The new left page 67 * @param rightPage The new right page 68 */ 69 /* No qualifier */SplitResult( List<Page<K, V>> copiedPages, K pivot, Page<K, V> leftPage, Page<K, V> rightPage ) 70 { 71 super( copiedPages ); 72 this.pivot = pivot; 73 this.leftPage = leftPage; 74 this.rightPage = rightPage; 75 } 76 77 78 /** 79 * @return the leftPage 80 */ 81 /* No qualifier */Page<K, V> getLeftPage() 82 { 83 return leftPage; 84 } 85 86 87 /** 88 * @return the rightPage 89 */ 90 /* No qualifier */Page<K, V> getRightPage() 91 { 92 return rightPage; 93 } 94 95 96 /** 97 * @return the pivot 98 */ 99 /* No qualifier */K getPivot() 100 { 101 return pivot; 102 } 103 104 105 /** 106 * @see Object#toString() 107 */ 108 public String toString() 109 { 110 StringBuilder sb = new StringBuilder(); 111 112 sb.append( "SplitResult, new pivot = " ).append( pivot ); 113 sb.append( "\n leftPage = " ).append( leftPage ); 114 sb.append( "\n rightPage = " ).append( rightPage ); 115 sb.append( super.toString() ); 116 117 return sb.toString(); 118 } 119 }