http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/entity/StarQuery.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/entity/StarQuery.java b/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/entity/StarQuery.java index 3700988..dedf85d 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/entity/StarQuery.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/entity/StarQuery.java @@ -1,5 +1,7 @@ package org.apache.rya.indexing.accumulo.entity; +import java.nio.charset.StandardCharsets; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -25,6 +27,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.accumulo.core.client.TableNotFoundException; +import org.apache.hadoop.io.Text; import org.apache.rya.accumulo.documentIndex.TextColumn; import org.apache.rya.api.domain.RyaType; import org.apache.rya.api.domain.RyaURI; @@ -32,9 +36,6 @@ import org.apache.rya.api.resolver.RdfToRyaConversions; import org.apache.rya.api.resolver.RyaContext; import org.apache.rya.api.resolver.RyaTypeResolverException; import org.apache.rya.joinselect.AccumuloSelectivityEvalDAO; - -import org.apache.accumulo.core.client.TableNotFoundException; -import org.apache.hadoop.io.Text; import org.openrdf.model.Value; import org.openrdf.query.BindingSet; import org.openrdf.query.algebra.StatementPattern; @@ -47,23 +48,23 @@ import com.google.common.primitives.Bytes; public class StarQuery { - private List<StatementPattern> nodes; - private TextColumn[] nodeColumnCond; + private final List<StatementPattern> nodes; + private final TextColumn[] nodeColumnCond; private String commonVarName; private Var commonVar; private Var context; private String contextURI =""; - private Map<String,Integer> varPos = Maps.newHashMap(); + private final Map<String,Integer> varPos = Maps.newHashMap(); private boolean isCommonVarURI = false; - public StarQuery(List<StatementPattern> nodes) { + public StarQuery(final List<StatementPattern> nodes) { this.nodes = nodes; if(nodes.size() == 0) { throw new IllegalArgumentException("Nodes cannot be empty!"); } nodeColumnCond = new TextColumn[nodes.size()]; - Var tempContext = nodes.get(0).getContextVar(); + final Var tempContext = nodes.get(0).getContextVar(); if(tempContext != null) { context = tempContext.clone(); } else { @@ -71,13 +72,13 @@ public class StarQuery { } try { this.init(); - } catch (RyaTypeResolverException e) { + } catch (final RyaTypeResolverException e) { e.printStackTrace(); } } - public StarQuery(Set<StatementPattern> nodes) { + public StarQuery(final Set<StatementPattern> nodes) { this(Lists.newArrayList(nodes)); } @@ -85,7 +86,7 @@ public class StarQuery { return nodes.size(); } - public StarQuery(StarQuery other) { + public StarQuery(final StarQuery other) { this(other.nodes); } @@ -153,7 +154,7 @@ public class StarQuery { Set<String> bindingNames = Sets.newHashSet(); - for(StatementPattern sp: nodes) { + for(final StatementPattern sp: nodes) { if(bindingNames.size() == 0) { bindingNames = sp.getBindingNames(); @@ -174,7 +175,7 @@ public class StarQuery { Set<String> bindingNames = Sets.newHashSet(); - for(StatementPattern sp: nodes) { + for(final StatementPattern sp: nodes) { if(bindingNames.size() == 0) { bindingNames = sp.getAssuredBindingNames(); @@ -194,13 +195,13 @@ public class StarQuery { - public CardinalityStatementPattern getMinCardSp(AccumuloSelectivityEvalDAO ase) { + public CardinalityStatementPattern getMinCardSp(final AccumuloSelectivityEvalDAO ase) { StatementPattern minSp = null; double cardinality = Double.MAX_VALUE; double tempCard = -1; - for (StatementPattern sp : nodes) { + for (final StatementPattern sp : nodes) { try { tempCard = ase.getCardinality(ase.getConf(), sp); @@ -209,7 +210,7 @@ public class StarQuery { cardinality = tempCard; minSp = sp; } - } catch (TableNotFoundException e) { + } catch (final TableNotFoundException e) { e.printStackTrace(); } @@ -223,10 +224,10 @@ public class StarQuery { public class CardinalityStatementPattern { - private StatementPattern sp; - private double cardinality; + private final StatementPattern sp; + private final double cardinality; - public CardinalityStatementPattern(StatementPattern sp, double cardinality) { + public CardinalityStatementPattern(final StatementPattern sp, final double cardinality) { this.sp = sp; this.cardinality = cardinality; } @@ -242,7 +243,7 @@ public class StarQuery { } - public double getCardinality( AccumuloSelectivityEvalDAO ase) { + public double getCardinality( final AccumuloSelectivityEvalDAO ase) { double cardinality = Double.MAX_VALUE; double tempCard = -1; @@ -263,7 +264,7 @@ public class StarQuery { } } - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } @@ -275,15 +276,15 @@ public class StarQuery { - public static Set<String> getCommonVars(StarQuery query, BindingSet bs) { + public static Set<String> getCommonVars(final StarQuery query, final BindingSet bs) { - Set<String> starQueryVarNames = Sets.newHashSet(); + final Set<String> starQueryVarNames = Sets.newHashSet(); if(bs == null || bs.size() == 0) { return Sets.newHashSet(); } - Set<String> bindingNames = bs.getBindingNames(); + final Set<String> bindingNames = bs.getBindingNames(); starQueryVarNames.addAll(query.getUnCommonVars()); if(!query.commonVarConstant()) { starQueryVarNames.add(query.getCommonVarName()); @@ -299,30 +300,30 @@ public class StarQuery { - public static StarQuery getConstrainedStarQuery(StarQuery query, BindingSet bs) { + public static StarQuery getConstrainedStarQuery(final StarQuery query, final BindingSet bs) { if(bs.size() == 0) { return query; } - Set<String> bindingNames = bs.getBindingNames(); - Set<String> unCommonVarNames = query.getUnCommonVars(); - Set<String> intersectVar = Sets.intersection(bindingNames, unCommonVarNames); + final Set<String> bindingNames = bs.getBindingNames(); + final Set<String> unCommonVarNames = query.getUnCommonVars(); + final Set<String> intersectVar = Sets.intersection(bindingNames, unCommonVarNames); if (!query.commonVarConstant()) { - Value v = bs.getValue(query.getCommonVarName()); + final Value v = bs.getValue(query.getCommonVarName()); if (v != null) { query.commonVar.setValue(v); } } - for(String s: intersectVar) { + for(final String s: intersectVar) { try { query.nodeColumnCond[query.varPos.get(s)] = query.setValue(query.nodeColumnCond[query.varPos.get(s)], bs.getValue(s)); - } catch (RyaTypeResolverException e) { + } catch (final RyaTypeResolverException e) { e.printStackTrace(); } } @@ -331,20 +332,20 @@ public class StarQuery { } - private TextColumn setValue(TextColumn tc, Value v) throws RyaTypeResolverException { + private TextColumn setValue(final TextColumn tc, final Value v) throws RyaTypeResolverException { - String cq = tc.getColumnQualifier().toString(); - String[] cqArray = cq.split("\u0000"); + final String cq = tc.getColumnQualifier().toString(); + final String[] cqArray = cq.split("\u0000"); if (cqArray[0].equals("subject")) { // RyaURI subjURI = (RyaURI) RdfToRyaConversions.convertValue(v); tc.setColumnQualifier(new Text("subject" + "\u0000" + v.stringValue())); tc.setIsPrefix(false); } else if (cqArray[0].equals("object")) { - RyaType objType = RdfToRyaConversions.convertValue(v); - byte[][] b1 = RyaContext.getInstance().serializeType(objType); - byte[] b2 = Bytes.concat("object".getBytes(), - "\u0000".getBytes(), b1[0], b1[1]); + final RyaType objType = RdfToRyaConversions.convertValue(v); + final byte[][] b1 = RyaContext.getInstance().serializeType(objType); + final byte[] b2 = Bytes.concat("object".getBytes(StandardCharsets.UTF_8), + "\u0000".getBytes(StandardCharsets.UTF_8), b1[0], b1[1]); tc.setColumnQualifier(new Text(b2)); tc.setIsPrefix(false); } else { @@ -359,15 +360,15 @@ public class StarQuery { //assumes nodes forms valid star query with only one common variable //assumes nodes and commonVar has been set - private TextColumn nodeToTextColumn(StatementPattern node, int i) throws RyaTypeResolverException { + private TextColumn nodeToTextColumn(final StatementPattern node, final int i) throws RyaTypeResolverException { - RyaContext rc = RyaContext.getInstance(); + final RyaContext rc = RyaContext.getInstance(); - Var subjVar = node.getSubjectVar(); - Var predVar = node.getPredicateVar(); - Var objVar = node.getObjectVar(); + final Var subjVar = node.getSubjectVar(); + final Var predVar = node.getPredicateVar(); + final Var objVar = node.getObjectVar(); - RyaURI predURI = (RyaURI) RdfToRyaConversions.convertValue(node.getPredicateVar().getValue()); + final RyaURI predURI = (RyaURI) RdfToRyaConversions.convertValue(node.getPredicateVar().getValue()); //assumes StatementPattern contains at least on variable @@ -388,10 +389,10 @@ public class StarQuery { } else { isCommonVarURI = true; - RyaType objType = RdfToRyaConversions.convertValue(objVar.getValue()); - byte[][] b1 = rc.serializeType(objType); + final RyaType objType = RdfToRyaConversions.convertValue(objVar.getValue()); + final byte[][] b1 = rc.serializeType(objType); - byte[] b2 = Bytes.concat("object".getBytes(), "\u0000".getBytes(), b1[0], b1[1]); + final byte[] b2 = Bytes.concat("object".getBytes(StandardCharsets.UTF_8), "\u0000".getBytes(StandardCharsets.UTF_8), b1[0], b1[1]); return new TextColumn(new Text(predURI.getData()), new Text(b2)); } @@ -401,7 +402,7 @@ public class StarQuery { isCommonVarURI = true; varPos.put(objVar.getName(), i); - TextColumn tc = new TextColumn(new Text(predURI.getData()), new Text("object")); + final TextColumn tc = new TextColumn(new Text(predURI.getData()), new Text("object")); tc.setIsPrefix(true); return tc; @@ -409,7 +410,7 @@ public class StarQuery { varPos.put(subjVar.getName(), i); - TextColumn tc = new TextColumn(new Text(predURI.getData()), new Text("subject")); + final TextColumn tc = new TextColumn(new Text(predURI.getData()), new Text("subject")); tc.setIsPrefix(true); return tc; @@ -437,7 +438,7 @@ public class StarQuery { } if(hasContext()) { - RyaURI ctxtURI = (RyaURI) RdfToRyaConversions.convertValue(context.getValue()); + final RyaURI ctxtURI = (RyaURI) RdfToRyaConversions.convertValue(context.getValue()); contextURI = ctxtURI.getData(); } @@ -456,14 +457,14 @@ public class StarQuery { // called after nodes set // assumes nodes forms valid query with single, common variable - private Var getCommonVar(List<StatementPattern> nodes) { + private Var getCommonVar(final List<StatementPattern> nodes) { Set<Var> vars = null; - List<Var> tempVar; + final List<Var> tempVar; Set<Var> tempSet; int i = 0; - for (StatementPattern sp : nodes) { + for (final StatementPattern sp : nodes) { if (vars == null) { vars = Sets.newHashSet(); @@ -485,7 +486,7 @@ public class StarQuery { i = 0; - for (Var v : vars) { + for (final Var v : vars) { i++; if (i == 1) { @@ -507,7 +508,7 @@ public class StarQuery { //assumes bindings is not of size 0 - private static boolean isBindingsetValid(Set<String> bindings) { + private static boolean isBindingsetValid(final Set<String> bindings) { int varCount = 0; @@ -516,7 +517,7 @@ public class StarQuery { } else { - for (String s : bindings) { + for (final String s : bindings) { if (!s.startsWith("-const-")) { varCount++; } @@ -535,7 +536,7 @@ public class StarQuery { - public static boolean isValidStarQuery(Collection<StatementPattern> nodes) { + public static boolean isValidStarQuery(final Collection<StatementPattern> nodes) { Set<String> bindings = null; boolean contextSet = false; @@ -545,10 +546,10 @@ public class StarQuery { return false; } - for(StatementPattern sp: nodes) { + for(final StatementPattern sp: nodes) { - Var tempContext = sp.getContextVar(); - Var predVar = sp.getPredicateVar(); + final Var tempContext = sp.getContextVar(); + final Var predVar = sp.getPredicateVar(); //does not support variable context if(tempContext != null && !tempContext.isConstant()) { @@ -617,7 +618,7 @@ public class StarQuery { String s = "Term conditions: " + "\n"; - for (TextColumn element : this.nodeColumnCond) { + for (final TextColumn element : this.nodeColumnCond) { s = s + element.toString() + "\n"; }
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/freetext/iterators/AndingIterator.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/freetext/iterators/AndingIterator.java b/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/freetext/iterators/AndingIterator.java index b63e0d2..f4c9436 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/freetext/iterators/AndingIterator.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/freetext/iterators/AndingIterator.java @@ -1,5 +1,3 @@ -package org.apache.rya.indexing.accumulo.freetext.iterators; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -8,9 +6,9 @@ package org.apache.rya.indexing.accumulo.freetext.iterators; * 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 @@ -18,10 +16,10 @@ package org.apache.rya.indexing.accumulo.freetext.iterators; * specific language governing permissions and limitations * under the License. */ - - +package org.apache.rya.indexing.accumulo.freetext.iterators; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Collections; import java.util.Map; @@ -49,27 +47,27 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { protected Text nullText = new Text(); - protected Text getPartition(Key key) { + protected Text getPartition(final Key key) { return key.getRow(); } - protected Text getTerm(Key key) { + protected Text getTerm(final Key key) { return key.getColumnFamily(); } - protected Text getDocID(Key key) { + protected Text getDocID(final Key key) { return key.getColumnQualifier(); } - protected Key buildKey(Text partition, Text term) { + protected Key buildKey(final Text partition, final Text term) { return new Key(partition, (term == null) ? nullText : term); } - protected Key buildKey(Text partition, Text term, Text docID) { + protected Key buildKey(final Text partition, final Text term, final Text docID) { return new Key(partition, (term == null) ? nullText : term, docID); } - protected Key buildFollowingPartitionKey(Key key) { + protected Key buildFollowingPartitionKey(final Key key) { return key.followingKey(PartialKey.ROW); } @@ -81,18 +79,18 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { public Collection<ByteSequence> seekColfams; public boolean notFlag; - public TermSource(TermSource other) { + public TermSource(final TermSource other) { this.iter = other.iter; this.term = other.term; this.notFlag = other.notFlag; this.seekColfams = other.seekColfams; } - public TermSource(SortedKeyValueIterator<Key, Value> iter, Text term) { + public TermSource(final SortedKeyValueIterator<Key, Value> iter, final Text term) { this(iter, term, false); } - public TermSource(SortedKeyValueIterator<Key, Value> iter, Text term, boolean notFlag) { + public TermSource(final SortedKeyValueIterator<Key, Value> iter, final Text term, final boolean notFlag) { this.iter = iter; this.term = term; this.notFlag = notFlag; @@ -128,11 +126,11 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { } @Override - public SortedKeyValueIterator<Key, Value> deepCopy(IteratorEnvironment env) { + public SortedKeyValueIterator<Key, Value> deepCopy(final IteratorEnvironment env) { return new AndingIterator(this, env); } - private AndingIterator(AndingIterator other, IteratorEnvironment env) { + private AndingIterator(final AndingIterator other, final IteratorEnvironment env) { if (other.sources != null) { sourcesCount = other.sourcesCount; sources = new TermSource[sourcesCount]; @@ -159,7 +157,7 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { } // precondition: currentRow is not null - private boolean seekOneSource(int sourceID) throws IOException { + private boolean seekOneSource(final int sourceID) throws IOException { // find the next key in the appropriate column family that is at or beyond the cursor (currentRow, currentCQ) // advance the cursor if this source goes beyond it // return whether we advanced the cursor @@ -189,13 +187,13 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { break; } } - int partitionCompare = currentPartition.compareTo(getPartition(sources[sourceID].iter.getTopKey())); + final int partitionCompare = currentPartition.compareTo(getPartition(sources[sourceID].iter.getTopKey())); // check if this source is already at or beyond currentRow // if not, then seek to at least the current row if (partitionCompare > 0) { // seek to at least the currentRow - Key seekKey = buildKey(currentPartition, sources[sourceID].term); + final Key seekKey = buildKey(currentPartition, sources[sourceID].term); sources[sourceID].iter.seek(new Range(seekKey, true, null, false), sources[sourceID].seekColfams, true); continue; } @@ -208,11 +206,11 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { // now we must make sure we're in the right columnFamily in the current row // Note: Iterators are auto-magically set to the correct columnFamily if (sources[sourceID].term != null) { - int termCompare = sources[sourceID].term.compareTo(getTerm(sources[sourceID].iter.getTopKey())); + final int termCompare = sources[sourceID].term.compareTo(getTerm(sources[sourceID].iter.getTopKey())); // check if this source is already on the right columnFamily // if not, then seek forwards to the right columnFamily if (termCompare > 0) { - Key seekKey = buildKey(currentPartition, sources[sourceID].term, currentDocID); + final Key seekKey = buildKey(currentPartition, sources[sourceID].term, currentDocID); sources[sourceID].iter.seek(new Range(seekKey, true, null, false), sources[sourceID].seekColfams, true); continue; } @@ -225,8 +223,8 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { // we have verified that we are in currentRow and the correct column family // make sure we are at or beyond columnQualifier - Text docID = getDocID(sources[sourceID].iter.getTopKey()); - int docIDCompare = currentDocID.compareTo(docID); + final Text docID = getDocID(sources[sourceID].iter.getTopKey()); + final int docIDCompare = currentDocID.compareTo(docID); // If we are past the target, this is a valid result if (docIDCompare < 0) { break; @@ -234,7 +232,7 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { // if this source is not yet at the currentCQ then advance in this source if (docIDCompare > 0) { // seek forwards - Key seekKey = buildKey(currentPartition, sources[sourceID].term, currentDocID); + final Key seekKey = buildKey(currentPartition, sources[sourceID].term, currentDocID); sources[sourceID].iter.seek(new Range(seekKey, true, null, false), sources[sourceID].seekColfams, true); continue; } @@ -267,12 +265,12 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { return true; } } - int partitionCompare = currentPartition.compareTo(getPartition(sources[sourceID].iter.getTopKey())); + final int partitionCompare = currentPartition.compareTo(getPartition(sources[sourceID].iter.getTopKey())); // check if this source is already at or beyond currentRow // if not, then seek to at least the current row if (partitionCompare > 0) { // seek to at least the currentRow - Key seekKey = buildKey(currentPartition, sources[sourceID].term); + final Key seekKey = buildKey(currentPartition, sources[sourceID].term); sources[sourceID].iter.seek(new Range(seekKey, true, null, false), sources[sourceID].seekColfams, true); continue; } @@ -289,11 +287,11 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { // Note: Iterators are auto-magically set to the correct columnFamily if (sources[sourceID].term != null) { - int termCompare = sources[sourceID].term.compareTo(getTerm(sources[sourceID].iter.getTopKey())); + final int termCompare = sources[sourceID].term.compareTo(getTerm(sources[sourceID].iter.getTopKey())); // check if this source is already on the right columnFamily // if not, then seek forwards to the right columnFamily if (termCompare > 0) { - Key seekKey = buildKey(currentPartition, sources[sourceID].term, currentDocID); + final Key seekKey = buildKey(currentPartition, sources[sourceID].term, currentDocID); sources[sourceID].iter.seek(new Range(seekKey, true, null, false), sources[sourceID].seekColfams, true); continue; } @@ -313,15 +311,15 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { // setting currentRow to null counts as advancing the cursor return true; } - Key seekKey = buildFollowingPartitionKey(sources[sourceID].iter.getTopKey()); + final Key seekKey = buildFollowingPartitionKey(sources[sourceID].iter.getTopKey()); sources[sourceID].iter.seek(new Range(seekKey, true, null, false), sources[sourceID].seekColfams, true); continue; } } // we have verified that we are in currentRow and the correct column family // make sure we are at or beyond columnQualifier - Text docID = getDocID(sources[sourceID].iter.getTopKey()); - int docIDCompare = currentDocID.compareTo(docID); + final Text docID = getDocID(sources[sourceID].iter.getTopKey()); + final int docIDCompare = currentDocID.compareTo(docID); // if this source has advanced beyond the current column qualifier then advance currentCQ and return true if (docIDCompare < 0) { currentDocID.set(docID); @@ -331,7 +329,7 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { // if this source is not yet at the currentCQ then seek in this source if (docIDCompare > 0) { // seek forwards - Key seekKey = buildKey(currentPartition, sources[sourceID].term, currentDocID); + final Key seekKey = buildKey(currentPartition, sources[sourceID].term, currentDocID); sources[sourceID].iter.seek(new Range(seekKey, true, null, false), sources[sourceID].seekColfams, true); continue; } @@ -372,9 +370,10 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { topKey = buildKey(currentPartition, nullText, currentDocID); } - public static String stringTopKey(SortedKeyValueIterator<Key, Value> iter) { - if (iter.hasTop()) - return iter.getTopKey().toString(); + public static String stringTopKey(final SortedKeyValueIterator<Key, Value> iter) { + if (iter.hasTop()) { + return iter.getTopKey().toString(); + } return ""; } @@ -387,10 +386,11 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { * @deprecated since 1.4. To be made protected. Do not interact with flags string directly, just use * {@link #setColumnFamilies(IteratorSetting, Text[], boolean[])}. */ - public static String encodeColumns(Text[] columns) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < columns.length; i++) { - sb.append(new String(Base64.encodeBase64(TextUtil.getBytes(columns[i])))); + @Deprecated + public static String encodeColumns(final Text[] columns) { + final StringBuilder sb = new StringBuilder(); + for (final Text column : columns) { + sb.append(new String(Base64.encodeBase64(TextUtil.getBytes(column)), StandardCharsets.UTF_8)); sb.append('\n'); } return sb.toString(); @@ -402,53 +402,58 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { * @deprecated since 1.4. To be made protected. Do not interact with flags string directly, just use * {@link #setColumnFamilies(IteratorSetting, Text[], boolean[])}. */ - public static String encodeBooleans(boolean[] flags) { - byte[] bytes = new byte[flags.length]; + @Deprecated + public static String encodeBooleans(final boolean[] flags) { + final byte[] bytes = new byte[flags.length]; for (int i = 0; i < flags.length; i++) { - if (flags[i]) - bytes[i] = 1; - else - bytes[i] = 0; + if (flags[i]) { + bytes[i] = 1; + } else { + bytes[i] = 0; + } } - return new String(Base64.encodeBase64(bytes)); + return new String(Base64.encodeBase64(bytes), StandardCharsets.UTF_8); } - protected static Text[] decodeColumns(String columns) { - String[] columnStrings = columns.split("\n"); - Text[] columnTexts = new Text[columnStrings.length]; + protected static Text[] decodeColumns(final String columns) { + final String[] columnStrings = columns.split("\n"); + final Text[] columnTexts = new Text[columnStrings.length]; for (int i = 0; i < columnStrings.length; i++) { - columnTexts[i] = new Text(Base64.decodeBase64(columnStrings[i].getBytes())); + columnTexts[i] = new Text(Base64.decodeBase64(columnStrings[i].getBytes(StandardCharsets.UTF_8))); } return columnTexts; } /** * to be made protected - * + * * @param flags * @return decoded flags * @deprecated since 1.4. To be made protected. Do not interact with flags string directly, just use * {@link #setColumnFamilies(IteratorSetting, Text[], boolean[])}. */ - public static boolean[] decodeBooleans(String flags) { + @Deprecated + public static boolean[] decodeBooleans(final String flags) { // return null of there were no flags - if (flags == null) - return null; + if (flags == null) { + return null; + } - byte[] bytes = Base64.decodeBase64(flags.getBytes()); - boolean[] bFlags = new boolean[bytes.length]; + final byte[] bytes = Base64.decodeBase64(flags.getBytes(StandardCharsets.UTF_8)); + final boolean[] bFlags = new boolean[bytes.length]; for (int i = 0; i < bytes.length; i++) { - if (bytes[i] == 1) - bFlags[i] = true; - else - bFlags[i] = false; + if (bytes[i] == 1) { + bFlags[i] = true; + } else { + bFlags[i] = false; + } } return bFlags; } @Override - public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException { - Text[] terms = decodeColumns(options.get(columnFamiliesOptionName)); + public void init(final SortedKeyValueIterator<Key, Value> source, final Map<String, String> options, final IteratorEnvironment env) throws IOException { + final Text[] terms = decodeColumns(options.get(columnFamiliesOptionName)); boolean[] notFlag = decodeBooleans(options.get(notFlagOptionName)); if (terms.length < 2) { @@ -460,13 +465,14 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { // And we are going to re-order such that the first term is not a ! term if (notFlag == null) { notFlag = new boolean[terms.length]; - for (int i = 0; i < terms.length; i++) - notFlag[i] = false; + for (int i = 0; i < terms.length; i++) { + notFlag[i] = false; + } } if (notFlag[0]) { for (int i = 1; i < notFlag.length; i++) { if (notFlag[i] == false) { - Text swapFamily = new Text(terms[0]); + final Text swapFamily = new Text(terms[0]); terms[0].set(terms[i]); terms[i].set(swapFamily); notFlag[0] = false; @@ -488,7 +494,7 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { } @Override - public void seek(Range range, Collection<ByteSequence> seekColumnFamilies, boolean inclusive) throws IOException { + public void seek(final Range range, final Collection<ByteSequence> seekColumnFamilies, final boolean inclusive) throws IOException { overallRange = new Range(range); currentPartition = new Text(); currentDocID.set(emptyByteArray); @@ -512,16 +518,16 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { advanceToIntersection(); } - public void addSource(SortedKeyValueIterator<Key, Value> source, IteratorEnvironment env, Text term, boolean notFlag) { + public void addSource(final SortedKeyValueIterator<Key, Value> source, final IteratorEnvironment env, final Text term, final boolean notFlag) { // Check if we have space for the added Source if (sources == null) { sources = new TermSource[1]; } else { // allocate space for node, and copy current tree. // TODO: Should we change this to an ArrayList so that we can just add() ? - TermSource[] localSources = new TermSource[sources.length + 1]; + final TermSource[] localSources = new TermSource[sources.length + 1]; int currSource = 0; - for (TermSource myTerm : sources) { + for (final TermSource myTerm : sources) { // TODO: Do I need to call new here? or can I just re-use the term? localSources[currSource] = new TermSource(myTerm); currSource++; @@ -534,29 +540,32 @@ public class AndingIterator implements SortedKeyValueIterator<Key, Value> { /** * Encode the columns to be used when iterating. - * + * * @param cfg * @param columns */ - public static void setColumnFamilies(IteratorSetting cfg, Text[] columns) { - if (columns.length < 2) - throw new IllegalArgumentException("Must supply at least two terms to intersect"); + public static void setColumnFamilies(final IteratorSetting cfg, final Text[] columns) { + if (columns.length < 2) { + throw new IllegalArgumentException("Must supply at least two terms to intersect"); + } cfg.addOption(AndingIterator.columnFamiliesOptionName, AndingIterator.encodeColumns(columns)); } /** * Encode columns and NOT flags indicating which columns should be negated (docIDs will be excluded if matching negated columns, instead * of included). - * + * * @param cfg * @param columns * @param notFlags */ - public static void setColumnFamilies(IteratorSetting cfg, Text[] columns, boolean[] notFlags) { - if (columns.length < 2) - throw new IllegalArgumentException("Must supply at least two terms to intersect"); - if (columns.length != notFlags.length) - throw new IllegalArgumentException("columns and notFlags arrays must be the same length"); + public static void setColumnFamilies(final IteratorSetting cfg, final Text[] columns, final boolean[] notFlags) { + if (columns.length < 2) { + throw new IllegalArgumentException("Must supply at least two terms to intersect"); + } + if (columns.length != notFlags.length) { + throw new IllegalArgumentException("columns and notFlags arrays must be the same length"); + } setColumnFamilies(cfg, columns); cfg.addOption(AndingIterator.notFlagOptionName, AndingIterator.encodeBooleans(notFlags)); } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/freetext/query/SimpleCharStream.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/freetext/query/SimpleCharStream.java b/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/freetext/query/SimpleCharStream.java index 5d69967..3bc9164 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/freetext/query/SimpleCharStream.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/freetext/query/SimpleCharStream.java @@ -1,887 +1,3 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */ -/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package org.apache.rya.indexing.accumulo.freetext.query; - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - -/* - * 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. - */ - - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -890,9 +6,9 @@ package org.apache.rya.indexing.accumulo.freetext.query; * 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 @@ -900,8 +16,11 @@ package org.apache.rya.indexing.accumulo.freetext.query; * specific language governing permissions and limitations * under the License. */ +/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */ +/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package org.apache.rya.indexing.accumulo.freetext.query; - +import java.nio.charset.StandardCharsets; /** * An implementation of interface CharStream, where the stream is assumed to @@ -933,15 +52,15 @@ public class SimpleCharStream protected int inBuf = 0; protected int tabSize = 8; - protected void setTabSize(int i) { tabSize = i; } - protected int getTabSize(int i) { return tabSize; } + protected void setTabSize(final int i) { tabSize = i; } + protected int getTabSize(final int i) { return tabSize; } - protected void ExpandBuff(boolean wrapAround) + protected void ExpandBuff(final boolean wrapAround) { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; + final char[] newbuffer = new char[bufsize + 2048]; + final int newbufline[] = new int[bufsize + 2048]; + final int newbufcolumn[] = new int[bufsize + 2048]; try { @@ -975,7 +94,7 @@ public class SimpleCharStream maxNextCharInd = (bufpos -= tokenBegin); } } - catch (Throwable t) + catch (final Throwable t) { throw new Error(t.getMessage()); } @@ -997,18 +116,20 @@ public class SimpleCharStream bufpos = maxNextCharInd = 0; available = tokenBegin; } - else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); + else if (tokenBegin < 0) { + bufpos = maxNextCharInd = 0; + } else { + ExpandBuff(false); + } } - else if (available > tokenBegin) + else if (available > tokenBegin) { available = bufsize; - else if ((tokenBegin - available) < 2048) + } else if ((tokenBegin - available) < 2048) { ExpandBuff(true); - else + } else { available = tokenBegin; } + } int i; try { @@ -1016,16 +137,17 @@ public class SimpleCharStream { inputStream.close(); throw new java.io.IOException(); - } - else + } else { maxNextCharInd += i; + } return; } - catch(java.io.IOException e) { + catch(final java.io.IOException e) { --bufpos; backup(0); - if (tokenBegin == -1) + if (tokenBegin == -1) { tokenBegin = bufpos; + } throw e; } } @@ -1034,13 +156,13 @@ public class SimpleCharStream public char BeginToken() throws java.io.IOException { tokenBegin = -1; - char c = readChar(); + final char c = readChar(); tokenBegin = bufpos; return c; } - protected void UpdateLineColumn(char c) + protected void UpdateLineColumn(final char c) { column++; @@ -1055,10 +177,10 @@ public class SimpleCharStream if (c == '\n') { prevCharIsLF = true; - } - else + } else { line += (column = 1); } + } switch (c) { @@ -1087,16 +209,18 @@ public class SimpleCharStream { --inBuf; - if (++bufpos == bufsize) + if (++bufpos == bufsize) { bufpos = 0; + } return buffer[bufpos]; } - if (++bufpos >= maxNextCharInd) - FillBuff(); + if (++bufpos >= maxNextCharInd) { + FillBuff(); + } - char c = buffer[bufpos]; + final char c = buffer[bufpos]; UpdateLineColumn(c); return c; @@ -1143,16 +267,17 @@ public class SimpleCharStream } /** Backup a number of characters. */ - public void backup(int amount) { + public void backup(final int amount) { inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; + if ((bufpos -= amount) < 0) { + bufpos += bufsize; + } } /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) + public SimpleCharStream(final java.io.Reader dstream, final int startline, + final int startcolumn, final int buffersize) { inputStream = dstream; line = startline; @@ -1165,21 +290,21 @@ public class SimpleCharStream } /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn) + public SimpleCharStream(final java.io.Reader dstream, final int startline, + final int startcolumn) { this(dstream, startline, startcolumn, 4096); } /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream) + public SimpleCharStream(final java.io.Reader dstream) { this(dstream, 1, 1, 4096); } /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) + public void ReInit(final java.io.Reader dstream, final int startline, + final int startcolumn, final int buffersize) { inputStream = dstream; line = startline; @@ -1198,112 +323,113 @@ public class SimpleCharStream } /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) + public void ReInit(final java.io.Reader dstream, final int startline, + final int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } /** Reinitialise. */ - public void ReInit(java.io.Reader dstream) + public void ReInit(final java.io.Reader dstream) { ReInit(dstream, 1, 1, 4096); } /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException + public SimpleCharStream(final java.io.InputStream dstream, final String encoding, final int startline, + final int startcolumn, final int buffersize) throws java.io.UnsupportedEncodingException { - this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + this(encoding == null ? new java.io.InputStreamReader(dstream, StandardCharsets.UTF_8) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) + public SimpleCharStream(final java.io.InputStream dstream, final int startline, + final int startcolumn, final int buffersize) { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + this(new java.io.InputStreamReader(dstream, StandardCharsets.UTF_8), startline, startcolumn, buffersize); } /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException + public SimpleCharStream(final java.io.InputStream dstream, final String encoding, final int startline, + final int startcolumn) throws java.io.UnsupportedEncodingException { this(dstream, encoding, startline, startcolumn, 4096); } /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn) + public SimpleCharStream(final java.io.InputStream dstream, final int startline, + final int startcolumn) { this(dstream, startline, startcolumn, 4096); } /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException + public SimpleCharStream(final java.io.InputStream dstream, final String encoding) throws java.io.UnsupportedEncodingException { this(dstream, encoding, 1, 1, 4096); } /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream) + public SimpleCharStream(final java.io.InputStream dstream) { this(dstream, 1, 1, 4096); } /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException + public void ReInit(final java.io.InputStream dstream, final String encoding, final int startline, + final int startcolumn, final int buffersize) throws java.io.UnsupportedEncodingException { - ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + ReInit(encoding == null ? new java.io.InputStreamReader(dstream, StandardCharsets.UTF_8) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) + public void ReInit(final java.io.InputStream dstream, final int startline, + final int startcolumn, final int buffersize) { - ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + ReInit(new java.io.InputStreamReader(dstream, StandardCharsets.UTF_8), startline, startcolumn, buffersize); } /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException + public void ReInit(final java.io.InputStream dstream, final String encoding) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, 1, 1, 4096); } /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream) + public void ReInit(final java.io.InputStream dstream) { ReInit(dstream, 1, 1, 4096); } /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException + public void ReInit(final java.io.InputStream dstream, final String encoding, final int startline, + final int startcolumn) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, startline, startcolumn, 4096); } /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn) + public void ReInit(final java.io.InputStream dstream, final int startline, + final int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } /** Get token literal value. */ public String GetImage() { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); + if (bufpos >= tokenBegin) { + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + } else { + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } } /** Get the suffix. */ - public char[] GetSuffix(int len) + public char[] GetSuffix(final int len) { - char[] ret = new char[len]; + final char[] ret = new char[len]; - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else + if ((bufpos + 1) >= len) { + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + } else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); @@ -1324,7 +450,7 @@ public class SimpleCharStream /** * Method to adjust line and column numbers for the start of a token. */ - public void adjustBeginLineColumn(int newLine, int newCol) + public void adjustBeginLineColumn(int newLine, final int newCol) { int start = tokenBegin; int len; @@ -1357,10 +483,11 @@ public class SimpleCharStream while (i++ < len) { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) { + bufline[j] = newLine++; + } else { + bufline[j] = newLine; + } } } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/extras/indexingExample/src/main/java/RyaDirectExample.java ---------------------------------------------------------------------- diff --git a/extras/indexingExample/src/main/java/RyaDirectExample.java b/extras/indexingExample/src/main/java/RyaDirectExample.java index d2aa1f6..eed1a22 100644 --- a/extras/indexingExample/src/main/java/RyaDirectExample.java +++ b/extras/indexingExample/src/main/java/RyaDirectExample.java @@ -18,20 +18,16 @@ */ import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; import java.util.List; -import java.util.Map; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Connector; -import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.TableExistsException; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.mock.MockInstance; import org.apache.accumulo.core.client.security.tokens.PasswordToken; -import org.apache.accumulo.core.data.Key; -import org.apache.accumulo.core.data.Value; -import org.apache.accumulo.core.security.Authorizations; import org.apache.commons.lang.Validate; import org.apache.hadoop.conf.Configuration; import org.apache.log4j.Logger; @@ -153,7 +149,7 @@ public class RyaDirectExample { private static Configuration getConf() { - + return AccumuloIndexingConfiguration.builder() .setUseMockAccumulo(USE_MOCK_INSTANCE) .setAuths(AUTHS) @@ -165,7 +161,7 @@ public class RyaDirectExample { .setUseAccumuloFreetextIndex(true) .setUseAccumuloTemporalIndex(true) .build(); - + } public static void testAddAndDelete(final SailRepositoryConnection conn) @@ -775,7 +771,7 @@ public class RyaDirectExample { final String tablename2 = RYA_TABLE_PREFIX + "INDEX_2"; final Connector accCon = new MockInstance(INSTANCE).getConnector( - "root", new PasswordToken("".getBytes())); + "root", new PasswordToken("".getBytes(StandardCharsets.UTF_8))); new PcjTables().createAndPopulatePcj(conn, accCon, tablename1, queryString1, new String[] { "e", "c", "l", "o" }, @@ -784,7 +780,7 @@ public class RyaDirectExample { new PcjTables().createAndPopulatePcj(conn, accCon, tablename2, queryString2, new String[] { "e", "c", "l", "o" }, Optional.<PcjVarOrderFactory> absent()); - + } catch (final RyaDAOException e) { throw new Error("While creating PCJ tables.",e); } finally {