HADOOP-2061 Add new Base64 dialects

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@585219 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Kellerman 2007-10-16 18:56:28 +00:00
parent 8a381624d9
commit ab813c3673
3 changed files with 1706 additions and 0 deletions

View File

@ -38,6 +38,7 @@ Branch 0.15 (unreleased changes)
HADOOP-1913 Build a Lucene index on an HBase table
(Ning Li via Stack)
HADOOP-1957 Web UI with report on cluster state and basic browsing of tables
HADOOP-2061 Add new Base64 dialects
OPTIMIZATIONS

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
/**
* Copyright 2007 The Apache Software Foundation
*
* 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.hadoop.hbase.util;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.TreeMap;
import junit.framework.TestCase;
/**
* Test order preservation characteristics of ordered Base64 dialect
*/
public class TestBase64 extends TestCase {
// Note: uris is sorted. We need to prove that the ordered Base64
// preserves that ordering
private String[] uris = {
"dns://dns.powerset.com/www.powerset.com",
"dns:www.powerset.com",
"file:///usr/bin/java",
"filename",
"ftp://one.two.three/index.html",
"http://one.two.three/index.html",
"https://one.two.three:9443/index.html",
"r:dns://com.powerset.dns/www.powerset.com",
"r:ftp://three.two.one/index.html",
"r:http://three.two.one/index.html",
"r:https://three.two.one:9443/index.html"
};
/**
* the test
* @throws UnsupportedEncodingException
*/
public void testBase64() throws UnsupportedEncodingException {
TreeMap<String, String> sorted = new TreeMap<String, String>();
for (int i = 0; i < uris.length; i++) {
byte[] bytes = uris[i].getBytes("UTF-8");
sorted.put(Base64.encodeBytes(bytes, Base64.ORDERED), uris[i]);
}
System.out.println();
int i = 0;
for (Map.Entry<String, String> e: sorted.entrySet()) {
assertTrue(uris[i++].compareTo(e.getValue()) == 0);
}
}
}