Adding a test file that was missed in an earlier commit.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/c65c81d9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/c65c81d9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/c65c81d9 Branch: refs/heads/master Commit: c65c81d9cd4afca4199f2355367438245b2c5654 Parents: a6b2a66 Author: Aaron McCurry <amccu...@gmail.com> Authored: Tue Jan 19 16:05:37 2016 -0500 Committer: Aaron McCurry <amccu...@gmail.com> Committed: Tue Jan 19 16:05:37 2016 -0500 ---------------------------------------------------------------------- .../blur/command/InfiniteLoopCommand.java | 69 ++++++++++++++++++++ 1 file changed, 69 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c65c81d9/blur-core/src/test/java/org/apache/blur/command/InfiniteLoopCommand.java ---------------------------------------------------------------------- diff --git a/blur-core/src/test/java/org/apache/blur/command/InfiniteLoopCommand.java b/blur-core/src/test/java/org/apache/blur/command/InfiniteLoopCommand.java new file mode 100644 index 0000000..e0efb7c --- /dev/null +++ b/blur-core/src/test/java/org/apache/blur/command/InfiniteLoopCommand.java @@ -0,0 +1,69 @@ +/** + * 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.blur.command; + +import java.io.IOException; + +import org.apache.blur.command.commandtype.IndexReadCommandSingleTable; +import org.apache.lucene.index.AtomicReader; +import org.apache.lucene.index.AtomicReaderContext; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.Terms; +import org.apache.lucene.index.TermsEnum; +import org.apache.lucene.util.BytesRef; + +public class InfiniteLoopCommand extends IndexReadCommandSingleTable<Boolean> { + + @Override + public Boolean execute(IndexContext context) throws IOException, InterruptedException { + try { + IndexReader indexReader = context.getIndexReader(); + while (true) { + long hash = 0; + for (AtomicReaderContext atomicReaderContext : indexReader.leaves()) { + AtomicReader reader = atomicReaderContext.reader(); + for (String field : reader.fields()) { + Terms terms = reader.terms(field); + BytesRef bytesRef; + TermsEnum iterator = terms.iterator(null); + while ((bytesRef = iterator.next()) != null) { + hash += bytesRef.hashCode(); + } + } + } + System.out.println("hashcode = " + hash); + } + } catch (IOException e) { + e.printStackTrace(); + throw e; + } catch (Throwable t) { + t.printStackTrace(); + if (t instanceof InterruptedException) { + throw t; + } else if (t instanceof RuntimeException) { + throw (RuntimeException) t; + } + throw new RuntimeException(t); + } + } + + @Override + public String getName() { + return "infinite-loop"; + } + +}