Return-Path: Delivered-To: apmail-lucene-hadoop-commits-archive@locus.apache.org Received: (qmail 58763 invoked from network); 18 Jan 2008 00:30:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jan 2008 00:30:49 -0000 Received: (qmail 2563 invoked by uid 500); 18 Jan 2008 00:30:39 -0000 Delivered-To: apmail-lucene-hadoop-commits-archive@lucene.apache.org Received: (qmail 2532 invoked by uid 500); 18 Jan 2008 00:30:38 -0000 Mailing-List: contact hadoop-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hadoop-dev@lucene.apache.org Delivered-To: mailing list hadoop-commits@lucene.apache.org Received: (qmail 2523 invoked by uid 99); 18 Jan 2008 00:30:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jan 2008 16:30:38 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jan 2008 00:30:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 818B01A9832; Thu, 17 Jan 2008 16:30:16 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r613022 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/io/SequenceFile.java Date: Fri, 18 Jan 2008 00:30:16 -0000 To: hadoop-commits@lucene.apache.org From: omalley@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080118003016.818B01A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: omalley Date: Thu Jan 17 16:30:14 2008 New Revision: 613022 URL: http://svn.apache.org/viewvc?rev=613022&view=rev Log: HADOOP-2603. Add SequenceFileAsBinaryInputFormat to read sequence files as BytesWritable. Modified: lucene/hadoop/trunk/CHANGES.txt lucene/hadoop/trunk/src/java/org/apache/hadoop/io/SequenceFile.java Modified: lucene/hadoop/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=613022&r1=613021&r2=613022&view=diff ============================================================================== --- lucene/hadoop/trunk/CHANGES.txt (original) +++ lucene/hadoop/trunk/CHANGES.txt Thu Jan 17 16:30:14 2008 @@ -97,6 +97,10 @@ HADOOP-1883. Add versioning to Record I/O. (Vivek Ratan via ddas) + HADOOP-2603. Add SeqeunceFileAsBinaryInputFormat, which reads + sequence files as BytesWritable/BytesWritable regardless of the + key and value types used to write the file. (cdouglas via omalley) + IMPROVEMENTS HADOOP-2045. Change committer list on website to a table, so that Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/io/SequenceFile.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/io/SequenceFile.java?rev=613022&r1=613021&r2=613022&view=diff ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/io/SequenceFile.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/io/SequenceFile.java Thu Jan 17 16:30:14 2008 @@ -1294,6 +1294,8 @@ private byte version; + private String keyClassName; + private String valClassName; private Class keyClass; private Class valClass; @@ -1394,15 +1396,15 @@ if (version < BLOCK_COMPRESS_VERSION) { UTF8 className = new UTF8(); - - className.readFields(in); // read key class name - this.keyClass = WritableName.getClass(className.toString(), conf); - - className.readFields(in); // read val class name - this.valClass = WritableName.getClass(className.toString(), conf); + + className.readFields(in); + keyClassName = className.toString(); // key class name + + className.readFields(in); + valClassName = className.toString(); // val class name } else { - this.keyClass = WritableName.getClass(Text.readString(in), conf); - this.valClass = WritableName.getClass(Text.readString(in), conf); + keyClassName = Text.readString(in); + valClassName = Text.readString(in); } if (version > 2) { // if version > 2 @@ -1490,11 +1492,39 @@ in.close(); } + /** Returns the name of the key class. */ + public String getKeyClassName() { + return keyClassName; + } + /** Returns the class of keys in this file. */ - public Class getKeyClass() { return keyClass; } + public synchronized Class getKeyClass() { + if (null == keyClass) { + try { + keyClass = WritableName.getClass(getKeyClassName(), conf); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + return keyClass; + } + + /** Returns the name of the value class. */ + public String getValueClassName() { + return valClassName; + } /** Returns the class of values in this file. */ - public Class getValueClass() { return valClass; } + public synchronized Class getValueClass() { + if (null == valClass) { + try { + valClass = WritableName.getClass(getValueClassName(), conf); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + return valClass; + } /** Returns true if values are compressed. */ public boolean isCompressed() { return decompress; } @@ -1653,7 +1683,7 @@ /** Read the next key in the file into key, skipping its * value. True if another entry exists, and false at end of file. */ public synchronized boolean next(Writable key) throws IOException { - if (key.getClass() != keyClass) + if (key.getClass() != getKeyClass()) throw new IOException("wrong key class: "+key.getClass().getName() +" is not "+keyClass); @@ -1703,7 +1733,7 @@ * end of file */ public synchronized boolean next(Writable key, Writable val) throws IOException { - if (val.getClass() != valClass) + if (val.getClass() != getValueClass()) throw new IOException("wrong value class: "+val+" is not "+valClass); boolean more = next(key); @@ -2870,10 +2900,10 @@ //sometimes we ignore syncs especially for temp merge files if (ignoreSync) reader.sync = null; - if (reader.keyClass != keyClass) + if (reader.getKeyClass() != keyClass) throw new IOException("wrong key class: " + reader.getKeyClass() + " is not " + keyClass); - if (reader.valClass != valClass) + if (reader.getValueClass() != valClass) throw new IOException("wrong value class: "+reader.getValueClass()+ " is not " + valClass); this.in = reader;