http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0f78613d/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/SerializerUtil.java ---------------------------------------------------------------------- diff --git a/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/SerializerUtil.java b/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/SerializerUtil.java deleted file mode 100644 index a43ac0e..0000000 --- a/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/SerializerUtil.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.apache.blur.lucene.serializer; - -/** - * 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. - */ -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.UnicodeUtil; - -public class SerializerUtil { - - public static void writeString(String s, DataOutput out) throws IOException { - BytesRef bytes = new BytesRef(); - UnicodeUtil.UTF16toUTF8(s, 0, s.length(), bytes); - writeBytesRef(bytes, out); - } - - public static void writeBytesRef(BytesRef bytes, DataOutput out) throws IOException { - out.writeInt(bytes.length); - out.write(bytes.bytes, bytes.offset, bytes.length); - } - - public static String readString(DataInput in) throws IOException { - BytesRef bytes = readBytesRef(in); - return bytes.utf8ToString(); - } - - public static BytesRef readBytesRef(DataInput in) throws IOException { - int length = in.readInt(); - BytesRef bytes = new BytesRef(length); - in.readFully(bytes.bytes); - bytes.offset = 0; - bytes.length = length; - return bytes; - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0f78613d/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/TermQueryWritable.java ---------------------------------------------------------------------- diff --git a/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/TermQueryWritable.java b/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/TermQueryWritable.java deleted file mode 100644 index 4173ac2..0000000 --- a/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/TermQueryWritable.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.blur.lucene.serializer; - -/** - * 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. - */ -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.lucene.index.Term; -import org.apache.lucene.search.TermQuery; - -public class TermQueryWritable extends AbtractQueryWritable<TermQuery> { - - private TermQuery query; - - public TermQuery getQuery() { - return query; - } - - public void setQuery(TermQuery query) { - this.query = query; - } - - public TermQueryWritable() { - - } - - public TermQueryWritable(TermQuery termQuery) { - this.query = termQuery; - } - - @Override - public void write(DataOutput out) throws IOException { - out.writeFloat(query.getBoost()); - Term term = query.getTerm(); - new TermWritable(term).write(out); - } - - @Override - public void readFields(DataInput in) throws IOException { - float boost = in.readFloat(); - TermWritable termWritable = new TermWritable(); - termWritable.readFields(in); - query = new TermQuery(termWritable.getTerm()); - query.setBoost(boost); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0f78613d/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/TermWritable.java ---------------------------------------------------------------------- diff --git a/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/TermWritable.java b/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/TermWritable.java deleted file mode 100644 index 9c008b5..0000000 --- a/src/blur-store/src/main/java/org/apache/blur/lucene/serializer/TermWritable.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.blur.lucene.serializer; - -/** - * 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. - */ -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.hadoop.io.Writable; -import org.apache.lucene.index.Term; -import org.apache.lucene.util.BytesRef; - -public class TermWritable implements Writable { - - private Term term; - - public TermWritable() { - - } - - public TermWritable(Term term) { - this.term = term; - } - - public Term getTerm() { - return term; - } - - public void setTerm(Term term) { - this.term = term; - } - - @Override - public void write(DataOutput out) throws IOException { - String field = term.field(); - BytesRef bytes = term.bytes(); - SerializerUtil.writeString(field, out); - SerializerUtil.writeBytesRef(bytes, out); - } - - @Override - public void readFields(DataInput in) throws IOException { - String field = SerializerUtil.readString(in); - BytesRef bytes = SerializerUtil.readBytesRef(in); - term = new Term(field, bytes); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0f78613d/src/blur-store/src/test/java/org/apache/blur/lucene/serializer/QueryWritableTest.java ---------------------------------------------------------------------- diff --git a/src/blur-store/src/test/java/org/apache/blur/lucene/serializer/QueryWritableTest.java b/src/blur-store/src/test/java/org/apache/blur/lucene/serializer/QueryWritableTest.java deleted file mode 100644 index 2b1e87c..0000000 --- a/src/blur-store/src/test/java/org/apache/blur/lucene/serializer/QueryWritableTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.blur.lucene.serializer; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; - -import org.apache.hadoop.io.DataInputBuffer; -import org.apache.hadoop.io.DataOutputBuffer; -import org.apache.lucene.index.Term; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TermQuery; -import org.junit.Test; - -public class QueryWritableTest { - - @Test - public void testTermQuery() throws IOException { - TermQuery query = new TermQuery(new Term("field","value")); - QueryWritable queryWritable = new QueryWritable(); - queryWritable.setQuery(query); - DataOutputBuffer out = new DataOutputBuffer(); - queryWritable.write(out); - byte[] data = out.getData(); - int length = out.getLength(); - - DataInputBuffer in = new DataInputBuffer(); - in.reset(data, length); - - QueryWritable newQueryWritable = new QueryWritable(); - newQueryWritable.readFields(in); - - Query termQuery = newQueryWritable.getQuery(); - - assertEquals(query,termQuery); - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0f78613d/src/pom.xml ---------------------------------------------------------------------- diff --git a/src/pom.xml b/src/pom.xml index 390f328..eb88760 100644 --- a/src/pom.xml +++ b/src/pom.xml @@ -55,6 +55,7 @@ under the License. <modules> <module>blur-core</module> <module>blur-thrift</module> + <module>blur-query</module> <module>blur-store</module> <module>blur-mapred</module> <module>blur-util</module>
