Diff stringlengths 10 2k | Message stringlengths 28 159 |
|---|---|
throw new RuntimeException(e); | Define and throw a dedicated exception instead of using a generic one. |
import org.apache.accumulo.core.security.Credentials;
public MetaDataTableScanner(Instance instance, Credentials credentials, Range range, CurrentState state) {
this(instance, credentials, range, state, MetadataTable.NAME);
MetaDataTableScanner(Instance instance, Credentials credentials, Range range, CurrentState state, String tableName) {
Connector connector = instance.getConnector(credentials.getPrincipal(), credentials.getToken());
public MetaDataTableScanner(Instance instance, Credentials credentials, Range range) {
this(instance, credentials, range, MetadataTable.NAME);
public MetaDataTableScanner(Instance instance, Credentials credentials, Range range, String tableName) {
this(instance, credentials, range, null, tableName); | Immediately return this expression instead of assigning it to the temporary variable "onlineTabletsForTable". |
Connector connector = opts.getConnector();
connector.securityOperations().changeUserAuthorizations(opts.principal, AUTHS); | Remove this hard-coded password. |
/*
* 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.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
private HashMap<ColFamHashKey,K> objectsCF;
private HashMap<ColHashKey,K> objectsCol;
private ColHashKey lookupCol = new ColHashKey();
private ColFamHashKey lookupCF = new ColFamHashKey();
public ColumnToClassMapping() {
objectsCF = new HashMap<ColFamHashKey,K>();
objectsCol = new HashMap<ColHashKey,K>();
}
public ColumnToClassMapping(Map<String,String> objectStrings, Class<? extends K> c) throws InstantiationException, IllegalAccessException,
ClassNotFoundException {
this();
for (Entry<String,String> entry : objectStrings.entrySet()) {
String column = entry.getKey();
String className = entry.getValue();
PerColumnIteratorConfig pcic = PerColumnIteratorConfig.decodeColumns(column, className);
Class<? extends K> clazz = AccumuloClassLoader.loadClass(className, c);
if (pcic.getColumnQualifier() == null) {
addObject(pcic.getColumnFamily(), clazz.newInstance());
} else {
addObject(pcic.getColumnFamily(), pcic.getColumnQualifier(), clazz.newInstance());
}
}
protected void addObject(Text colf, K obj) {
objectsCF.put(new ColFamHashKey(new Text(colf)), obj);
}
protected void addObject(Text colf, Text colq, K obj) {
objectsCol.put(new ColHashKey(colf, colq), obj);
}
public K getObject(Key key) {
K obj = null;
// lookup column family and column qualifier
if (objectsCol.size() > 0) {
lookupCol.set(key);
obj = objectsCol.get(lookupCol);
if (obj != null) {
}
// lookup just column family
if (objectsCF.size() > 0) {
lookupCF.set(key);
obj = objectsCF.get(lookupCF);
return obj;
}
public boolean isEmpty() {
return objectsCol.size() == 0 && objectsCF.size() == 0;
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
@Override
public void visit(State state, Properties props) throws Exception {
Connector conn = SecurityHelper.getSystemConnector(state);
String tableName = SecurityHelper.getTableName(state);
boolean exists = SecurityHelper.getTableExists(state);
boolean hasPermission = false;
if (SecurityHelper.getSysPerm(state, SecurityHelper.getSysUserName(state), SystemPermission.CREATE_TABLE)) hasPermission = true;
try {
conn.tableOperations().create(tableName);
} catch (AccumuloSecurityException ae) {
if (ae.getErrorCode().equals(SecurityErrorCode.PERMISSION_DENIED)) {
if (hasPermission) throw new AccumuloException("Got a security exception when I should have had permission.", ae);
else
// create table anyway for sake of state
{
try {
state.getConnector().tableOperations().create(tableName);
SecurityHelper.setTableExists(state, true);
} catch (TableExistsException tee) {
if (exists) return;
else throw new AccumuloException("Test and Accumulo are out of sync");
}
return;
} else throw new AccumuloException("Got unexpected error", ae);
} catch (TableExistsException tee) {
if (!exists) throw new TableExistsException(null, tableName, "Got a TableExistsException but it shouldn't have existed", tee);
else return;
SecurityHelper.setTableExists(state, true);
for (TablePermission tp : TablePermission.values())
SecurityHelper.setTabPerm(state, conn.whoami(), tp, true);
if (!hasPermission) throw new AccumuloException("Didn't get Security Exception when we should have");
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
bw = getConnector().createBatchWriter("foo", new BatchWriterConfig()); | Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'. |
package org.apache.accumulo.core.client.mapreduce.lib.util; | Return empty string instead. |
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
| Replace all tab characters in this file by sequences of white-spaces. |
private static final PasswordToken TEST_PASS = new PasswordToken("test_password");
getConnector().securityOperations().createLocalUser(TEST_USER, TEST_PASS);
test_user_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
if (e.getErrorCode() != SecurityErrorCode.PERMISSION_DENIED || root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
test_user_conn.securityOperations().dropLocalUser(user);
if (e.getErrorCode() != SecurityErrorCode.PERMISSION_DENIED || !root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
test_user_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
if (!root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
test_user_conn.securityOperations().dropLocalUser(user);
if (root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
getConnector().securityOperations().createLocalUser(TEST_USER, TEST_PASS); | Remove the redundant '!unknownSymbol!' thrown exception declaration(s). |
assertEquals(0, shell.getExitCode());
exec("constraint --list -t t2", true, "VisibilityConstraint=2", true);
exec("constraint --list -t clone", true, "VisibilityConstraint=2", true);
exec("constraint -l -t c", true, "VisibilityConstraint=2", true);
exec("constraint -t c -d 2", true, "Removed constraint 2 from table c");
exec("constraint -l -t c", true, "VisibilityConstraint=2", false); | Add a default case to this switch. |
/*
* 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.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
* 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.
*/
@Override
public Long typedReduce(Key key, Iterator<Long> iter) {
long max = Long.MIN_VALUE;
while (iter.hasNext()) {
Long l = iter.next();
if (l > max) max = l;
}
return max;
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import java.util.Set; | Replace all tab characters in this file by sequences of white-spaces. |
package org.apache.accumulo.core.data;
import org.apache.hadoop.io.WritableComparator;
public abstract class ByteSequence implements Comparable<ByteSequence>{
public abstract byte byteAt(int i);
public abstract int length();
public abstract ByteSequence subSequence(int start, int end);
//may copy data
public abstract byte[] toArray();
public abstract boolean isBackedByArray();
public abstract byte[] getBackingArray();
public abstract int offset();
public static int compareBytes(ByteSequence bs1, ByteSequence bs2) {
int minLen = Math.min(bs1.length(), bs2.length());
for(int i = 0; i < minLen; i++){
int a = (bs1.byteAt(i) & 0xff);
int b = (bs2.byteAt(i) & 0xff);
if (a != b) {
return a - b;
}
}
return bs1.length() - bs2.length();
}
public int compareTo(ByteSequence obs) {
if(isBackedByArray() && obs.isBackedByArray()){
return WritableComparator.compareBytes(getBackingArray(), offset(), length(),
obs.getBackingArray(), obs.offset(), obs.length());
}
return compareBytes(this, obs);
}
@Override
public boolean equals(Object o){
if(o instanceof ByteSequence){
ByteSequence obs = (ByteSequence) o;
if(this == o)
return true;
if(length() != obs.length())
return false;
return compareTo(obs) == 0;
}
return false;
}
@Override
public int hashCode(){
int hash = 1;
if(isBackedByArray()){
byte[] data = getBackingArray();
int end = offset()+length();
for (int i = offset(); i < end; i++)
hash = (31 * hash) + data[i];
}else{
for (int i = 0; i < length(); i++)
hash = (31 * hash) + byteAt(i);
}
return hash;
}
} | Return empty string instead. |
import org.apache.accumulo.core.client.admin.ActiveCompaction;
/*
* (non-Javadoc)
*
* @see org.apache.accumulo.core.client.admin.InstanceOperations#getActiveCompactions(java.lang.String)
*/
@Override
public List<ActiveCompaction> getActiveCompactions(String tserver) throws AccumuloException, AccumuloSecurityException {
return new ArrayList<ActiveCompaction>();
}
/*
* (non-Javadoc)
*
* @see org.apache.accumulo.core.client.admin.InstanceOperations#ping(java.lang.String)
*/
@Override
public void ping(String tserver) throws AccumuloException {
// TODO Auto-generated method stub
} | Return empty string instead. |
/*
* 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.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
if (docSource.hasTop() && docKey.equals(docSource.getTopKey(), PartialKey.ROW_COLFAM_COLQUAL)) { | Replace all tab characters in this file by sequences of white-spaces. |
splits.add((r.nextLong() & 0x7fffffffffffffffl) % 1000000000000l); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.util.MapCounter; | Cast one of the operands of this multiplication operation to a "long". |
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.RootTable; | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/*
* 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.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
/*
* 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.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
import org.apache.accumulo.core.util.ContextFactory;
TaskAttemptContext context = ContextFactory.createTaskAttemptContext(job); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/*
* 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.accumulo.core.conf;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* An annotation to denote {@link AccumuloConfiguration} {@link Property} keys which are sensitive, and should be masked or hidden when printed.
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@interface Sensitive {
} | Make the "log" logger private static final and rename it to comply with the format "LOG(?:GER)?". |
public static String getBaseDir(final AccumuloConfiguration conf) {
public static String getTablesDir(final AccumuloConfiguration conf) {
public static String getRecoveryDir(final AccumuloConfiguration conf) {
public static Path getDataVersionLocation(final AccumuloConfiguration conf) {
public static String getMetadataTableDir(final AccumuloConfiguration conf) {
public static String getRootTabletDir(final AccumuloConfiguration conf) {
public static String getWalDirectory(final AccumuloConfiguration conf) { | Move this constructor to comply with Java Code Conventions. |
if (hasProblems)
MetadataTable.getMetadataTable(SecurityConstants.getSystemCredentials()).update(delMut); | Remove this call to "exit" or ensure it is really required. |
@SuppressWarnings("all") public class TabletClientService { | 13 duplicated blocks of code must be removed. |
/*
* 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.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
private Text tableId;
this.tableId = new Text(table);
scanState = new ScanState(credentials, tableId, authorizations, new Range(range), options.fetchedColumns, size, options.serverSideIteratorList, | Constructor has 9 parameters, which is greater than 7 authorized. |
public static final void strictlyPositive(final int i) {
if (i <= 0)
throw new IllegalArgumentException("integer should be > 0, was " + i);
} | Remove this unused method parameter "hasStart". |
import org.apache.accumulo.core.security.thrift.Credentials;
private Credentials credentials;
public TabletServerBatchReader(Instance instance, Credentials credentials, String table, Authorizations authorizations, int numQueryThreads) { | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
if (config.isJDWPEnabled()) { | Define a constant instead of duplicating this literal "superSecret" 3 times. |
if (hasTimestamp)
throw new IllegalStateException("Cannot set system timestamp when user set a timestamp"); | Remove this call to "exit" or ensure it is really required. |
/*
* 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.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken; | Move this constructor to comply with Java Code Conventions. |
package org.apache.accumulo.test.continuous; | Move the "org.apache.accumulo.test.randomwalk.unit.CreateTable" string literal on the left side of this string comparison. |
import org.apache.accumulo.server.cli.ClientOnDefaultTable;
import org.apache.accumulo.core.cli.BatchWriterOpts;
import org.apache.accumulo.core.cli.ScannerOpts;
import com.beust.jcommander.Parameter;
static class Opts extends ClientOnDefaultTable {
@Parameter(names={"-readonly", "--readonly"}, description="read only")
boolean readOnly = false;
@Parameter(names={"-count", "--count"}, description="count", required = true)
int count = 10000;
Opts() { super("mrtest1"); }
}
private static void readBack(Connector conn, Opts opts, ScannerOpts scanOpts) throws Exception {
Scanner scanner = conn.createScanner("mrtest1", opts.auths);
scanner.setBatchSize(scanOpts.scanBatchSize);
assert (opts.count == count);
String program = CreateTestTable.class.getName();
Opts opts = new Opts();
BatchWriterOpts bwOpts = new BatchWriterOpts();
ScannerOpts scanOpts = new ScannerOpts();
opts.parseArgs(program, args, bwOpts, scanOpts);
Connector connector = opts.getConnector();
if (!opts.readOnly) {
for (int i = 0; i < opts.count / 100; i++) {
connector.tableOperations().create(opts.getTableName());
connector.tableOperations().addSplits(opts.getTableName(), keys);
BatchWriter b = connector.createBatchWriter(opts.getTableName(), bwOpts.getBatchWriterConfig());
for (int i = 0; i < opts.count; i++) {
readBack(connector, opts, scanOpts);
opts.stopTracing(); | Remove this unused private "appendProp" method. |
@Deprecated
@Deprecated | 3 duplicated blocks of code must be removed. |
import org.apache.accumulo.core.file.rfile.RelativeKey.SkippR;
static final int RINDEX_VER_7 = 7;
// static final int RINDEX_VER_5 = 5; // unreleased
@Override
mba.writeInt(RINDEX_VER_7);
@Override
SkippR skippr = RelativeKey.fastSkip(currBlock, startKey, valbs, prevKey, getTopKey());
if (skippr.skipped > 0) {
entriesLeft -= skippr.skipped;
prevKey = skippr.prevKey;
rk = skippr.rk;
RelativeKey tmpRk = new RelativeKey();
tmpRk.setPrevKey(bie.getPrevKey());
prevKey = new Key(bie.getPrevKey());
SkippR skippr = RelativeKey.fastSkip(currBlock, startKey, valbs, prevKey, currKey);
prevKey = skippr.prevKey;
entriesLeft -= skippr.skipped;
rk = skippr.rk;
if (ver != RINDEX_VER_7 && ver != RINDEX_VER_6 && ver != RINDEX_VER_4 && ver != RINDEX_VER_3) | Use "Character.toString" instead. |
if (slave.length() > 0 && slave.indexOf("#") < 0)
result.add(slave); | Remove this call to "exit" or ensure it is really required. |
@SuppressWarnings("all") public class RecoveryException extends Exception implements org.apache.thrift.TBase<RecoveryException, RecoveryException._Fields>, java.io.Serializable, Cloneable { | 13 duplicated blocks of code must be removed. |
/*
* 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.
*/ | Replace all tab characters in this file by sequences of white-spaces. |
if (parts.length > 2) { | Refactor this code to not nest more than 3 if/for/while/switch/try statements. |
import java.lang.RuntimeException; | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
private Option verboseOpt, forceOpt, sizeOpt, allOpt;
boolean all = false;
if (cl.hasOption(allOpt.getOpt())) {
force = true;
}
if (startRow == null && endRow == null && size < 0 && all) {
allOpt = new Option("", "all", false, "allow an entire table to be merged into one tablet without prompting the user for confirmation");
o.addOption(allOpt); | Either log or rethrow this exception. |
final String[] args = new String[] {"--fake", "-u", "root", "-p", ""}; | Remove this call to "exit" or ensure it is really required. |
private RowIterator decisionIterator;
private static class RowIterator extends WrappingIterator {
private Range rowRange;
private boolean hasTop;
RowIterator(SortedKeyValueIterator<Key,Value> source) {
super.setSource(source);
}
void setRow(Range row) {
this.rowRange = row;
}
@Override
public boolean hasTop() {
return hasTop && super.hasTop();
}
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
range = rowRange.clip(range, true);
if (range == null) {
hasTop = false;
} else {
hasTop = true;
super.seek(range, columnFamilies, inclusive);
}
}
}
Range rowRange = new Range(row);
decisionIterator.setRow(rowRange);
decisionIterator.seek(rowRange, columnFamilies, inclusive);
* - An iterator over the row. This iterator is confined to the row. Seeking past the end of the row will return no data. Seeking before the row will
* always set top to the first column in the current row. By default this iterator will only see the columns the parent was seeked with. To see more
* columns reseek this iterator with those columns.
this.decisionIterator = new RowIterator(source.deepCopy(env)); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
if (ts.getLastCommitTime() > 0)
idleTime = ct - ts.getLastCommitTime();
else
idleTime = ct - zerotime;
if (!mincIdleThresholds.containsKey(tableId))
mincIdleThresholds.put(tableId, ServerConfiguration.getTableConfiguration(tableId.toString()).getTimeInMillis(Property.TABLE_MINC_COMPACT_IDLETIME));
if (mcmts > 0)
numWaitingMincs++; | Remove this call to "exit" or ensure it is really required. |
RangeFilter(SortedKeyValueIterator<Key,Value> i, Range range) {
setSource(i); | Remove the literal "true" boolean value. |
* 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.
*/
void send(AuthInfo info, String serverName, MasterClientService.Iface client) throws TException, ThriftSecurityException;
| Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
package org.apache.accumulo.server.tabletserver;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.accumulo.core.data.Key;
class MemKey extends Key {
int mutationCount;
public MemKey(byte[] row, byte[] cf, byte[] cq, byte[] cv, long ts, boolean del, boolean copy, int mc) {
super(row, cf, cq, cv, ts, del, copy);
this.mutationCount = mc;
}
public MemKey() {
super();
this.mutationCount = Integer.MAX_VALUE;
}
public MemKey(Key key, int mc) {
super(key);
this.mutationCount = mc;
}
public String toString(){
return super.toString()+" mc="+mutationCount;
}
@Override
public Object clone() throws CloneNotSupportedException{
return super.clone();
}
@Override
public void write(DataOutput out) throws IOException{
super.write(out);
out.writeInt(mutationCount);
}
@Override
public void readFields(DataInput in) throws IOException{
super.readFields(in);
mutationCount = in.readInt();
}
@Override
public int compareTo(Key k){
int cmp = super.compareTo(k);
if(cmp == 0 && k instanceof MemKey){
cmp = ((MemKey)k).mutationCount - mutationCount;
}
return cmp;
}
} | Return empty string instead. |
public static final String SERVICE_SEPARATOR = ";";
public static final String SEPARATOR_CHAR = "="; | Make this member "protected". |
@Override
public void unableToMonitorLockNode(Throwable e) {
// TODO Auto-generated method stub
}
} | Remove this call to "exit" or ensure it is really required. |
import org.apache.accumulo.core.client.BatchWriterConfig;
BatchWriter bw = getConnector().createBatchWriter("foo", new BatchWriterConfig()); | Remove this unused method parameter "e". |
* @deprecated since 1.4, replaced by {@link org.apache.accumulo.core.iterators.user.IndexedDocIterator} | Either log or rethrow this exception. |
package org.apache.accumulo.examples.wikisearch.sample; | Rename "table" which hides the field declared at line 107. |
@Override
public boolean hasNext() {
return false;
}
@Override
public Entry<Key,Value> next() {
return null;
}
@Override
public void remove() {} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
constraintChecker.set(new ConstraintChecker(getTableConfiguration()));
public void checkConstraints() {
ConstraintChecker cc = constraintChecker.get();
if (cc.classLoaderChanged()) {
ConstraintChecker ncc = new ConstraintChecker(getTableConfiguration());
constraintChecker.compareAndSet(cc, ncc);
}
}
| Return empty string instead. |
return Long.toString(Ingest.encoder.decode(colf.getBytes())) + ":"; | Either log or rethrow this exception. |
package org.apache.accumulo.server.test.randomwalk.multitable;
import java.util.ArrayList;
import java.util.Properties;
import java.util.Random;
import org.apache.accumulo.server.test.randomwalk.State;
import org.apache.accumulo.server.test.randomwalk.Test;
public class OfflineTable extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
@SuppressWarnings("unchecked")
ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
if (tables.size() <= 0) {
return;
}
Random rand = new Random();
String tableName = tables.get(rand.nextInt(tables.size()));
state.getConnector().tableOperations().offline(tableName);
log.debug("Table "+tableName+" offline ");
state.getConnector().tableOperations().online(tableName);
log.debug("Table "+tableName+" online ");
}
} | Return empty string instead. |
import org.apache.accumulo.core.security.thrift.Credentials;
private final Credentials credentials;
public TabletServerBatchReaderIterator(Instance instance, Credentials credentials, String table, Authorizations authorizations, ArrayList<Range> ranges,
ResultReceiver receiver, List<Column> columns, Credentials credentials, ScannerOptions options, Authorizations authorizations, AccumuloConfiguration conf)
ResultReceiver receiver, List<Column> columns, Credentials credentials, ScannerOptions options, Authorizations authorizations, AccumuloConfiguration conf,
InitialMultiScan imsr = client.startMultiScan(Tracer.traceInfo(), credentials, thriftTabletRanges, Translator.translate(columns, Translator.CT), | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.util.PeekingIterator;
PeekingIterator<Entry<Key, Value>> row = new PeekingIterator<Entry<Key,Value>>(iter.next());
Entry<Key,Value> kv = null;
if (row.hasNext()) kv = row.peek();
while (row.hasNext()) {
Entry<Key, Value> currentKV = row.next();
if (!kv.getValue().equals(currentKV.getValue()))
throw new Exception("values not equal "+kv+" "+currentKV);
} | Either log or rethrow this exception. |
DeleteIT.deleteTest(c, cluster); | Define and throw a dedicated exception instead of using a generic one. |
if (task.size() == 0)
return null;
if (task.size() == 0)
return null;
if (task.size() == 0)
return null; | Remove this call to "exit" or ensure it is really required. |
public final void printHelp(int width) {
Shell.printHelp(usage(), "description: " + this.description(), getOptionsWithHelp(), width);
}
printHelp(usage, description, opts, Integer.MAX_VALUE);
}
private static final void printHelp(String usage, String description, Options opts, int width) {
new HelpFormatter().printHelp(pw, width, usage, description, opts, 2, 5, null, true);
| Refactor this code to not nest more than 3 if/for/while/switch/try statements. |
import org.apache.accumulo.core.security.tokens.PasswordToken; | Replace all tab characters in this file by sequences of white-spaces. |
vfs = AccumuloVFSClassLoader.generateVfs(); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
protected TermSource[] sources; | Move this variable to comply with Java Code Conventions. |
package org.apache.accumulo.server.fate;
public class StackOverflowException extends Exception {
public StackOverflowException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
} | Return empty string instead. |
org.apache.thrift.protocol.TList _list31 = iprot.readListBegin();
this.newTablets = new ArrayList<org.apache.accumulo.core.data.thrift.TKeyExtent>(_list31.size);
for (int _i32 = 0; _i32 < _list31.size; ++_i32)
org.apache.accumulo.core.data.thrift.TKeyExtent _elem33;
_elem33 = new org.apache.accumulo.core.data.thrift.TKeyExtent();
_elem33.read(iprot);
this.newTablets.add(_elem33);
for (org.apache.accumulo.core.data.thrift.TKeyExtent _iter34 : this.newTablets)
_iter34.write(oprot); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
Connector connector = instance.getConnector(new UserPassToken(userpass.getUsername(), userpass.bufferForPassword()));
return getConnector(userpass).securityOperations().authenticateUser(new UserPassToken(user, password.array()));
getConnector(userpass).securityOperations().changeUserPassword(new UserPassToken(user, password.array())); | This block of commented-out lines of code should be removed. |
import org.apache.accumulo.core.security.tokens.InstanceTokenWrapper;
public MultiTableBatchWriterImpl(Instance instance, InstanceTokenWrapper credentials, BatchWriterConfig config) { | Immediately return this expression instead of assigning it to the temporary variable "ret". |
SimpleTimer.getInstance().schedule(new Runnable() { | Either log or rethrow this exception. |
import org.apache.accumulo.core.security.tokens.InstanceTokenWrapper;
import org.apache.accumulo.core.security.tokens.UserPassToken;
InstanceTokenWrapper auth;
WalkingSecurity.get(state).changePassword(new UserPassToken(target, newPass)); | Immediately return this expression instead of assigning it to the temporary variable "ret". |
Map<String,String> map;
MockConfiguration(Map<String,String> settings) {
map = settings;
}
public void put(String k, String v) {
map.put(k, v);
}
@Override
public String get(Property property) {
return map.get(property.getKey());
}
@Override
public Iterator<Entry<String,String>> iterator() {
return map.entrySet().iterator();
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
private static double totalScanRate = 0.0;
private static List<Pair<Long,Integer>> scanRateOverTime = Collections.synchronizedList(new MaxList<Integer>(MAX_TIME_PERIOD));
total.scanRate += more.scanRate;
double totalScanRate = 0.;
totalScanRate += summary.scanRate;
Monitor.totalScanRate = totalScanRate;
scanRateOverTime.add(new Pair<Long,Integer>(currentTime, (int) totalScanRate));
public static double getTotalScanRate() {
return totalScanRate;
}
public static List<Pair<Long,Integer>> getScanRateOverTime() {
synchronized (scanRateOverTime) {
return new ArrayList<Pair<Long,Integer>>(scanRateOverTime);
}
}
| Use isEmpty() to check whether the collection is empty or not. |
* A convenience method to set the "all columns" option on a Combiner.
* @param combineAllColumns
* if true, the columns option is ignored and the Combiner will be applied to all columns | 1 duplicated blocks of code must be removed. |
synchronized (tch) {
while (!tch.halted) { | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
public void initialize(String instanceId, boolean initialize) {
// prep parent node of users with root username
if (!zoo.exists(ZKUserPath))
zoo.putPersistentData(ZKUserPath, rootuser.getBytes(), NodeExistsPolicy.FAIL);
| Remove this call to "exit" or ensure it is really required. |
* 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.
*/
@Override
public void visit(State state, Properties props) throws Exception {
Connector conn = state.getConnector();
Random rand = (Random) state.get("rand");
@SuppressWarnings("unchecked")
List<String> tableNames = (List<String>) state.get("tables");
String tableName = tableNames.get(rand.nextInt(tableNames.size()));
// TODO need to sometimes do null start and end ranges
TreeSet<Text> range = new TreeSet<Text>();
range.add(new Text(String.format("%016x", Math.abs(rand.nextLong()))));
range.add(new Text(String.format("%016x", Math.abs(rand.nextLong()))));
try {
conn.tableOperations().merge(tableName, range.first(), range.last());
log.debug("merged " + tableName);
} catch (TableOfflineException toe) {
log.debug("merge " + tableName + " failed, table is not online");
} catch (TableNotFoundException tne) {
log.debug("merge " + tableName + " failed, doesnt exist");
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
new DistributedWorkQueue(ZooUtil.getRoot(master.getInstance()) + Constants.ZRECOVERY).addWork(file, source.getBytes()); | Remove this unused method parameter "ex". |
@Override
public void unableToMonitorLockNode(Throwable e) {
// TODO Auto-generated method stub
}
| Remove this call to "exit" or ensure it is really required. |
/**
* @deprecated since 1.4
* @use org.apache.accumulo.core.iterators.user.AgeOffFilter
**/ | Remove this unused private "match" method. |
import org.apache.accumulo.core.iterators.user.RegExFilter;
IteratorSetting si = new IteratorSetting(prio, name, RegExFilter.class);
RegExFilter.setRegexs(si, term, term, term, term, true); | Remove this unused private "match" method. |
import org.apache.accumulo.core.security.Credentials;
public void visit(State state, Properties props) throws Exception {
boolean hasPermission = WalkingSecurity.get(state).canChangeAuthorizations(new Credentials(authPrincipal, authToken).toThrift(state.getInstance()), target); | Remove this hard-coded password. |
/*
* 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.accumulo.wikisearch.sample;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlAccessorType(XmlAccessType.FIELD)
public class Document {
@XmlElement
private String id = null;
@XmlElement
private List<Field> field = new ArrayList<Field>();
public Document() {
super();
}
public Document(String id, List<Field> fields) {
super();
this.id = id;
this.field = fields;
}
public String getId() {
return id;
}
public List<Field> getFields() {
return field;
}
public void setId(String id) {
this.id = id;
}
public void setFields(List<Field> fields) {
this.field = fields;
}
} | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
/*
* 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.
*/
String _val3; // optional
String _val9; // optional | Remove this unused private "appendProp" method. |
/**
* This class remains here for backwards compatibility.
* @deprecated since 1.4
* @see org.apache.accumulo.core.iterators.user.RowDeletingIterator
public class RowDeletingIterator extends org.apache.accumulo.core.iterators.user.RowDeletingIterator { | Remove the literal "false" boolean value. |
if (id == null)
return "No trace id specified";
if (hasData)
sb.append("<td><input type='checkbox' onclick='toggle(\"" + Long.toHexString(node.spanId) + "\")'></td>\n");
else
sb.append("<td></td>\n"); | Remove this call to "exit" or ensure it is really required. |
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken; | Move this constructor to comply with Java Code Conventions. |
org.apache.accumulo.core.security.crypto.CryptoModule cryptoOps = org.apache.accumulo.core.security.crypto.CryptoModuleFactory
.getCryptoModule(cryptoModuleName);
private final Instance instance; | Extract the assignment out of this expression. |
import org.apache.accumulo.core.client.BatchWriterConfig;
private BatchWriterConfig bwConfig;
public TabletServerBatchDeleter(Instance instance, AuthInfo credentials, String tableId, Authorizations authorizations, int numQueryThreads,
BatchWriterConfig bwConfig) throws TableNotFoundException {
this.bwConfig = bwConfig;
bw = new BatchWriterImpl(instance, credentials, tableId, bwConfig); | Remove this unused method parameter "e". |
import java.nio.charset.Charset;
private static final Charset utf8 = Charset.forName("UTF8");
return Base64.decodeBase64(conf.get(PASSWORD, "").getBytes(utf8));
return authString == null ? Constants.NO_AUTHS : new Authorizations(authString.getBytes(utf8));
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(rangeString.getBytes(utf8)));
Text cf = new Text(idx < 0 ? Base64.decodeBase64(col.getBytes(utf8)) : Base64.decodeBase64(col.substring(0, idx).getBytes(utf8)));
Text cq = idx < 0 ? null : new Text(Base64.decodeBase64(col.substring(idx + 1).getBytes(utf8)));
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(itstring.getBytes(utf8))); | Move this variable to comply with Java Code Conventions. |
public boolean canImport(InstanceTokenWrapper credentials) throws ThriftSecurityException { | This block of commented-out lines of code should be removed. |
conn = new ZooKeeperInstance(instanceName, zookeepers).getConnector(user, password.getBytes()); | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.schema.MetadataSchema;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily;
@Parameter(names = "--fix")
metadata.setRange(MetadataSchema.TabletsSection.getRange());
metadata.fetchColumnFamily(DataFileColumnFamily.NAME);
BatchWriter writer = null; | Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. |
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken; | 1 duplicated blocks of code must be removed. |
if (state.getConnector().tableOperations().exists(table)) {
log.debug("Setting " + property.getKey() + " on " + table + " back to " + property.getDefaultValue());
state.getConnector().tableOperations().setProperty(table, property.getKey(), property.getDefaultValue());
}
state.getMap().put(LAST_TABLE_SETTING, table + "," + choice);
state.getConnector().tableOperations().setProperty(table, setting.property.getKey(), "" + newValue); | Use "Long.toString" instead. |
return "Master Server" + (masters.size() == 0 ? "" : ":" + AddressUtil.parseAddress(masters.get(0)).getHostText());
row.add(masters.size() == 0 ? "<div class='error'>Down</div>" : AddressUtil.parseAddress(masters.get(0)).getHostText());
row.add(AddressUtil.parseAddress(server.name).getHostText()); | Remove this unused method parameter "threadName". |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.