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, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package org.apache.hadoop.hbase.codec.prefixtree.row.data; 20 21 import java.util.Collections; 22 import java.util.List; 23 24 import org.apache.hadoop.hbase.CellComparator; 25 import org.apache.hadoop.hbase.KeyValue; 26 import org.apache.hadoop.hbase.KeyValue.Type; 27 import org.apache.hadoop.hbase.codec.prefixtree.row.BaseTestRowData; 28 import org.apache.hadoop.hbase.util.Bytes; 29 30 import com.google.common.collect.Lists; 31 32 public class TestRowDataNumberStrings extends BaseTestRowData{ 33 34 static List<KeyValue> d = Lists.newArrayList(); 35 static { 36 37 /** 38 * Test a string-encoded list of numbers. 0, 1, 10, 11 will sort as 0, 1, 10, 11 if strings 39 * <p/> 40 * This helped catch a bug with reverse scanning where it was jumping from the last leaf cell to 41 * the previous nub. It should do 11->10, but it was incorrectly doing 11->1 42 */ 43 List<Integer> problematicSeries = Lists.newArrayList(0, 1, 10, 11);//sort this at the end 44 for(Integer i : problematicSeries){ 45 // for(int i=0; i < 13; ++i){ 46 byte[] row = Bytes.toBytes(""+i); 47 byte[] family = Bytes.toBytes("F"); 48 byte[] column = Bytes.toBytes("C"); 49 byte[] value = Bytes.toBytes("V"); 50 51 d.add(new KeyValue(row, family, column, 0L, Type.Put, value)); 52 } 53 Collections.sort(d, new CellComparator()); 54 } 55 56 @Override 57 public List<KeyValue> getInputs() { 58 return d; 59 } 60 61 }