HADOOP-1148. More indentation and spacing fixes.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@530556 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doug Cutting 2007-04-19 21:34:41 +00:00
parent 4a8d243f4e
commit 114d67c614
17 changed files with 402 additions and 402 deletions

View File

@ -60,17 +60,17 @@ public abstract class HAbstractScanner implements HScannerInterface {
String column = col.toString();
try {
int colpos = column.indexOf(":") + 1;
if(colpos == 0) {
if (colpos == 0) {
throw new IllegalArgumentException("Column name has no family indicator.");
}
String columnkey = column.substring(colpos);
if(columnkey == null || columnkey.length() == 0) {
if (columnkey == null || columnkey.length() == 0) {
this.matchType = MATCH_TYPE.FAMILY_ONLY;
this.family = column.substring(0, colpos);
} else if(isRegexPattern.matcher(columnkey).matches()) {
} else if (isRegexPattern.matcher(columnkey).matches()) {
this.matchType = MATCH_TYPE.REGEX;
this.columnMatcher = Pattern.compile(column);
@ -86,13 +86,13 @@ public abstract class HAbstractScanner implements HScannerInterface {
// Matching method
boolean matches(Text col) throws IOException {
if(this.matchType == MATCH_TYPE.SIMPLE) {
if (this.matchType == MATCH_TYPE.SIMPLE) {
return col.equals(this.col);
} else if(this.matchType == MATCH_TYPE.FAMILY_ONLY) {
} else if (this.matchType == MATCH_TYPE.FAMILY_ONLY) {
return col.toString().startsWith(this.family);
} else if(this.matchType == MATCH_TYPE.REGEX) {
} else if (this.matchType == MATCH_TYPE.REGEX) {
return this.columnMatcher.matcher(col.toString()).matches();
} else {
@ -121,7 +121,7 @@ public abstract class HAbstractScanner implements HScannerInterface {
for(int i = 0; i < targetCols.length; i++) {
Text family = HStoreKey.extractFamily(targetCols[i]);
Vector<ColumnMatcher> matchers = okCols.get(family);
if(matchers == null) {
if (matchers == null) {
matchers = new Vector<ColumnMatcher>();
}
matchers.add(new ColumnMatcher(targetCols[i]));
@ -144,11 +144,11 @@ public abstract class HAbstractScanner implements HScannerInterface {
Text column = keys[i].getColumn();
Text family = HStoreKey.extractFamily(column);
Vector<ColumnMatcher> matchers = okCols.get(family);
if(matchers == null) {
if (matchers == null) {
return false;
}
for(int m = 0; m < matchers.size(); m++) {
if(matchers.get(m).matches(column)) {
if (matchers.get(m).matches(column)) {
return true;
}
}
@ -203,7 +203,7 @@ public abstract class HAbstractScanner implements HScannerInterface {
// Grab all the values that match this row/timestamp
boolean insertedItem = false;
if(chosenRow != null) {
if (chosenRow != null) {
key.setRow(chosenRow);
key.setVersion(chosenTimestamp);
key.setColumn(new Text(""));
@ -215,7 +215,7 @@ public abstract class HAbstractScanner implements HScannerInterface {
&& (keys[i].getRow().compareTo(chosenRow) == 0)
&& (keys[i].getTimestamp() == chosenTimestamp)) {
if(columnMatch(i)) {
if (columnMatch(i)) {
outbuf.reset();
vals[i].write(outbuf);
byte byteresults[] = outbuf.getData();
@ -226,7 +226,7 @@ public abstract class HAbstractScanner implements HScannerInterface {
insertedItem = true;
}
if (! getNext(i)) {
if (!getNext(i)) {
closeSubScanner(i);
}
}
@ -237,7 +237,7 @@ public abstract class HAbstractScanner implements HScannerInterface {
while((keys[i] != null)
&& ((keys[i].getRow().compareTo(chosenRow) <= 0)
|| (keys[i].getTimestamp() > this.timestamp)
|| (! columnMatch(i)))) {
|| (!columnMatch(i)))) {
getNext(i);
}

View File

@ -95,12 +95,12 @@ public class HClient extends HGlobals implements HConstants {
}
public synchronized void openTable(Text tableName) throws IOException {
if(closed) {
if (closed) {
throw new IllegalStateException("client is not open");
}
tableServers = tablesToServers.get(tableName);
if(tableServers == null ) { // We don't know where the table is
if (tableServers == null) { // We don't know where the table is
findTableInMeta(tableName); // Load the information from meta
}
}
@ -108,9 +108,9 @@ public class HClient extends HGlobals implements HConstants {
private void findTableInMeta(Text tableName) throws IOException {
TreeMap<Text, TableInfo> metaServers = tablesToServers.get(META_TABLE_NAME);
if(metaServers == null) { // Don't know where the meta is
if (metaServers == null) { // Don't know where the meta is
loadMetaFromRoot(tableName);
if(tableName.equals(META_TABLE_NAME) || tableName.equals(ROOT_TABLE_NAME)) {
if (tableName.equals(META_TABLE_NAME) || tableName.equals(ROOT_TABLE_NAME)) {
// All we really wanted was the meta or root table
return;
}
@ -119,7 +119,7 @@ public class HClient extends HGlobals implements HConstants {
tableServers = new TreeMap<Text, TableInfo>();
for(Iterator<TableInfo> i = metaServers.tailMap(tableName).values().iterator();
i.hasNext(); ) {
i.hasNext();) {
TableInfo t = i.next();
@ -133,7 +133,7 @@ public class HClient extends HGlobals implements HConstants {
*/
private void loadMetaFromRoot(Text tableName) throws IOException {
locateRootRegion();
if(tableName.equals(ROOT_TABLE_NAME)) { // All we really wanted was the root
if (tableName.equals(ROOT_TABLE_NAME)) { // All we really wanted was the root
return;
}
scanRoot();
@ -144,7 +144,7 @@ public class HClient extends HGlobals implements HConstants {
* could be.
*/
private void locateRootRegion() throws IOException {
if(master == null) {
if (master == null) {
master = (HMasterInterface)RPC.getProxy(HMasterInterface.class,
HMasterInterface.versionID,
masterLocation.getInetSocketAddress(), conf);
@ -157,7 +157,7 @@ public class HClient extends HGlobals implements HConstants {
while(rootRegionLocation == null && localTimeouts < numTimeouts) {
rootRegionLocation = master.findRootRegion();
if(rootRegionLocation == null) {
if (rootRegionLocation == null) {
try {
Thread.sleep(clientTimeout);
@ -166,7 +166,7 @@ public class HClient extends HGlobals implements HConstants {
localTimeouts++;
}
}
if(rootRegionLocation == null) {
if (rootRegionLocation == null) {
throw new IOException("Timed out trying to locate root region");
}
@ -174,7 +174,7 @@ public class HClient extends HGlobals implements HConstants {
HRegionInterface rootRegion = getHRegionConnection(rootRegionLocation);
if(rootRegion.getRegionInfo(rootRegionInfo.regionName) != null) {
if (rootRegion.getRegionInfo(rootRegionInfo.regionName) != null) {
tableServers = new TreeMap<Text, TableInfo>();
tableServers.put(startRow, new TableInfo(rootRegionInfo, rootRegionLocation));
tablesToServers.put(ROOT_TABLE_NAME, tableServers);
@ -184,7 +184,7 @@ public class HClient extends HGlobals implements HConstants {
} while(rootRegionLocation == null && tries++ < numRetries);
if(rootRegionLocation == null) {
if (rootRegionLocation == null) {
closed = true;
throw new IOException("unable to locate root region server");
}
@ -220,7 +220,7 @@ public class HClient extends HGlobals implements HConstants {
HRegionInfo regionInfo = new HRegionInfo();
regionInfo.readFields(inbuf);
if(! regionInfo.tableDesc.getName().equals(tableName)) {
if (!regionInfo.tableDesc.getName().equals(tableName)) {
// We're done
break;
}
@ -245,7 +245,7 @@ public class HClient extends HGlobals implements HConstants {
HRegionInterface server = servers.get(regionServer.toString());
if(server == null) { // Get a connection
if (server == null) { // Get a connection
server = (HRegionInterface)RPC.waitForProxy(HRegionInterface.class,
HRegionInterface.versionID, regionServer.getInetSocketAddress(), conf);
@ -257,7 +257,7 @@ public class HClient extends HGlobals implements HConstants {
/** Close the connection to the HRegionServer */
public synchronized void close() throws IOException {
if(! closed) {
if (!closed) {
RPC.stopClient();
closed = true;
}
@ -274,13 +274,13 @@ public class HClient extends HGlobals implements HConstants {
TreeSet<HTableDescriptor> uniqueTables = new TreeSet<HTableDescriptor>();
TreeMap<Text, TableInfo> metaTables = tablesToServers.get(META_TABLE_NAME);
if(metaTables == null) {
if (metaTables == null) {
// Meta is not loaded yet so go do that
loadMetaFromRoot(META_TABLE_NAME);
metaTables = tablesToServers.get(META_TABLE_NAME);
}
for(Iterator<TableInfo>i = metaTables.values().iterator(); i.hasNext(); ) {
for(Iterator<TableInfo>i = metaTables.values().iterator(); i.hasNext();) {
TableInfo t = i.next();
HRegionInterface server = getHRegionConnection(t.serverAddress);
HScannerInterface scanner = null;
@ -297,7 +297,7 @@ public class HClient extends HGlobals implements HConstants {
// Only examine the rows where the startKey is zero length
if(info.startKey.getLength() == 0) {
if (info.startKey.getLength() == 0) {
uniqueTables.add(info.tableDesc);
}
results.clear();
@ -311,7 +311,7 @@ public class HClient extends HGlobals implements HConstants {
}
private TableInfo getTableInfo(Text row) {
if(tableServers == null) {
if (tableServers == null) {
throw new IllegalStateException("Must open table first");
}
@ -335,7 +335,7 @@ public class HClient extends HGlobals implements HConstants {
info.regionInfo.regionName, row, column, numVersions);
ArrayList<byte[]> bytes = new ArrayList<byte[]>();
for(int i = 0 ; i < values.length; i++) {
for(int i = 0; i < values.length; i++) {
bytes.add(values[i].get());
}
return bytes.toArray(new byte[values.length][]);
@ -351,7 +351,7 @@ public class HClient extends HGlobals implements HConstants {
info.regionInfo.regionName, row, column, timestamp, numVersions);
ArrayList<byte[]> bytes = new ArrayList<byte[]>();
for(int i = 0 ; i < values.length; i++) {
for(int i = 0; i < values.length; i++) {
bytes.add(values[i].get());
}
return bytes.toArray(new byte[values.length][]);
@ -369,7 +369,7 @@ public class HClient extends HGlobals implements HConstants {
* Return the specified columns.
*/
public HScannerInterface obtainScanner(Text[] columns, Text startRow) throws IOException {
if(tableServers == null) {
if (tableServers == null) {
throw new IllegalStateException("Must open table first");
}
return new ClientScanner(columns, startRow);
@ -481,11 +481,11 @@ public class HClient extends HGlobals implements HConstants {
* Returns false if there are no more scanners.
*/
private boolean nextScanner() throws IOException {
if(scanner != null) {
if (scanner != null) {
scanner.close();
}
currentRegion += 1;
if(currentRegion == regions.length) {
if (currentRegion == regions.length) {
close();
return false;
}
@ -505,13 +505,13 @@ public class HClient extends HGlobals implements HConstants {
* @see org.apache.hadoop.hbase.HScannerInterface#next(org.apache.hadoop.hbase.HStoreKey, java.util.TreeMap)
*/
public boolean next(HStoreKey key, TreeMap<Text, byte[]> results) throws IOException {
if(closed) {
if (closed) {
return false;
}
boolean status = scanner.next(key, results);
if(! status) {
if (!status) {
status = nextScanner();
if(status) {
if (status) {
status = scanner.next(key, results);
}
}
@ -522,7 +522,7 @@ public class HClient extends HGlobals implements HConstants {
* @see org.apache.hadoop.hbase.HScannerInterface#close()
*/
public void close() throws IOException {
if(scanner != null) {
if (scanner != null) {
scanner.close();
}
server = null;

View File

@ -101,12 +101,12 @@ public class HLog {
newlog.close();
}
if(fs.exists(srcDir)) {
if (fs.exists(srcDir)) {
if(! fs.delete(srcDir)) {
if (!fs.delete(srcDir)) {
LOG.error("Cannot delete: " + srcDir);
if(! FileUtil.fullyDelete(new File(srcDir.toString()))) {
if (!FileUtil.fullyDelete(new File(srcDir.toString()))) {
throw new IOException("Cannot delete: " + srcDir);
}
}
@ -127,7 +127,7 @@ public class HLog {
this.conf = conf;
this.logSeqNum = 0;
if(fs.exists(dir)) {
if (fs.exists(dir)) {
throw new IOException("Target HLog directory already exists: " + dir);
}
fs.mkdirs(dir);
@ -154,7 +154,7 @@ public class HLog {
Vector<Path> toDeleteList = new Vector<Path>();
synchronized(this) {
if(closed) {
if (closed) {
throw new IOException("Cannot roll log; log is closed");
}
@ -174,10 +174,10 @@ public class HLog {
// Close the current writer (if any), and grab a new one.
if(writer != null) {
if (writer != null) {
writer.close();
if(filenum > 0) {
if (filenum > 0) {
outputfiles.put(logSeqNum-1, computeFilename(filenum-1));
}
}
@ -192,10 +192,10 @@ public class HLog {
// over all the regions.
long oldestOutstandingSeqNum = Long.MAX_VALUE;
for(Iterator<Long> it = regionToLastFlush.values().iterator(); it.hasNext(); ) {
for(Iterator<Long> it = regionToLastFlush.values().iterator(); it.hasNext();) {
long curSeqNum = it.next().longValue();
if(curSeqNum < oldestOutstandingSeqNum) {
if (curSeqNum < oldestOutstandingSeqNum) {
oldestOutstandingSeqNum = curSeqNum;
}
}
@ -205,10 +205,10 @@ public class HLog {
LOG.debug("removing old log files");
for(Iterator<Long> it = outputfiles.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Long> it = outputfiles.keySet().iterator(); it.hasNext();) {
long maxSeqNum = it.next().longValue();
if(maxSeqNum < oldestOutstandingSeqNum) {
if (maxSeqNum < oldestOutstandingSeqNum) {
Path p = outputfiles.get(maxSeqNum);
it.remove();
toDeleteList.add(p);
@ -221,7 +221,7 @@ public class HLog {
// Actually delete them, if any!
for(Iterator<Path> it = toDeleteList.iterator(); it.hasNext(); ) {
for(Iterator<Path> it = toDeleteList.iterator(); it.hasNext();) {
Path p = it.next();
fs.delete(p);
}
@ -262,7 +262,7 @@ public class HLog {
* We need to seize a lock on the writer so that writes are atomic.
*/
public synchronized void append(Text regionName, Text tableName, Text row, TreeMap<Text, byte[]> columns, long timestamp) throws IOException {
if(closed) {
if (closed) {
throw new IOException("Cannot append; log is closed");
}
@ -273,12 +273,12 @@ public class HLog {
// that don't have any flush yet, the relevant operation is the
// first one that's been added.
if(regionToLastFlush.get(regionName) == null) {
if (regionToLastFlush.get(regionName) == null) {
regionToLastFlush.put(regionName, seqNum[0]);
}
int counter = 0;
for(Iterator<Text> it = columns.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = columns.keySet().iterator(); it.hasNext();) {
Text column = it.next();
byte[] val = columns.get(column);
HLogKey logKey = new HLogKey(regionName, tableName, row, seqNum[counter++]);
@ -333,11 +333,11 @@ public class HLog {
/** Complete the cache flush */
public synchronized void completeCacheFlush(Text regionName, Text tableName, long logSeqId) throws IOException {
if(closed) {
if (closed) {
return;
}
if(! insideCacheFlush) {
if (!insideCacheFlush) {
throw new IOException("Impossible situation: inside completeCacheFlush(), but 'insideCacheFlush' flag is false");
}

View File

@ -80,10 +80,10 @@ public class HLogKey implements WritableComparable {
HLogKey other = (HLogKey) o;
int result = this.regionName.compareTo(other.regionName);
if(result == 0) {
if (result == 0) {
result = this.row.compareTo(other.row);
if(result == 0) {
if (result == 0) {
if (this.logSeqNum < other.logSeqNum) {
result = -1;

View File

@ -108,7 +108,7 @@ public class HMaster extends HGlobals
};
Text firstRow = new Text();
while((! closed)) {
while((!closed)) {
int metaRegions = 0;
while(rootRegionLocation == null) {
try {
@ -155,8 +155,8 @@ public class HMaster extends HGlobals
HServerInfo storedInfo = null;
synchronized(serversToServerInfo) {
storedInfo = serversToServerInfo.get(serverName);
if(storedInfo == null
|| storedInfo.getStartCode() != startCode) {
if (storedInfo == null
|| storedInfo.getStartCode() != startCode) {
// The current assignment is no good; load the region.
@ -261,8 +261,8 @@ public class HMaster extends HGlobals
HServerInfo storedInfo = null;
synchronized(serversToServerInfo) {
storedInfo = serversToServerInfo.get(serverName);
if(storedInfo == null
|| storedInfo.getStartCode() != startCode) {
if (storedInfo == null
|| storedInfo.getStartCode() != startCode) {
// The current assignment is no good; load the region.
@ -285,16 +285,16 @@ public class HMaster extends HGlobals
}
public void run() {
while((! closed)) {
while((!closed)) {
MetaRegion region = null;
while(region == null) {
synchronized(metaRegionsToScan) {
if(metaRegionsToScan.size() != 0) {
if (metaRegionsToScan.size() != 0) {
region = metaRegionsToScan.remove(0);
}
}
if(region == null) {
if (region == null) {
try {
metaRegionsToScan.wait();
@ -307,7 +307,7 @@ public class HMaster extends HGlobals
synchronized(knownMetaRegions) {
knownMetaRegions.put(region.startKey, region);
if(rootScanned && knownMetaRegions.size() == numMetaRegions) {
if (rootScanned && knownMetaRegions.size() == numMetaRegions) {
allMetaRegionsScanned = true;
allMetaRegionsScanned.notifyAll();
}
@ -319,7 +319,7 @@ public class HMaster extends HGlobals
} catch(InterruptedException ex) {
}
if(! allMetaRegionsScanned) {
if (!allMetaRegionsScanned) {
break; // A region must have split
}
@ -328,7 +328,7 @@ public class HMaster extends HGlobals
Vector<MetaRegion> v = new Vector<MetaRegion>();
v.addAll(knownMetaRegions.values());
for(Iterator<MetaRegion> i = v.iterator(); i.hasNext(); ) {
for(Iterator<MetaRegion> i = v.iterator(); i.hasNext();) {
scanRegion(i.next());
}
} while(true);
@ -391,12 +391,12 @@ public class HMaster extends HGlobals
// Make sure the root directory exists!
if(! fs.exists(dir)) {
if (!fs.exists(dir)) {
fs.mkdirs(dir);
}
Path rootRegionDir = HStoreFile.getHRegionDir(dir, rootRegionInfo.regionName);
if(! fs.exists(rootRegionDir)) {
if (!fs.exists(rootRegionDir)) {
// Bootstrap! Need to create the root region and the first meta region.
//TODO is the root region self referential?
@ -521,7 +521,7 @@ public class HMaster extends HGlobals
synchronized(serversToServerInfo) {
storedInfo = serversToServerInfo.get(server);
if(storedInfo != null) {
if (storedInfo != null) {
serversToServerInfo.remove(server);
synchronized(msgQueue) {
@ -548,7 +548,7 @@ public class HMaster extends HGlobals
synchronized(serversToServerInfo) {
HServerInfo storedInfo = serversToServerInfo.get(server);
if(storedInfo == null) {
if (storedInfo == null) {
// The HBaseMaster may have been restarted.
// Tell the RegionServer to start over and call regionServerStartup()
@ -557,7 +557,7 @@ public class HMaster extends HGlobals
returnMsgs[0] = new HMsg(HMsg.MSG_CALL_SERVER_STARTUP);
return returnMsgs;
} else if(storedInfo.getStartCode() != serverInfo.getStartCode()) {
} else if (storedInfo.getStartCode() != serverInfo.getStartCode()) {
// This state is reachable if:
//
@ -597,9 +597,9 @@ public class HMaster extends HGlobals
// Process the kill list
TreeMap<Text, HRegionInfo> regionsToKill = killList.get(info.toString());
if(regionsToKill != null) {
if (regionsToKill != null) {
for(Iterator<HRegionInfo> i = regionsToKill.values().iterator();
i.hasNext(); ) {
i.hasNext();) {
returnMsgs.add(new HMsg(HMsg.MSG_REGION_CLOSE_AND_DELETE, i.next()));
}
@ -616,7 +616,7 @@ public class HMaster extends HGlobals
case HMsg.MSG_REPORT_OPEN:
HRegionInfo regionInfo = unassignedRegions.get(region.regionName);
if(regionInfo == null) {
if (regionInfo == null) {
// This Region should not have been opened.
// Ask the server to shut it down, but don't report it as closed.
@ -632,7 +632,7 @@ public class HMaster extends HGlobals
unassignedRegions.remove(region.regionName);
assignAttempts.remove(region.regionName);
if(region.regionName.compareTo(rootRegionInfo.regionName) == 0) {
if (region.regionName.compareTo(rootRegionInfo.regionName) == 0) {
// Store the Root Region location (in memory)
@ -643,7 +643,7 @@ public class HMaster extends HGlobals
rootRegionLocation.notifyAll();
break;
} else if(region.regionName.find(META_TABLE_NAME.toString()) == 0) {
} else if (region.regionName.find(META_TABLE_NAME.toString()) == 0) {
// It's a meta region. Put it on the queue to be scanned.
@ -668,7 +668,7 @@ public class HMaster extends HGlobals
break;
case HMsg.MSG_REPORT_CLOSE:
if(region.regionName.compareTo(rootRegionInfo.regionName) == 0) { // Root region
if (region.regionName.compareTo(rootRegionInfo.regionName) == 0) { // Root region
rootRegionLocation = null;
unassignedRegions.put(region.regionName, region);
assignAttempts.put(region.regionName, 0L);
@ -676,10 +676,10 @@ public class HMaster extends HGlobals
} else {
boolean reassignRegion = true;
if(regionsToKill.containsKey(region.regionName)) {
if (regionsToKill.containsKey(region.regionName)) {
regionsToKill.remove(region.regionName);
if(regionsToKill.size() > 0) {
if (regionsToKill.size() > 0) {
killList.put(info.toString(), regionsToKill);
} else {
@ -701,7 +701,7 @@ public class HMaster extends HGlobals
break;
case HMsg.MSG_NEW_REGION:
if(region.regionName.find(META_TABLE_NAME.toString()) == 0) {
if (region.regionName.find(META_TABLE_NAME.toString()) == 0) {
// A meta region has split.
allMetaRegionsScanned = false;
@ -720,7 +720,7 @@ public class HMaster extends HGlobals
// Figure out what the RegionServer ought to do, and write back.
if(unassignedRegions.size() > 0) {
if (unassignedRegions.size() > 0) {
// Open new regions as necessary
@ -731,20 +731,20 @@ public class HMaster extends HGlobals
long now = System.currentTimeMillis();
for(Iterator<Text> it = unassignedRegions.keySet().iterator();
it.hasNext(); ) {
it.hasNext();) {
Text curRegionName = it.next();
HRegionInfo regionInfo = unassignedRegions.get(curRegionName);
long assignedTime = assignAttempts.get(curRegionName);
if(now - assignedTime > maxRegionOpenTime) {
if (now - assignedTime > maxRegionOpenTime) {
returnMsgs.add(new HMsg(HMsg.MSG_REGION_OPEN, regionInfo));
assignAttempts.put(curRegionName, now);
counter++;
}
if(counter >= targetForServer) {
if (counter >= targetForServer) {
break;
}
}
@ -762,7 +762,7 @@ public class HMaster extends HGlobals
}
public void run() {
while(! closed) {
while(!closed) {
PendingOperation op = null;
synchronized(msgQueue) {
@ -827,7 +827,7 @@ public class HMaster extends HGlobals
byte serverBytes[] = results.get(META_COL_SERVER);
String serverName = new String(serverBytes, UTF8_ENCODING);
if(deadServer.compareTo(serverName) != 0) {
if (deadServer.compareTo(serverName) != 0) {
// This isn't the server you're looking for - move along
continue;
}
@ -835,7 +835,7 @@ public class HMaster extends HGlobals
byte startCodeBytes[] = results.get(META_COL_STARTCODE);
long startCode = Long.decode(new String(startCodeBytes, UTF8_ENCODING));
if(oldStartCode != startCode) {
if (oldStartCode != startCode) {
// Close but no cigar
continue;
}
@ -869,7 +869,7 @@ public class HMaster extends HGlobals
// Put all the regions we found on the unassigned region list
for(Iterator<Map.Entry<Text, HRegionInfo>> i = regions.entrySet().iterator();
i.hasNext(); ) {
i.hasNext();) {
Map.Entry<Text, HRegionInfo> e = i.next();
Text region = e.getKey();
@ -903,7 +903,7 @@ public class HMaster extends HGlobals
scanMetaRegion(server, scanner, rootRegionInfo.regionName);
for(Iterator<MetaRegion> i = knownMetaRegions.values().iterator();
i.hasNext(); ) {
i.hasNext();) {
MetaRegion r = i.next();
@ -929,7 +929,7 @@ public class HMaster extends HGlobals
// If the region closing down is a meta region then we need to update
// the ROOT table
if(this.regionInfo.regionName.find(metaTableDesc.getName().toString()) == 0) {
if (this.regionInfo.regionName.find(metaTableDesc.getName().toString()) == 0) {
this.rootRegion = true;
} else {
@ -954,7 +954,7 @@ public class HMaster extends HGlobals
Text metaRegionName;
HRegionInterface server;
if(rootRegion) {
if (rootRegion) {
metaRegionName = rootRegionInfo.regionName;
server = client.getHRegionConnection(rootRegionLocation);
@ -969,7 +969,7 @@ public class HMaster extends HGlobals
server.delete(metaRegionName, clientId, lockid, META_COL_STARTCODE);
server.commit(metaRegionName, clientId, lockid);
if(reassignRegion) {
if (reassignRegion) {
synchronized(unassignedRegions) {
unassignedRegions.put(regionInfo.regionName, regionInfo);
assignAttempts.put(regionInfo.regionName, 0L);
@ -986,7 +986,7 @@ public class HMaster extends HGlobals
BytesWritable startCode;
public PendingOpenReport(HServerInfo info, Text regionName) {
if(regionName.find(metaTableDesc.getName().toString()) == 0) {
if (regionName.find(metaTableDesc.getName().toString()) == 0) {
// The region which just came on-line is a META region.
// We need to look in the ROOT region for its information.
@ -1030,7 +1030,7 @@ public class HMaster extends HGlobals
Text metaRegionName;
HRegionInterface server;
if(rootRegion) {
if (rootRegion) {
metaRegionName = rootRegionInfo.regionName;
server = client.getHRegionConnection(rootRegionLocation);
@ -1074,13 +1074,13 @@ public class HMaster extends HGlobals
BytesWritable bytes = server.get(metaRegionName, desc.getName(), META_COL_REGIONINFO);
if(bytes != null && bytes.getSize() != 0) {
if (bytes != null && bytes.getSize() != 0) {
byte[] infoBytes = bytes.get();
DataInputBuffer inbuf = new DataInputBuffer();
inbuf.reset(infoBytes, infoBytes.length);
HRegionInfo info = new HRegionInfo();
info.readFields(inbuf);
if(info.tableDesc.getName().compareTo(desc.getName()) == 0) {
if (info.tableDesc.getName().compareTo(desc.getName()) == 0) {
throw new IOException("table already exists");
}
}
@ -1183,7 +1183,7 @@ public class HMaster extends HGlobals
}
for(Iterator<MetaRegion> i = knownMetaRegions.tailMap(tableName).values().iterator();
i.hasNext(); ) {
i.hasNext();) {
// Find all the regions that make up this table
@ -1206,7 +1206,7 @@ public class HMaster extends HGlobals
HRegionInfo info = new HRegionInfo();
info.readFields(inbuf);
if(info.tableDesc.getName().compareTo(tableName) > 0) {
if (info.tableDesc.getName().compareTo(tableName) > 0) {
break; // Beyond any more entries for this table
}
@ -1220,12 +1220,12 @@ public class HMaster extends HGlobals
synchronized(serversToServerInfo) {
HServerInfo s = serversToServerInfo.get(serverName);
if(s != null && s.getStartCode() == startCode) {
if (s != null && s.getStartCode() == startCode) {
// It is being served. Tell the server to stop it and not report back
TreeMap<Text, HRegionInfo> regionsToKill = killList.get(serverName);
if(regionsToKill == null) {
if (regionsToKill == null) {
regionsToKill = new TreeMap<Text, HRegionInfo>();
}
regionsToKill.put(info.regionName, info);
@ -1233,7 +1233,7 @@ public class HMaster extends HGlobals
}
}
}
for(Iterator<Text> row = rowsToDelete.iterator(); row.hasNext(); ) {
for(Iterator<Text> row = rowsToDelete.iterator(); row.hasNext();) {
long lockid = server.startUpdate(m.regionName, clientId, row.next());
server.delete(m.regionName, clientId, lockid, columns[0]);
server.commit(m.regionName, clientId, lockid);

View File

@ -65,10 +65,10 @@ public class HMemcache {
locking.obtainWriteLock();
try {
if(snapshot != null) {
if (snapshot != null) {
throw new IOException("Snapshot in progress!");
}
if(memcache.size() == 0) {
if (memcache.size() == 0) {
LOG.debug("memcache empty. Skipping snapshot");
return retval;
}
@ -99,16 +99,16 @@ public class HMemcache {
locking.obtainWriteLock();
try {
if(snapshot == null) {
if (snapshot == null) {
throw new IOException("Snapshot not present!");
}
LOG.debug("deleting snapshot");
for(Iterator<TreeMap<HStoreKey, BytesWritable>> it = history.iterator();
it.hasNext(); ) {
it.hasNext();) {
TreeMap<HStoreKey, BytesWritable> cur = it.next();
if(snapshot == cur) {
if (snapshot == cur) {
it.remove();
break;
}
@ -130,7 +130,7 @@ public class HMemcache {
public void add(Text row, TreeMap<Text, byte[]> columns, long timestamp) {
locking.obtainWriteLock();
try {
for(Iterator<Text> it = columns.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = columns.keySet().iterator(); it.hasNext();) {
Text column = it.next();
byte[] val = columns.get(column);
@ -156,7 +156,7 @@ public class HMemcache {
results.addAll(0, result);
for(int i = history.size()-1; i >= 0; i--) {
if(numVersions > 0 && results.size() >= numVersions) {
if (numVersions > 0 && results.size() >= numVersions) {
break;
}
@ -164,7 +164,7 @@ public class HMemcache {
results.addAll(results.size(), result);
}
if(results.size() == 0) {
if (results.size() == 0) {
return null;
} else {
@ -203,16 +203,16 @@ public class HMemcache {
SortedMap<HStoreKey, BytesWritable> tailMap = map.tailMap(key);
for(Iterator<HStoreKey> it = tailMap.keySet().iterator(); it.hasNext(); ) {
for(Iterator<HStoreKey> it = tailMap.keySet().iterator(); it.hasNext();) {
HStoreKey itKey = it.next();
Text itCol = itKey.getColumn();
if(results.get(itCol) == null
&& key.matchesWithoutColumn(itKey)) {
if (results.get(itCol) == null
&& key.matchesWithoutColumn(itKey)) {
BytesWritable val = tailMap.get(itKey);
results.put(itCol, val.get());
} else if(key.getRow().compareTo(itKey.getRow()) > 0) {
} else if (key.getRow().compareTo(itKey.getRow()) > 0) {
break;
}
}
@ -232,15 +232,15 @@ public class HMemcache {
HStoreKey curKey = new HStoreKey(key.getRow(), key.getColumn(), key.getTimestamp());
SortedMap<HStoreKey, BytesWritable> tailMap = map.tailMap(curKey);
for(Iterator<HStoreKey> it = tailMap.keySet().iterator(); it.hasNext(); ) {
for(Iterator<HStoreKey> it = tailMap.keySet().iterator(); it.hasNext();) {
HStoreKey itKey = it.next();
if(itKey.matchesRowCol(curKey)) {
if (itKey.matchesRowCol(curKey)) {
result.add(tailMap.get(itKey).get());
curKey.setVersion(itKey.getTimestamp() - 1);
}
if(numVersions > 0 && result.size() >= numVersions) {
if (numVersions > 0 && result.size() >= numVersions) {
break;
}
}
@ -266,7 +266,7 @@ public class HMemcache {
Iterator<HStoreKey> keyIterators[];
@SuppressWarnings("unchecked")
public HMemcacheScanner(long timestamp, Text targetCols[], Text firstRow)
public HMemcacheScanner(long timestamp, Text targetCols[], Text firstRow)
throws IOException {
super(timestamp, targetCols);
@ -276,7 +276,7 @@ public class HMemcache {
this.backingMaps = new TreeMap[history.size() + 1];
int i = 0;
for(Iterator<TreeMap<HStoreKey, BytesWritable>> it = history.iterator();
it.hasNext(); ) {
it.hasNext();) {
backingMaps[i++] = it.next();
}
@ -290,7 +290,7 @@ public class HMemcache {
HStoreKey firstKey = new HStoreKey(firstRow);
for(i = 0; i < backingMaps.length; i++) {
if(firstRow.getLength() != 0) {
if (firstRow.getLength() != 0) {
keyIterators[i] = backingMaps[i].tailMap(firstKey).keySet().iterator();
} else {
@ -298,10 +298,10 @@ public class HMemcache {
}
while(getNext(i)) {
if(! findFirstRow(i, firstRow)) {
if (!findFirstRow(i, firstRow)) {
continue;
}
if(columnMatch(i)) {
if (columnMatch(i)) {
break;
}
}
@ -331,7 +331,7 @@ public class HMemcache {
* @return - true if there is more data available
*/
boolean getNext(int i) {
if(! keyIterators[i].hasNext()) {
if (!keyIterators[i].hasNext()) {
closeSubScanner(i);
return false;
}
@ -350,10 +350,10 @@ public class HMemcache {
/** Shut down map iterators, and release the lock */
public void close() throws IOException {
if(! scannerClosed) {
if (!scannerClosed) {
try {
for(int i = 0; i < keys.length; i++) {
if(keyIterators[i] != null) {
if (keyIterators[i] != null) {
closeSubScanner(i);
}
}

View File

@ -61,21 +61,21 @@ public class HRegion implements HConstants {
// Make sure that srcA comes first; important for key-ordering during
// write of the merged file.
if(srcA.getStartKey() == null) {
if(srcB.getStartKey() == null) {
if (srcA.getStartKey() == null) {
if (srcB.getStartKey() == null) {
throw new IOException("Cannot merge two regions with null start key");
}
// A's start key is null but B's isn't. Assume A comes before B
} else if((srcB.getStartKey() == null) // A is not null but B is
|| (srcA.getStartKey().compareTo(srcB.getStartKey()) > 0)) { // A > B
} else if ((srcB.getStartKey() == null) // A is not null but B is
|| (srcA.getStartKey().compareTo(srcB.getStartKey()) > 0)) { // A > B
HRegion tmp = srcA;
srcA = srcB;
srcB = tmp;
}
if (! srcA.getEndKey().equals(srcB.getStartKey())) {
if (!srcA.getEndKey().equals(srcB.getStartKey())) {
throw new IOException("Cannot merge non-adjacent regions");
}
@ -89,7 +89,7 @@ public class HRegion implements HConstants {
Text endKey = srcB.getEndKey();
Path merges = new Path(srcA.getRegionDir(), MERGEDIR);
if(! fs.exists(merges)) {
if (!fs.exists(merges)) {
fs.mkdirs(merges);
}
@ -98,14 +98,14 @@ public class HRegion implements HConstants {
Path newRegionDir = HStoreFile.getHRegionDir(merges, newRegionInfo.regionName);
if(fs.exists(newRegionDir)) {
if (fs.exists(newRegionDir)) {
throw new IOException("Cannot merge; target file collision at " + newRegionDir);
}
LOG.info("starting merge of regions: " + srcA.getRegionName() + " and "
+ srcB.getRegionName() + " new region start key is '"
+ (startKey == null ? "" : startKey) + "', end key is '"
+ (endKey == null ? "" : endKey) + "'");
+ srcB.getRegionName() + " new region start key is '"
+ (startKey == null ? "" : startKey) + "', end key is '"
+ (endKey == null ? "" : endKey) + "'");
// Flush each of the sources, and merge their files into a single
// target for each column family.
@ -114,10 +114,10 @@ public class HRegion implements HConstants {
TreeSet<HStoreFile> alreadyMerged = new TreeSet<HStoreFile>();
TreeMap<Text, Vector<HStoreFile>> filesToMerge = new TreeMap<Text, Vector<HStoreFile>>();
for(Iterator<HStoreFile> it = srcA.flushcache(true).iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = srcA.flushcache(true).iterator(); it.hasNext();) {
HStoreFile src = it.next();
Vector<HStoreFile> v = filesToMerge.get(src.getColFamily());
if(v == null) {
if (v == null) {
v = new Vector<HStoreFile>();
filesToMerge.put(src.getColFamily(), v);
}
@ -126,10 +126,10 @@ public class HRegion implements HConstants {
LOG.debug("flushing and getting file names for region " + srcB.getRegionName());
for(Iterator<HStoreFile> it = srcB.flushcache(true).iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = srcB.flushcache(true).iterator(); it.hasNext();) {
HStoreFile src = it.next();
Vector<HStoreFile> v = filesToMerge.get(src.getColFamily());
if(v == null) {
if (v == null) {
v = new Vector<HStoreFile>();
filesToMerge.put(src.getColFamily(), v);
}
@ -138,11 +138,11 @@ public class HRegion implements HConstants {
LOG.debug("merging stores");
for(Iterator<Text> it = filesToMerge.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = filesToMerge.keySet().iterator(); it.hasNext();) {
Text colFamily = it.next();
Vector<HStoreFile> srcFiles = filesToMerge.get(colFamily);
HStoreFile dst = new HStoreFile(conf, merges, newRegionInfo.regionName,
colFamily, Math.abs(rand.nextLong()));
colFamily, Math.abs(rand.nextLong()));
dst.mergeStoreFiles(srcFiles, fs, conf);
alreadyMerged.addAll(srcFiles);
@ -153,15 +153,15 @@ public class HRegion implements HConstants {
// of any last-minute inserts
LOG.debug("flushing changes since start of merge for region "
+ srcA.getRegionName());
+ srcA.getRegionName());
filesToMerge.clear();
for(Iterator<HStoreFile> it = srcA.close().iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = srcA.close().iterator(); it.hasNext();) {
HStoreFile src = it.next();
if(! alreadyMerged.contains(src)) {
if (!alreadyMerged.contains(src)) {
Vector<HStoreFile> v = filesToMerge.get(src.getColFamily());
if(v == null) {
if (v == null) {
v = new Vector<HStoreFile>();
filesToMerge.put(src.getColFamily(), v);
}
@ -170,14 +170,14 @@ public class HRegion implements HConstants {
}
LOG.debug("flushing changes since start of merge for region "
+ srcB.getRegionName());
+ srcB.getRegionName());
for(Iterator<HStoreFile> it = srcB.close().iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = srcB.close().iterator(); it.hasNext();) {
HStoreFile src = it.next();
if(! alreadyMerged.contains(src)) {
if (!alreadyMerged.contains(src)) {
Vector<HStoreFile> v = filesToMerge.get(src.getColFamily());
if(v == null) {
if (v == null) {
v = new Vector<HStoreFile>();
filesToMerge.put(src.getColFamily(), v);
}
@ -187,11 +187,11 @@ public class HRegion implements HConstants {
LOG.debug("merging changes since start of merge");
for(Iterator<Text> it = filesToMerge.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = filesToMerge.keySet().iterator(); it.hasNext();) {
Text colFamily = it.next();
Vector<HStoreFile> srcFiles = filesToMerge.get(colFamily);
HStoreFile dst = new HStoreFile(conf, merges, newRegionInfo.regionName,
colFamily, Math.abs(rand.nextLong()));
colFamily, Math.abs(rand.nextLong()));
dst.mergeStoreFiles(srcFiles, fs, conf);
}
@ -199,7 +199,7 @@ public class HRegion implements HConstants {
// Done
HRegion dstRegion = new HRegion(dir, log, fs, conf, newRegionInfo,
newRegionDir, null);
newRegionDir, null);
// Get rid of merges directory
@ -284,7 +284,7 @@ public class HRegion implements HConstants {
* written-to before), then read it from the supplied path.
*/
public HRegion(Path dir, HLog log, FileSystem fs, Configuration conf,
HRegionInfo regionInfo, Path initialFiles, Path oldLogFile) throws IOException {
HRegionInfo regionInfo, Path initialFiles, Path oldLogFile) throws IOException {
this.dir = dir;
this.log = log;
@ -303,29 +303,29 @@ public class HRegion implements HConstants {
// Move prefab HStore files into place (if any)
if(initialFiles != null && fs.exists(initialFiles)) {
if (initialFiles != null && fs.exists(initialFiles)) {
fs.rename(initialFiles, regiondir);
}
// Load in all the HStores.
for(Iterator<Text> it = this.regionInfo.tableDesc.families().iterator();
it.hasNext(); ) {
it.hasNext();) {
Text colFamily = it.next();
stores.put(colFamily, new HStore(dir, this.regionInfo.regionName, colFamily,
this.regionInfo.tableDesc.getMaxVersions(), fs, oldLogFile, conf));
this.regionInfo.tableDesc.getMaxVersions(), fs, oldLogFile, conf));
}
// Get rid of any splits or merges that were lost in-progress
Path splits = new Path(regiondir, SPLITDIR);
if(fs.exists(splits)) {
if (fs.exists(splits)) {
fs.delete(splits);
}
Path merges = new Path(regiondir, MERGEDIR);
if(fs.exists(merges)) {
if (fs.exists(merges)) {
fs.delete(merges);
}
@ -362,7 +362,7 @@ public class HRegion implements HConstants {
public Vector<HStoreFile> close() throws IOException {
boolean shouldClose = false;
synchronized(writestate) {
if(writestate.closed) {
if (writestate.closed) {
LOG.info("region " + this.regionInfo.regionName + " closed");
return new Vector<HStoreFile>();
}
@ -376,13 +376,13 @@ public class HRegion implements HConstants {
shouldClose = true;
}
if(! shouldClose) {
if (!shouldClose) {
return null;
} else {
LOG.info("closing region " + this.regionInfo.regionName);
Vector<HStoreFile> allHStoreFiles = internalFlushcache();
for(Iterator<HStore> it = stores.values().iterator(); it.hasNext(); ) {
for(Iterator<HStore> it = stores.values().iterator(); it.hasNext();) {
HStore store = it.next();
store.close();
}
@ -406,8 +406,8 @@ public class HRegion implements HConstants {
* Returns two brand-new (and open) HRegions
*/
public HRegion[] closeAndSplit(Text midKey) throws IOException {
if(((regionInfo.startKey.getLength() != 0)
&& (regionInfo.startKey.compareTo(midKey) > 0))
if (((regionInfo.startKey.getLength() != 0)
&& (regionInfo.startKey.compareTo(midKey) > 0))
|| ((regionInfo.endKey.getLength() != 0)
&& (regionInfo.endKey.compareTo(midKey) < 0))) {
throw new IOException("Region splitkey must lie within region boundaries.");
@ -419,13 +419,13 @@ public class HRegion implements HConstants {
// or compactions until close() is called.
Path splits = new Path(regiondir, SPLITDIR);
if(! fs.exists(splits)) {
if (!fs.exists(splits)) {
fs.mkdirs(splits);
}
long regionAId = Math.abs(rand.nextLong());
HRegionInfo regionAInfo = new HRegionInfo(regionAId, regionInfo.tableDesc,
regionInfo.startKey, midKey);
regionInfo.startKey, midKey);
long regionBId = Math.abs(rand.nextLong());
HRegionInfo regionBInfo
@ -434,24 +434,24 @@ public class HRegion implements HConstants {
Path dirA = HStoreFile.getHRegionDir(splits, regionAInfo.regionName);
Path dirB = HStoreFile.getHRegionDir(splits, regionBInfo.regionName);
if(fs.exists(dirA) || fs.exists(dirB)) {
if (fs.exists(dirA) || fs.exists(dirB)) {
throw new IOException("Cannot split; target file collision at " + dirA
+ " or " + dirB);
+ " or " + dirB);
}
TreeSet<HStoreFile> alreadySplit = new TreeSet<HStoreFile>();
Vector<HStoreFile> hstoreFilesToSplit = flushcache(true);
for(Iterator<HStoreFile> it = hstoreFilesToSplit.iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = hstoreFilesToSplit.iterator(); it.hasNext();) {
HStoreFile hsf = it.next();
LOG.debug("splitting HStore " + hsf.getRegionName() + "/" + hsf.getColFamily()
+ "/" + hsf.fileId());
+ "/" + hsf.fileId());
HStoreFile dstA = new HStoreFile(conf, splits, regionAInfo.regionName,
hsf.getColFamily(), Math.abs(rand.nextLong()));
hsf.getColFamily(), Math.abs(rand.nextLong()));
HStoreFile dstB = new HStoreFile(conf, splits, regionBInfo.regionName,
hsf.getColFamily(), Math.abs(rand.nextLong()));
hsf.getColFamily(), Math.abs(rand.nextLong()));
hsf.splitStoreFile(midKey, dstA, dstB, fs, conf);
alreadySplit.add(hsf);
@ -461,18 +461,18 @@ public class HRegion implements HConstants {
// and copy the small remainder
hstoreFilesToSplit = close();
for(Iterator<HStoreFile> it = hstoreFilesToSplit.iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = hstoreFilesToSplit.iterator(); it.hasNext();) {
HStoreFile hsf = it.next();
if(! alreadySplit.contains(hsf)) {
if (!alreadySplit.contains(hsf)) {
LOG.debug("splitting HStore " + hsf.getRegionName() + "/" + hsf.getColFamily()
+ "/" + hsf.fileId());
+ "/" + hsf.fileId());
HStoreFile dstA = new HStoreFile(conf, splits, regionAInfo.regionName,
hsf.getColFamily(), Math.abs(rand.nextLong()));
hsf.getColFamily(), Math.abs(rand.nextLong()));
HStoreFile dstB = new HStoreFile(conf, splits, regionBInfo.regionName,
hsf.getColFamily(), Math.abs(rand.nextLong()));
hsf.getColFamily(), Math.abs(rand.nextLong()));
hsf.splitStoreFile(midKey, dstA, dstB, fs, conf);
}
@ -494,7 +494,7 @@ public class HRegion implements HConstants {
regions[1] = regionB;
LOG.info("region split complete. new regions are: " + regions[0].getRegionName()
+ ", " + regions[1].getRegionName());
+ ", " + regions[1].getRegionName());
return regions;
}
@ -565,10 +565,10 @@ public class HRegion implements HConstants {
Text key = new Text();
long maxSize = 0;
for(Iterator<HStore> i = stores.values().iterator(); i.hasNext(); ) {
for(Iterator<HStore> i = stores.values().iterator(); i.hasNext();) {
long size = i.next().getLargestFileSize(key);
if(size > maxSize) { // Largest so far
if (size > maxSize) { // Largest so far
maxSize = size;
midKey.set(key);
}
@ -593,9 +593,9 @@ public class HRegion implements HConstants {
public boolean compactStores() throws IOException {
boolean shouldCompact = false;
synchronized(writestate) {
if((! writestate.writesOngoing)
if ((!writestate.writesOngoing)
&& writestate.writesEnabled
&& (! writestate.closed)
&& (!writestate.closed)
&& recentCommits > MIN_COMMITS_FOR_COMPACTION) {
writestate.writesOngoing = true;
@ -603,14 +603,14 @@ public class HRegion implements HConstants {
}
}
if(! shouldCompact) {
if (!shouldCompact) {
LOG.info("not compacting region " + this.regionInfo.regionName);
return false;
} else {
try {
LOG.info("starting compaction on region " + this.regionInfo.regionName);
for(Iterator<HStore> it = stores.values().iterator(); it.hasNext(); ) {
for(Iterator<HStore> it = stores.values().iterator(); it.hasNext();) {
HStore store = it.next();
store.compact();
}
@ -632,7 +632,7 @@ public class HRegion implements HConstants {
* only take if there have been a lot of uncommitted writes.
*/
public void optionallyFlush() throws IOException {
if(commitsSinceFlush > maxUnflushedEntries) {
if (commitsSinceFlush > maxUnflushedEntries) {
flushcache(false);
}
}
@ -657,20 +657,20 @@ public class HRegion implements HConstants {
public Vector<HStoreFile> flushcache(boolean disableFutureWrites) throws IOException {
boolean shouldFlush = false;
synchronized(writestate) {
if((! writestate.writesOngoing)
if ((!writestate.writesOngoing)
&& writestate.writesEnabled
&& (! writestate.closed)) {
&& (!writestate.closed)) {
writestate.writesOngoing = true;
shouldFlush = true;
if(disableFutureWrites) {
if (disableFutureWrites) {
writestate.writesEnabled = false;
}
}
}
if(! shouldFlush) {
if (!shouldFlush) {
LOG.debug("not flushing cache for region " + this.regionInfo.regionName);
return null;
@ -731,8 +731,8 @@ public class HRegion implements HConstants {
HMemcache.Snapshot retval = memcache.snapshotMemcacheForLog(log);
TreeMap<HStoreKey, BytesWritable> memcacheSnapshot = retval.memcacheSnapshot;
if(memcacheSnapshot == null) {
for(Iterator<HStore> it = stores.values().iterator(); it.hasNext(); ) {
if (memcacheSnapshot == null) {
for(Iterator<HStore> it = stores.values().iterator(); it.hasNext();) {
HStore hstore = it.next();
Vector<HStoreFile> hstoreFiles = hstore.getAllMapFiles();
allHStoreFiles.addAll(0, hstoreFiles);
@ -746,7 +746,7 @@ public class HRegion implements HConstants {
LOG.debug("flushing memcache to HStores");
for(Iterator<HStore> it = stores.values().iterator(); it.hasNext(); ) {
for(Iterator<HStore> it = stores.values().iterator(); it.hasNext();) {
HStore hstore = it.next();
Vector<HStoreFile> hstoreFiles
= hstore.flushCache(memcacheSnapshot, logCacheFlushId);
@ -762,7 +762,7 @@ public class HRegion implements HConstants {
LOG.debug("writing flush cache complete to log");
log.completeCacheFlush(this.regionInfo.regionName,
regionInfo.tableDesc.getName(), logCacheFlushId);
regionInfo.tableDesc.getName(), logCacheFlushId);
// C. Delete the now-irrelevant memcache snapshot; its contents have been
// dumped to disk-based HStores.
@ -784,7 +784,7 @@ public class HRegion implements HConstants {
/** Fetch a single data item. */
public byte[] get(Text row, Text column) throws IOException {
byte results[][] = get(row, column, Long.MAX_VALUE, 1);
if(results == null) {
if (results == null) {
return null;
} else {
@ -799,9 +799,9 @@ public class HRegion implements HConstants {
/** Fetch multiple versions of a single data item, with timestamp. */
public byte[][] get(Text row, Text column, long timestamp, int numVersions)
throws IOException {
throws IOException {
if(writestate.closed) {
if (writestate.closed) {
throw new IOException("HRegion is closed.");
}
@ -830,7 +830,7 @@ public class HRegion implements HConstants {
// Check the memcache
byte[][] result = memcache.get(key, numVersions);
if(result != null) {
if (result != null) {
return result;
}
@ -838,7 +838,7 @@ public class HRegion implements HConstants {
Text colFamily = HStoreKey.extractFamily(key.getColumn());
HStore targetStore = stores.get(colFamily);
if(targetStore == null) {
if (targetStore == null) {
return null;
}
@ -859,7 +859,7 @@ public class HRegion implements HConstants {
HStoreKey key = new HStoreKey(row, System.currentTimeMillis());
TreeMap<Text, byte[]> memResult = memcache.getFull(key);
for(Iterator<Text> it = stores.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = stores.keySet().iterator(); it.hasNext();) {
Text colFamily = it.next();
HStore targetStore = stores.get(colFamily);
targetStore.getFull(key, memResult);
@ -879,7 +879,7 @@ public class HRegion implements HConstants {
HStore storelist[] = new HStore[families.size()];
int i = 0;
for(Iterator<Text> it = families.iterator(); it.hasNext(); ) {
for(Iterator<Text> it = families.iterator(); it.hasNext();) {
Text family = it.next();
storelist[i++] = stores.get(family);
}
@ -918,16 +918,16 @@ public class HRegion implements HConstants {
* method.
*/
public void put(long lockid, Text targetCol, byte[] val) throws IOException {
if(val.length == HStoreKey.DELETE_BYTES.length) {
if (val.length == HStoreKey.DELETE_BYTES.length) {
boolean matches = true;
for(int i = 0; i < val.length; i++) {
if(val[i] != HStoreKey.DELETE_BYTES[i]) {
if (val[i] != HStoreKey.DELETE_BYTES[i]) {
matches = false;
break;
}
}
if(matches) {
if (matches) {
throw new IOException("Cannot insert value: " + val);
}
}
@ -951,7 +951,7 @@ public class HRegion implements HConstants {
*/
void localput(long lockid, Text targetCol, byte[] val) throws IOException {
Text row = getRowFromLock(lockid);
if(row == null) {
if (row == null) {
throw new IOException("No write lock for lockid " + lockid);
}
@ -964,13 +964,13 @@ public class HRegion implements HConstants {
// This check makes sure that another thread from the client
// hasn't aborted/committed the write-operation.
if(row != getRowFromLock(lockid)) {
if (row != getRowFromLock(lockid)) {
throw new IOException("Locking error: put operation on lock " + lockid
+ " unexpected aborted by another thread");
+ " unexpected aborted by another thread");
}
TreeMap<Text, byte[]> targets = targetColumns.get(lockid);
if(targets == null) {
if (targets == null) {
targets = new TreeMap<Text, byte[]>();
targetColumns.put(lockid, targets);
}
@ -985,7 +985,7 @@ public class HRegion implements HConstants {
*/
public void abort(long lockid) throws IOException {
Text row = getRowFromLock(lockid);
if(row == null) {
if (row == null) {
throw new IOException("No write lock for lockid " + lockid);
}
@ -998,9 +998,9 @@ public class HRegion implements HConstants {
// This check makes sure another thread from the client
// hasn't aborted/committed the write-operation.
if(row != getRowFromLock(lockid)) {
if (row != getRowFromLock(lockid)) {
throw new IOException("Locking error: abort() operation on lock "
+ lockid + " unexpected aborted by another thread");
+ lockid + " unexpected aborted by another thread");
}
targetColumns.remove(lockid);
@ -1021,7 +1021,7 @@ public class HRegion implements HConstants {
// that repeated executions won't screw this up.
Text row = getRowFromLock(lockid);
if(row == null) {
if (row == null) {
throw new IOException("No write lock for lockid " + lockid);
}
@ -1035,7 +1035,7 @@ public class HRegion implements HConstants {
long commitTimestamp = System.currentTimeMillis();
log.append(regionInfo.regionName, regionInfo.tableDesc.getName(), row,
targetColumns.get(lockid), commitTimestamp);
targetColumns.get(lockid), commitTimestamp);
memcache.add(row, targetColumns.get(lockid), commitTimestamp);
@ -1054,25 +1054,25 @@ public class HRegion implements HConstants {
/** Make sure this is a valid row for the HRegion */
void checkRow(Text row) throws IOException {
if(((regionInfo.startKey.getLength() == 0)
|| (regionInfo.startKey.compareTo(row) <= 0))
if (((regionInfo.startKey.getLength() == 0)
|| (regionInfo.startKey.compareTo(row) <= 0))
&& ((regionInfo.endKey.getLength() == 0)
|| (regionInfo.endKey.compareTo(row) > 0))) {
// all's well
} else {
throw new IOException("Requested row out of range for HRegion "
+ regionInfo.regionName + ", startKey='" + regionInfo.startKey
+ "', endKey='" + regionInfo.endKey + "', row='" + row + "'");
+ regionInfo.regionName + ", startKey='" + regionInfo.startKey
+ "', endKey='" + regionInfo.endKey + "', row='" + row + "'");
}
}
/** Make sure this is a valid column for the current table */
void checkFamily(Text family) throws IOException {
if(! regionInfo.tableDesc.hasFamily(family)) {
if (!regionInfo.tableDesc.hasFamily(family)) {
throw new IOException("Requested column family " + family
+ " does not exist in HRegion " + regionInfo.regionName
+ " for table " + regionInfo.tableDesc.getName());
+ " does not exist in HRegion " + regionInfo.regionName
+ " for table " + regionInfo.tableDesc.getName());
}
}
@ -1150,7 +1150,7 @@ public class HRegion implements HConstants {
keys[i] = new HStoreKey();
resultSets[i] = new TreeMap<Text, byte[]>();
if(! scanners[i].next(keys[i], resultSets[i])) {
if (!scanners[i].next(keys[i], resultSets[i])) {
closeScanner(i);
}
}
@ -1167,7 +1167,7 @@ public class HRegion implements HConstants {
Text chosenRow = null;
long chosenTimestamp = -1;
for(int i = 0; i < keys.length; i++) {
if(scanners[i] != null
if (scanners[i] != null
&& (chosenRow == null
|| (keys[i].getRow().compareTo(chosenRow) < 0)
|| ((keys[i].getRow().compareTo(chosenRow) == 0)
@ -1181,21 +1181,21 @@ public class HRegion implements HConstants {
// Store the key and results for each sub-scanner. Merge them as appropriate.
boolean insertedItem = false;
if(chosenTimestamp > 0) {
if (chosenTimestamp > 0) {
key.setRow(chosenRow);
key.setVersion(chosenTimestamp);
key.setColumn(new Text(""));
for(int i = 0; i < scanners.length; i++) {
while((scanners[i] != null)
&& (keys[i].getRow().compareTo(chosenRow) == 0)
&& (keys[i].getTimestamp() == chosenTimestamp)) {
&& (keys[i].getRow().compareTo(chosenRow) == 0)
&& (keys[i].getTimestamp() == chosenTimestamp)) {
results.putAll(resultSets[i]);
insertedItem = true;
resultSets[i].clear();
if(! scanners[i].next(keys[i], resultSets[i])) {
if (!scanners[i].next(keys[i], resultSets[i])) {
closeScanner(i);
}
}
@ -1204,10 +1204,10 @@ public class HRegion implements HConstants {
// row label, then its timestamp is bad. We need to advance it.
while((scanners[i] != null)
&& (keys[i].getRow().compareTo(chosenRow) <= 0)) {
&& (keys[i].getRow().compareTo(chosenRow) <= 0)) {
resultSets[i].clear();
if(! scanners[i].next(keys[i], resultSets[i])) {
if (!scanners[i].next(keys[i], resultSets[i])) {
closeScanner(i);
}
}
@ -1231,7 +1231,7 @@ public class HRegion implements HConstants {
/** All done with the scanner. */
public void close() throws IOException {
for(int i = 0; i < scanners.length; i++) {
if(scanners[i] != null) {
if (scanners[i] != null) {
closeScanner(i);
}
}

View File

@ -42,19 +42,19 @@ public class HRegionInfo implements Writable {
this.regionId = regionId;
if(tableDesc == null) {
if (tableDesc == null) {
throw new IllegalArgumentException("tableDesc cannot be null");
}
this.tableDesc = tableDesc;
this.startKey = new Text();
if(startKey != null) {
if (startKey != null) {
this.startKey.set(startKey);
}
this.endKey = new Text();
if(endKey != null) {
if (endKey != null) {
this.endKey.set(endKey);
}

View File

@ -61,7 +61,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
}
public void run() {
while(! stopRequested) {
while(!stopRequested) {
long startTime = System.currentTimeMillis();
// Grab a list of regions to check
@ -78,12 +78,12 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
// Check to see if they need splitting
Vector<SplitRegion> toSplit = new Vector<SplitRegion>();
for(Iterator<HRegion> it = checkSplit.iterator(); it.hasNext(); ) {
for(Iterator<HRegion> it = checkSplit.iterator(); it.hasNext();) {
HRegion cur = it.next();
Text midKey = new Text();
try {
if(cur.needsSplit(midKey)) {
if (cur.needsSplit(midKey)) {
toSplit.add(new SplitRegion(cur, midKey));
}
@ -92,7 +92,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
}
}
for(Iterator<SplitRegion> it = toSplit.iterator(); it.hasNext(); ) {
for(Iterator<SplitRegion> it = toSplit.iterator(); it.hasNext();) {
SplitRegion r = it.next();
locking.obtainWriteLock();
@ -161,7 +161,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
private Thread cacheFlusherThread;
private class Flusher implements Runnable {
public void run() {
while(! stopRequested) {
while(!stopRequested) {
long startTime = System.currentTimeMillis();
// Grab a list of items to flush
@ -177,7 +177,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
// Flush them, if necessary
for(Iterator<HRegion> it = toFlush.iterator(); it.hasNext(); ) {
for(Iterator<HRegion> it = toFlush.iterator(); it.hasNext();) {
HRegion cur = it.next();
try {
@ -212,12 +212,12 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
private Thread logRollerThread;
private class LogRoller implements Runnable {
public void run() {
while(! stopRequested) {
while(!stopRequested) {
// If the number of log entries is high enough, roll the log. This is a
// very fast operation, but should not be done too frequently.
if(log.getNumEntries() > maxLogEntries) {
if (log.getNumEntries() > maxLogEntries) {
try {
log.rollWriter();
@ -334,7 +334,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
* processing to cease.
*/
public void stop() throws IOException {
if(! stopRequested) {
if (!stopRequested) {
stopRequested = true;
closeAllRegions();
@ -375,7 +375,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
* load/unload instructions.
*/
public void run() {
while(! stopRequested) {
while(!stopRequested) {
HServerInfo info = new HServerInfo(address, rand.nextLong());
long lastMsg = 0;
long waitTime;
@ -398,8 +398,8 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
// Now ask the master what it wants us to do and tell it what we have done.
while(! stopRequested) {
if((System.currentTimeMillis() - lastMsg) >= msgInterval) {
while(!stopRequested) {
if ((System.currentTimeMillis() - lastMsg) >= msgInterval) {
HMsg outboundArray[] = null;
synchronized(outboundMsgs) {
@ -413,7 +413,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
// Process the HMaster's instruction stream
if(! processMessages(msgs)) {
if (!processMessages(msgs)) {
break;
}
@ -529,10 +529,10 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
try {
HRegion region = regions.remove(info.regionName);
if(region != null) {
if (region != null) {
region.close();
if(reportWhenCompleted) {
if (reportWhenCompleted) {
reportClose(region);
}
}
@ -548,7 +548,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
try {
HRegion region = regions.remove(info.regionName);
if(region != null) {
if (region != null) {
region.closeAndDelete();
}
@ -561,7 +561,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
private void closeAllRegions() throws IOException {
locking.obtainWriteLock();
try {
for(Iterator<HRegion> it = regions.values().iterator(); it.hasNext(); ) {
for(Iterator<HRegion> it = regions.values().iterator(); it.hasNext();) {
HRegion region = it.next();
region.close();
}
@ -606,7 +606,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
/** Obtain a table descriptor for the given region */
public HRegionInfo getRegionInfo(Text regionName) {
HRegion region = getRegion(regionName);
if(region == null) {
if (region == null) {
return null;
}
return region.getRegionInfo();
@ -617,7 +617,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
Text firstRow) throws IOException {
HRegion r = getRegion(regionName);
if(r == null) {
if (r == null) {
throw new IOException("Not serving region " + regionName);
}
return r.getScanner(cols, firstRow);
@ -626,12 +626,12 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
/** Get the indicated row/column */
public BytesWritable get(Text regionName, Text row, Text column) throws IOException {
HRegion region = getRegion(regionName);
if(region == null) {
if (region == null) {
throw new IOException("Not serving region " + regionName);
}
byte results[] = region.get(row, column);
if(results != null) {
if (results != null) {
return new BytesWritable(results);
}
return null;
@ -642,15 +642,15 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
int numVersions) throws IOException {
HRegion region = getRegion(regionName);
if(region == null) {
if (region == null) {
throw new IOException("Not serving region " + regionName);
}
byte results[][] = region.get(row, column, numVersions);
if(results != null) {
if (results != null) {
BytesWritable realResults[] = new BytesWritable[results.length];
for(int i = 0; i < realResults.length; i++) {
if(results[i] != null) {
if (results[i] != null) {
realResults[i] = new BytesWritable(results[i]);
}
}
@ -664,15 +664,15 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
long timestamp, int numVersions) throws IOException {
HRegion region = getRegion(regionName);
if(region == null) {
if (region == null) {
throw new IOException("Not serving region " + regionName);
}
byte results[][] = region.get(row, column, timestamp, numVersions);
if(results != null) {
if (results != null) {
BytesWritable realResults[] = new BytesWritable[results.length];
for(int i = 0; i < realResults.length; i++) {
if(results[i] != null) {
if (results[i] != null) {
realResults[i] = new BytesWritable(results[i]);
}
}
@ -684,14 +684,14 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
/** Get all the columns (along with their names) for a given row. */
public LabelledData[] getRow(Text regionName, Text row) throws IOException {
HRegion region = getRegion(regionName);
if(region == null) {
if (region == null) {
throw new IOException("Not serving region " + regionName);
}
TreeMap<Text, byte[]> map = region.getFull(row);
LabelledData result[] = new LabelledData[map.size()];
int counter = 0;
for(Iterator<Text> it = map.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = map.keySet().iterator(); it.hasNext();) {
Text colname = it.next();
byte val[] = map.get(colname);
result[counter++] = new LabelledData(colname, val);
@ -726,7 +726,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
throws IOException {
HRegion region = getRegion(regionName);
if(region == null) {
if (region == null) {
throw new IOException("Not serving region " + regionName);
}
@ -743,7 +743,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
BytesWritable val) throws IOException {
HRegion region = getRegion(regionName);
if(region == null) {
if (region == null) {
throw new IOException("Not serving region " + regionName);
}
@ -758,7 +758,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
throws IOException {
HRegion region = getRegion(regionName);
if(region == null) {
if (region == null) {
throw new IOException("Not serving region " + regionName);
}
@ -773,7 +773,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
throws IOException {
HRegion region = getRegion(regionName);
if(region == null) {
if (region == null) {
throw new IOException("Not serving region " + regionName);
}
@ -788,7 +788,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
throws IOException {
HRegion region = getRegion(regionName);
if(region == null) {
if (region == null) {
throw new IOException("Not serving region " + regionName);
}

View File

@ -35,7 +35,7 @@ public class HServerAddress implements Writable {
public HServerAddress(String hostAndPort) {
int colonIndex = hostAndPort.indexOf(':');
if(colonIndex < 0) {
if (colonIndex < 0) {
throw new IllegalArgumentException("Not a host:port pair: " + hostAndPort);
}
String host = hostAndPort.substring(0, colonIndex);
@ -80,7 +80,7 @@ public class HServerAddress implements Writable {
String bindAddress = in.readUTF();
int port = in.readInt();
if(bindAddress == null || bindAddress.length() == 0) {
if (bindAddress == null || bindAddress.length() == 0) {
address = null;
stringValue = null;
@ -91,7 +91,7 @@ public class HServerAddress implements Writable {
}
public void write(DataOutput out) throws IOException {
if(address == null) {
if (address == null) {
out.writeUTF("");
out.writeInt(0);

View File

@ -110,7 +110,7 @@ public class HStore {
this.compactdir = new Path(dir, COMPACTION_DIR);
Path curCompactStore = HStoreFile.getHStoreDir(compactdir, regionName, colFamily);
if(fs.exists(curCompactStore)) {
if (fs.exists(curCompactStore)) {
processReadyCompaction();
fs.delete(curCompactStore);
}
@ -123,7 +123,7 @@ public class HStore {
Vector<HStoreFile> hstoreFiles
= HStoreFile.loadHStoreFiles(conf, dir, regionName, colFamily, fs);
for(Iterator<HStoreFile> it = hstoreFiles.iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = hstoreFiles.iterator(); it.hasNext();) {
HStoreFile hsf = it.next();
mapFiles.put(hsf.loadInfo(fs), hsf);
}
@ -138,11 +138,11 @@ public class HStore {
// contain any updates also contained in the log.
long maxSeqID = -1;
for(Iterator<HStoreFile> it = hstoreFiles.iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = hstoreFiles.iterator(); it.hasNext();) {
HStoreFile hsf = it.next();
long seqid = hsf.loadInfo(fs);
if(seqid > 0) {
if(seqid > maxSeqID) {
if (seqid > 0) {
if (seqid > maxSeqID) {
maxSeqID = seqid;
}
}
@ -157,7 +157,7 @@ public class HStore {
LOG.debug("reading reconstructionLog");
if(reconstructionLog != null && fs.exists(reconstructionLog)) {
if (reconstructionLog != null && fs.exists(reconstructionLog)) {
long maxSeqIdInLog = -1;
TreeMap<HStoreKey, BytesWritable> reconstructedCache
= new TreeMap<HStoreKey, BytesWritable>();
@ -170,7 +170,7 @@ public class HStore {
HLogEdit val = new HLogEdit();
while(login.next(key, val)) {
maxSeqIdInLog = Math.max(maxSeqIdInLog, key.getLogSeqNum());
if(key.getLogSeqNum() <= maxSeqID) {
if (key.getLogSeqNum() <= maxSeqID) {
continue;
}
reconstructedCache.put(new HStoreKey(key.getRow(), val.getColumn(),
@ -181,7 +181,7 @@ public class HStore {
login.close();
}
if(reconstructedCache.size() > 0) {
if (reconstructedCache.size() > 0) {
// We create a "virtual flush" at maxSeqIdInLog+1.
@ -195,7 +195,7 @@ public class HStore {
// should be "timeless"; that is, it should not have an associated seq-ID,
// because all log messages have been reflected in the TreeMaps at this point.
if(mapFiles.size() >= 1) {
if (mapFiles.size() >= 1) {
compactHelper(true);
}
@ -204,7 +204,7 @@ public class HStore {
LOG.debug("starting map readers");
for(Iterator<Long> it = mapFiles.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Long> it = mapFiles.keySet().iterator(); it.hasNext();) {
Long key = it.next().longValue();
HStoreFile hsf = mapFiles.get(key);
@ -222,7 +222,7 @@ public class HStore {
LOG.info("closing HStore for " + this.regionName + "/" + this.colFamily);
try {
for(Iterator<MapFile.Reader> it = maps.values().iterator(); it.hasNext(); ) {
for(Iterator<MapFile.Reader> it = maps.values().iterator(); it.hasNext();) {
MapFile.Reader map = it.next();
map.close();
}
@ -273,9 +273,9 @@ public class HStore {
HStoreKey.class, BytesWritable.class);
try {
for(Iterator<HStoreKey> it = inputCache.keySet().iterator(); it.hasNext(); ) {
for(Iterator<HStoreKey> it = inputCache.keySet().iterator(); it.hasNext();) {
HStoreKey curkey = it.next();
if(this.colFamily.equals(HStoreKey.extractFamily(curkey.getColumn()))) {
if (this.colFamily.equals(HStoreKey.extractFamily(curkey.getColumn()))) {
BytesWritable val = inputCache.get(curkey);
out.append(curkey, val);
}
@ -294,7 +294,7 @@ public class HStore {
// C. Finally, make the new MapFile available.
if(addToAvailableMaps) {
if (addToAvailableMaps) {
locking.obtainWriteLock();
try {
@ -312,7 +312,7 @@ public class HStore {
public Vector<HStoreFile> getAllMapFiles() {
Vector<HStoreFile> flushedFiles = new Vector<HStoreFile>();
for(Iterator<HStoreFile> it = mapFiles.values().iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = mapFiles.values().iterator(); it.hasNext();) {
HStoreFile hsf = it.next();
flushedFiles.add(hsf);
}
@ -366,11 +366,11 @@ public class HStore {
// Compute the max-sequenceID seen in any of the to-be-compacted TreeMaps
long maxSeenSeqID = -1;
for(Iterator<HStoreFile> it = toCompactFiles.iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = toCompactFiles.iterator(); it.hasNext();) {
HStoreFile hsf = it.next();
long seqid = hsf.loadInfo(fs);
if(seqid > 0) {
if(seqid > maxSeenSeqID) {
if (seqid > 0) {
if (seqid > maxSeenSeqID) {
maxSeenSeqID = seqid;
}
}
@ -380,11 +380,11 @@ public class HStore {
HStoreFile compactedOutputFile
= new HStoreFile(conf, compactdir, regionName, colFamily, -1);
if(toCompactFiles.size() == 1) {
if (toCompactFiles.size() == 1) {
LOG.debug("nothing to compact for " + this.regionName + "/" + this.colFamily);
HStoreFile hsf = toCompactFiles.elementAt(0);
if(hsf.loadInfo(fs) == -1) {
if (hsf.loadInfo(fs) == -1) {
return;
}
}
@ -414,7 +414,7 @@ public class HStore {
BytesWritable[] vals = new BytesWritable[toCompactFiles.size()];
boolean[] done = new boolean[toCompactFiles.size()];
int pos = 0;
for(Iterator<HStoreFile> it = toCompactFiles.iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = toCompactFiles.iterator(); it.hasNext();) {
HStoreFile hsf = it.next();
readers[pos] = new MapFile.Reader(fs, hsf.getMapFilePath().toString(), conf);
keys[pos] = new HStoreKey();
@ -431,8 +431,8 @@ public class HStore {
int numDone = 0;
for(int i = 0; i < readers.length; i++) {
readers[i].reset();
done[i] = ! readers[i].next(keys[i], vals[i]);
if(done[i]) {
done[i] = !readers[i].next(keys[i], vals[i]);
if (done[i]) {
numDone++;
}
}
@ -446,15 +446,15 @@ public class HStore {
int smallestKey = -1;
for(int i = 0; i < readers.length; i++) {
if(done[i]) {
if (done[i]) {
continue;
}
if(smallestKey < 0) {
if (smallestKey < 0) {
smallestKey = i;
} else {
if(keys[i].compareTo(keys[smallestKey]) < 0) {
if (keys[i].compareTo(keys[smallestKey]) < 0) {
smallestKey = i;
}
}
@ -463,8 +463,8 @@ public class HStore {
// Reflect the current key/val in the output
HStoreKey sk = keys[smallestKey];
if(lastRow.equals(sk.getRow())
&& lastColumn.equals(sk.getColumn())) {
if (lastRow.equals(sk.getRow())
&& lastColumn.equals(sk.getColumn())) {
timesSeen++;
@ -472,13 +472,13 @@ public class HStore {
timesSeen = 1;
}
if(timesSeen <= maxVersions) {
if (timesSeen <= maxVersions) {
// Keep old versions until we have maxVersions worth.
// Then just skip them.
if(sk.getRow().getLength() != 0
&& sk.getColumn().getLength() != 0) {
if (sk.getRow().getLength() != 0
&& sk.getColumn().getLength() != 0) {
// Only write out objects which have a non-zero length key and value
@ -499,7 +499,7 @@ public class HStore {
// Advance the smallest key. If that reader's all finished, then
// mark it as done.
if(! readers[smallestKey].next(keys[smallestKey], vals[smallestKey])) {
if (!readers[smallestKey].next(keys[smallestKey], vals[smallestKey])) {
done[smallestKey] = true;
readers[smallestKey].close();
numDone++;
@ -516,7 +516,7 @@ public class HStore {
// Now, write out an HSTORE_LOGINFOFILE for the brand-new TreeMap.
if((! deleteSequenceInfo) && maxSeenSeqID >= 0) {
if ((!deleteSequenceInfo) && maxSeenSeqID >= 0) {
compactedOutputFile.writeInfo(fs, maxSeenSeqID);
} else {
@ -529,7 +529,7 @@ public class HStore {
DataOutputStream out = new DataOutputStream(fs.create(filesToReplace));
try {
out.writeInt(toCompactFiles.size());
for(Iterator<HStoreFile> it = toCompactFiles.iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = toCompactFiles.iterator(); it.hasNext();) {
HStoreFile hsf = it.next();
hsf.write(out);
}
@ -587,7 +587,7 @@ public class HStore {
Path curCompactStore = HStoreFile.getHStoreDir(compactdir, regionName, colFamily);
try {
Path doneFile = new Path(curCompactStore, COMPACTION_DONE);
if(! fs.exists(doneFile)) {
if (!fs.exists(doneFile)) {
// The last execution didn't finish the compaction, so there's nothing
// we can do. We'll just have to redo it. Abandon it and return.
@ -622,18 +622,18 @@ public class HStore {
// 3. Unload all the replaced MapFiles.
Iterator<HStoreFile> it2 = mapFiles.values().iterator();
for(Iterator<MapFile.Reader> it = maps.values().iterator(); it.hasNext(); ) {
for(Iterator<MapFile.Reader> it = maps.values().iterator(); it.hasNext();) {
MapFile.Reader curReader = it.next();
HStoreFile curMapFile = it2.next();
if(toCompactFiles.contains(curMapFile)) {
if (toCompactFiles.contains(curMapFile)) {
curReader.close();
it.remove();
}
}
for(Iterator<HStoreFile> it = mapFiles.values().iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = mapFiles.values().iterator(); it.hasNext();) {
HStoreFile curMapFile = it.next();
if(toCompactFiles.contains(curMapFile)) {
if (toCompactFiles.contains(curMapFile)) {
it.remove();
}
}
@ -645,7 +645,7 @@ public class HStore {
// 4. Delete all the old files, no longer needed
for(Iterator<HStoreFile> it = toCompactFiles.iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = toCompactFiles.iterator(); it.hasNext();) {
HStoreFile hsf = it.next();
fs.delete(hsf.getMapFilePath());
fs.delete(hsf.getInfoFilePath());
@ -720,12 +720,12 @@ public class HStore {
do {
Text readcol = readkey.getColumn();
if(results.get(readcol) == null
&& key.matchesWithoutColumn(readkey)) {
if (results.get(readcol) == null
&& key.matchesWithoutColumn(readkey)) {
results.put(new Text(readcol), readval.get());
readval = new BytesWritable();
} else if(key.getRow().compareTo(readkey.getRow()) > 0) {
} else if (key.getRow().compareTo(readkey.getRow()) > 0) {
break;
}
@ -745,7 +745,7 @@ public class HStore {
* If 'numVersions' is negative, the method returns all available versions.
*/
public byte[][] get(HStoreKey key, int numVersions) throws IOException {
if(numVersions == 0) {
if (numVersions == 0) {
throw new IllegalArgumentException("Must request at least one value.");
}
@ -763,12 +763,12 @@ public class HStore {
map.reset();
HStoreKey readkey = (HStoreKey)map.getClosest(key, readval);
if(readkey.matchesRowCol(key)) {
if (readkey.matchesRowCol(key)) {
results.add(readval.get());
readval = new BytesWritable();
while(map.next(readkey, readval) && readkey.matchesRowCol(key)) {
if(numVersions > 0 && (results.size() >= numVersions)) {
if (numVersions > 0 && (results.size() >= numVersions)) {
break;
} else {
@ -778,12 +778,12 @@ public class HStore {
}
}
}
if(results.size() >= numVersions) {
if (results.size() >= numVersions) {
break;
}
}
if(results.size() == 0) {
if (results.size() == 0) {
return null;
} else {
@ -809,13 +809,13 @@ public class HStore {
// Iterate through all the MapFiles
for(Iterator<Map.Entry<Long, HStoreFile>> it = mapFiles.entrySet().iterator();
it.hasNext(); ) {
it.hasNext();) {
Map.Entry<Long, HStoreFile> e = it.next();
HStoreFile curHSF = e.getValue();
long size = fs.getLength(new Path(curHSF.getMapFilePath(), MapFile.DATA_FILE_NAME));
if(size > maxSize) { // This is the largest one so far
if (size > maxSize) { // This is the largest one so far
maxSize = size;
mapIndex = e.getKey();
}
@ -871,7 +871,7 @@ public class HStore {
try {
this.readers = new MapFile.Reader[mapFiles.size()];
int i = 0;
for(Iterator<HStoreFile> it = mapFiles.values().iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = mapFiles.values().iterator(); it.hasNext();) {
HStoreFile curHSF = it.next();
readers[i++] = new MapFile.Reader(fs, curHSF.getMapFilePath().toString(), conf);
}
@ -885,14 +885,14 @@ public class HStore {
keys[i] = new HStoreKey();
vals[i] = new BytesWritable();
if(firstRow.getLength() != 0) {
if(findFirstRow(i, firstRow)) {
if (firstRow.getLength() != 0) {
if (findFirstRow(i, firstRow)) {
continue;
}
}
while(getNext(i)) {
if(columnMatch(i)) {
if (columnMatch(i)) {
break;
}
}
@ -915,7 +915,7 @@ public class HStore {
HStoreKey firstKey
= (HStoreKey)readers[i].getClosest(new HStoreKey(firstRow), vals[i]);
if(firstKey == null) {
if (firstKey == null) {
// Didn't find it. Close the scanner and return TRUE
@ -935,7 +935,7 @@ public class HStore {
* @return - true if there is more data available
*/
boolean getNext(int i) throws IOException {
if(! readers[i].next(keys[i], vals[i])) {
if (!readers[i].next(keys[i], vals[i])) {
closeSubScanner(i);
return false;
}
@ -945,7 +945,7 @@ public class HStore {
/** Close down the indicated reader. */
void closeSubScanner(int i) throws IOException {
try {
if(readers[i] != null) {
if (readers[i] != null) {
readers[i].close();
}
@ -958,10 +958,10 @@ public class HStore {
/** Shut it down! */
public void close() throws IOException {
if(! scannerClosed) {
if (!scannerClosed) {
try {
for(int i = 0; i < readers.length; i++) {
if(readers[i] != null) {
if (readers[i] != null) {
readers[i].close();
}
}

View File

@ -158,13 +158,13 @@ public class HStoreFile implements HConstants, WritableComparable {
for(int i = 0; i < datfiles.length; i++) {
String name = datfiles[i].getName();
if(name.startsWith(HSTORE_DATFILE_PREFIX)) {
if (name.startsWith(HSTORE_DATFILE_PREFIX)) {
Long fileId = Long.parseLong(name.substring(HSTORE_DATFILE_PREFIX.length()));
HStoreFile curfile = new HStoreFile(conf, dir, regionName, colFamily, fileId);
Path mapfile = curfile.getMapFilePath();
Path infofile = curfile.getInfoFilePath();
if(fs.exists(infofile)) {
if (fs.exists(infofile)) {
results.add(curfile);
} else {
@ -178,12 +178,12 @@ public class HStoreFile implements HConstants, WritableComparable {
for(int i = 0; i < infofiles.length; i++) {
String name = infofiles[i].getName();
if(name.startsWith(HSTORE_INFOFILE_PREFIX)) {
if (name.startsWith(HSTORE_INFOFILE_PREFIX)) {
long fileId = Long.parseLong(name.substring(HSTORE_INFOFILE_PREFIX.length()));
HStoreFile curfile = new HStoreFile(conf, dir, regionName, colFamily, fileId);
Path mapfile = curfile.getMapFilePath();
if(! fs.exists(mapfile)) {
if (!fs.exists(mapfile)) {
fs.delete(curfile.getInfoFilePath());
}
}
@ -220,7 +220,7 @@ public class HStoreFile implements HConstants, WritableComparable {
while(in.next(readkey, readval)) {
Text key = readkey.getRow();
if(key.compareTo(midKey) < 0) {
if (key.compareTo(midKey) < 0) {
outA.append(readkey, readval);
} else {
@ -260,7 +260,7 @@ public class HStoreFile implements HConstants, WritableComparable {
HStoreKey.class, BytesWritable.class);
try {
for(Iterator<HStoreFile> it = srcFiles.iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = srcFiles.iterator(); it.hasNext();) {
HStoreFile src = it.next();
MapFile.Reader in = new MapFile.Reader(fs, src.getMapFilePath().toString(), conf);
@ -283,11 +283,11 @@ public class HStoreFile implements HConstants, WritableComparable {
// Build a unified InfoFile from the source InfoFiles.
long unifiedSeqId = -1;
for(Iterator<HStoreFile> it = srcFiles.iterator(); it.hasNext(); ) {
for(Iterator<HStoreFile> it = srcFiles.iterator(); it.hasNext();) {
HStoreFile hsf = it.next();
long curSeqId = hsf.loadInfo(fs);
if(curSeqId > unifiedSeqId) {
if (curSeqId > unifiedSeqId) {
unifiedSeqId = curSeqId;
}
}
@ -301,7 +301,7 @@ public class HStoreFile implements HConstants, WritableComparable {
try {
byte flag = in.readByte();
if(flag == INFO_SEQ_NUM) {
if (flag == INFO_SEQ_NUM) {
return in.readLong();
} else {
@ -352,17 +352,17 @@ public class HStoreFile implements HConstants, WritableComparable {
public int compareTo(Object o) {
HStoreFile other = (HStoreFile) o;
int result = this.dir.compareTo(other.dir);
if(result == 0) {
if (result == 0) {
this.regionName.compareTo(other.regionName);
}
if(result == 0) {
if (result == 0) {
result = this.colFamily.compareTo(other.colFamily);
}
if(result == 0) {
if(this.fileId < other.fileId) {
if (result == 0) {
if (this.fileId < other.fileId) {
result = -1;
} else if(this.fileId > other.fileId) {
} else if (this.fileId > other.fileId) {
result = 1;
}
}

View File

@ -29,7 +29,7 @@ public class HStoreKey implements WritableComparable {
public static Text extractFamily(Text col) throws IOException {
String column = col.toString();
int colpos = column.indexOf(":");
if(colpos < 0) {
if (colpos < 0) {
throw new IllegalArgumentException("Illegal column name has no family indicator: " + column);
}
return new Text(column.substring(0, colpos));
@ -94,8 +94,8 @@ public class HStoreKey implements WritableComparable {
}
public boolean matchesRowCol(HStoreKey other) {
if(this.row.compareTo(other.row) == 0 &&
this.column.compareTo(other.column) == 0) {
if (this.row.compareTo(other.row) == 0 &&
this.column.compareTo(other.column) == 0) {
return true;
} else {
@ -104,8 +104,8 @@ public class HStoreKey implements WritableComparable {
}
public boolean matchesWithoutColumn(HStoreKey other) {
if((this.row.compareTo(other.row) == 0) &&
(this.timestamp >= other.getTimestamp())) {
if ((this.row.compareTo(other.row) == 0) &&
(this.timestamp >= other.getTimestamp())) {
return true;
} else {
@ -124,14 +124,14 @@ public class HStoreKey implements WritableComparable {
public int compareTo(Object o) {
HStoreKey other = (HStoreKey) o;
int result = this.row.compareTo(other.row);
if(result == 0) {
if (result == 0) {
result = this.column.compareTo(other.column);
if(result == 0) {
if(this.timestamp < other.timestamp) {
if (result == 0) {
if (this.timestamp < other.timestamp) {
result = 1;
} else if(this.timestamp > other.timestamp) {
} else if (this.timestamp > other.timestamp) {
result = -1;
}
}

View File

@ -54,7 +54,7 @@ public class HTableDescriptor implements WritableComparable {
/** Do we contain a given column? */
public boolean hasFamily(Text family) {
if(families.contains(family)) {
if (families.contains(family)) {
return true;
} else {
@ -75,7 +75,7 @@ public class HTableDescriptor implements WritableComparable {
name.write(out);
out.writeInt(maxVersions);
out.writeInt(families.size());
for(Iterator<Text> it = families.iterator(); it.hasNext(); ) {
for(Iterator<Text> it = families.iterator(); it.hasNext();) {
it.next().write(out);
}
}
@ -99,21 +99,21 @@ public class HTableDescriptor implements WritableComparable {
public int compareTo(Object o) {
HTableDescriptor htd = (HTableDescriptor) o;
int result = name.compareTo(htd.name);
if(result == 0) {
if (result == 0) {
result = maxVersions - htd.maxVersions;
}
if(result == 0) {
if (result == 0) {
result = families.size() - htd.families.size();
}
if(result == 0) {
if (result == 0) {
Iterator<Text> it2 = htd.families.iterator();
for(Iterator<Text> it = families.iterator(); it.hasNext(); ) {
for(Iterator<Text> it = families.iterator(); it.hasNext();) {
Text family1 = it.next();
Text family2 = it2.next();
result = family1.compareTo(family2);
if(result != 0) {
if (result != 0) {
return result;
}
}

View File

@ -77,7 +77,7 @@ public class Leases {
synchronized(sortedLeases) {
Lease lease = new Lease(holderId, resourceId, listener);
Text leaseId = lease.getLeaseId();
if(leases.get(leaseId) != null) {
if (leases.get(leaseId) != null) {
throw new IOException("Impossible state for createLease(): Lease for holderId " + holderId + " and resourceId " + resourceId + " is still held.");
}
leases.put(leaseId, lease);
@ -92,7 +92,7 @@ public class Leases {
synchronized(sortedLeases) {
Text leaseId = createLeaseId(holderId, resourceId);
Lease lease = leases.get(leaseId);
if(lease == null) {
if (lease == null) {
// It's possible that someone tries to renew the lease, but
// it just expired a moment ago. So fail.
@ -113,7 +113,7 @@ public class Leases {
synchronized(sortedLeases) {
Text leaseId = createLeaseId(holderId, resourceId);
Lease lease = leases.get(leaseId);
if(lease == null) {
if (lease == null) {
// It's possible that someone tries to renew the lease, but
// it just expired a moment ago. So fail.
@ -139,7 +139,7 @@ public class Leases {
while((sortedLeases.size() > 0)
&& ((top = sortedLeases.first()) != null)) {
if(top.shouldExpire()) {
if (top.shouldExpire()) {
leases.remove(top.getLeaseId());
sortedLeases.remove(top);
@ -205,10 +205,10 @@ public class Leases {
public int compareTo(Object o) {
Lease other = (Lease) o;
if(this.lastUpdate < other.lastUpdate) {
if (this.lastUpdate < other.lastUpdate) {
return -1;
} else if(this.lastUpdate > other.lastUpdate) {
} else if (this.lastUpdate > other.lastUpdate) {
return 1;
} else {

View File

@ -29,27 +29,27 @@ public class Environment {
String value = null;
value = System.getenv("DEBUGGING");
if(value != null && value.equalsIgnoreCase("TRUE")) {
if (value != null && value.equalsIgnoreCase("TRUE")) {
debugging = true;
}
value = System.getenv("LOGGING_LEVEL");
if(value != null && value.length() != 0) {
if(value.equalsIgnoreCase("ALL")) {
if (value != null && value.length() != 0) {
if (value.equalsIgnoreCase("ALL")) {
logLevel = Level.ALL;
} else if(value.equalsIgnoreCase("DEBUG")) {
} else if (value.equalsIgnoreCase("DEBUG")) {
logLevel = Level.DEBUG;
} else if(value.equalsIgnoreCase("ERROR")) {
} else if (value.equalsIgnoreCase("ERROR")) {
logLevel = Level.ERROR;
} else if(value.equalsIgnoreCase("FATAL")) {
} else if (value.equalsIgnoreCase("FATAL")) {
logLevel = Level.FATAL;
} else if(value.equalsIgnoreCase("INFO")) {
} else if (value.equalsIgnoreCase("INFO")) {
logLevel = Level.INFO;
} else if(value.equalsIgnoreCase("OFF")) {
} else if (value.equalsIgnoreCase("OFF")) {
logLevel = Level.OFF;
} else if(value.equalsIgnoreCase("TRACE")) {
} else if (value.equalsIgnoreCase("TRACE")) {
logLevel = Level.TRACE;
} else if(value.equalsIgnoreCase("WARN")) {
} else if (value.equalsIgnoreCase("WARN")) {
logLevel = Level.WARN;
}
}

View File

@ -90,7 +90,7 @@ public class TestHRegion extends TestCase {
public void testSetup() throws IOException {
try {
if(System.getProperty("test.build.data") == null) {
if (System.getProperty("test.build.data") == null) {
String dir = new File(new File("").getAbsolutePath(), "build/contrib/hbase/test").getAbsolutePath();
System.out.println(dir);
System.setProperty("test.build.data", dir);
@ -98,7 +98,7 @@ public class TestHRegion extends TestCase {
conf = new Configuration();
Environment.getenv();
if(Environment.debugging) {
if (Environment.debugging) {
Logger rootLogger = Logger.getRootLogger();
rootLogger.setLevel(Level.WARN);
@ -133,7 +133,7 @@ public class TestHRegion extends TestCase {
// Test basic functionality. Writes to contents:basic and anchor:anchornum-*
public void testBasic() throws IOException {
if(!initialized) {
if (!initialized) {
throw new IllegalStateException();
}
@ -191,7 +191,7 @@ public class TestHRegion extends TestCase {
// Test scanners. Writes contents:firstcol and anchor:secondcol
public void testScan() throws IOException {
if(!initialized) {
if (!initialized) {
throw new IllegalStateException();
}
@ -225,13 +225,13 @@ public class TestHRegion extends TestCase {
TreeMap<Text, byte[]> curVals = new TreeMap<Text, byte[]>();
int k = 0;
while(s.next(curKey, curVals)) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext();) {
Text col = it.next();
byte val[] = curVals.get(col);
int curval = Integer.parseInt(new String(val).trim());
for(int j = 0; j < cols.length; j++) {
if(col.compareTo(cols[j]) == 0) {
if (col.compareTo(cols[j]) == 0) {
assertEquals("Error at:" + curKey.getRow() + "/" + curKey.getTimestamp()
+ ", Value for " + col + " should be: " + k
+ ", but was fetched as: " + curval, k, curval);
@ -258,13 +258,13 @@ public class TestHRegion extends TestCase {
TreeMap<Text, byte[]> curVals = new TreeMap<Text, byte[]>();
int k = 0;
while(s.next(curKey, curVals)) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext();) {
Text col = it.next();
byte val[] = curVals.get(col);
int curval = Integer.parseInt(new String(val).trim());
for(int j = 0; j < cols.length; j++) {
if(col.compareTo(cols[j]) == 0) {
if (col.compareTo(cols[j]) == 0) {
assertEquals("Error at:" + curKey.getRow() + "/" + curKey.getTimestamp()
+ ", Value for " + col + " should be: " + k
+ ", but was fetched as: " + curval, k, curval);
@ -299,13 +299,13 @@ public class TestHRegion extends TestCase {
TreeMap<Text, byte[]> curVals = new TreeMap<Text, byte[]>();
int k = 0;
while(s.next(curKey, curVals)) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext();) {
Text col = it.next();
byte val[] = curVals.get(col);
int curval = Integer.parseInt(new String(val).trim());
for(int j = 0; j < cols.length; j++) {
if(col.compareTo(cols[j]) == 0) {
if (col.compareTo(cols[j]) == 0) {
assertEquals("Error at:" + curKey.getRow() + "/" + curKey.getTimestamp()
+ ", Value for " + col + " should be: " + k
+ ", but was fetched as: " + curval, k, curval);
@ -332,7 +332,7 @@ public class TestHRegion extends TestCase {
TreeMap<Text, byte[]> curVals = new TreeMap<Text, byte[]>();
int k = 0;
while(s.next(curKey, curVals)) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext();) {
Text col = it.next();
byte val[] = curVals.get(col);
int curval = Integer.parseInt(new String(val).trim());
@ -362,7 +362,7 @@ public class TestHRegion extends TestCase {
TreeMap<Text, byte[]> curVals = new TreeMap<Text, byte[]>();
int k = 500;
while(s.next(curKey, curVals)) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext();) {
Text col = it.next();
byte val[] = curVals.get(col);
int curval = Integer.parseInt(new String(val).trim());
@ -390,10 +390,10 @@ public class TestHRegion extends TestCase {
// Creates contents:body
public void testBatchWrite() throws IOException {
if(!initialized || failures) {
if (!initialized || failures) {
throw new IllegalStateException();
}
if(! Environment.debugging) {
if (!Environment.debugging) {
return;
}
@ -437,7 +437,7 @@ public class TestHRegion extends TestCase {
}
}
long startCompact = System.currentTimeMillis();
if(region.compactStores()) {
if (region.compactStores()) {
totalCompact = System.currentTimeMillis() - startCompact;
System.out.println("Region compacted - elapsedTime: " + (totalCompact / 1000.0));
@ -467,14 +467,14 @@ public class TestHRegion extends TestCase {
// NOTE: This test depends on testBatchWrite succeeding
public void testSplitAndMerge() throws IOException {
if(!initialized || failures) {
if (!initialized || failures) {
throw new IllegalStateException();
}
try {
Text midKey = new Text();
if(region.needsSplit(midKey)) {
if (region.needsSplit(midKey)) {
System.out.println("Needs split");
}
@ -504,7 +504,7 @@ public class TestHRegion extends TestCase {
// This test verifies that everything is still there after splitting and merging
public void testRead() throws IOException {
if(!initialized || failures) {
if (!initialized || failures) {
throw new IllegalStateException();
}
@ -525,19 +525,19 @@ public class TestHRegion extends TestCase {
TreeMap<Text, byte[]> curVals = new TreeMap<Text, byte[]>();
int k = 0;
while(s.next(curKey, curVals)) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext();) {
Text col = it.next();
byte val[] = curVals.get(col);
String curval = new String(val).trim();
if(col.compareTo(CONTENTS_BASIC) == 0) {
if (col.compareTo(CONTENTS_BASIC) == 0) {
assertTrue("Error at:" + curKey.getRow() + "/" + curKey.getTimestamp()
+ ", Value for " + col + " should start with: " + CONTENTSTR
+ ", but was fetched as: " + curval,
curval.startsWith(CONTENTSTR));
contentsFetched++;
} else if(col.toString().startsWith(ANCHORNUM)) {
} else if (col.toString().startsWith(ANCHORNUM)) {
assertTrue("Error at:" + curKey.getRow() + "/" + curKey.getTimestamp()
+ ", Value for " + col + " should start with: " + ANCHORSTR
+ ", but was fetched as: " + curval,
@ -572,7 +572,7 @@ public class TestHRegion extends TestCase {
TreeMap<Text, byte[]> curVals = new TreeMap<Text, byte[]>();
int k = 0;
while(s.next(curKey, curVals)) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext();) {
Text col = it.next();
byte val[] = curVals.get(col);
int curval = Integer.parseInt(new String(val).trim());
@ -596,7 +596,7 @@ public class TestHRegion extends TestCase {
// Verify testBatchWrite data
if(Environment.debugging) {
if (Environment.debugging) {
s = region.getScanner(new Text[] { CONTENTS_BODY }, new Text());
try {
int numFetched = 0;
@ -604,7 +604,7 @@ public class TestHRegion extends TestCase {
TreeMap<Text, byte[]> curVals = new TreeMap<Text, byte[]>();
int k = 0;
while(s.next(curKey, curVals)) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext();) {
Text col = it.next();
byte val[] = curVals.get(col);
@ -635,7 +635,7 @@ public class TestHRegion extends TestCase {
HStoreKey curKey = new HStoreKey();
TreeMap<Text, byte[]> curVals = new TreeMap<Text, byte[]>();
while(s.next(curKey, curVals)) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext(); ) {
for(Iterator<Text> it = curVals.keySet().iterator(); it.hasNext();) {
it.next();
fetched++;
}
@ -650,7 +650,7 @@ public class TestHRegion extends TestCase {
private static void deleteFile(File f) {
if(f.isDirectory()) {
if (f.isDirectory()) {
File[] children = f.listFiles();
for(int i = 0; i < children.length; i++) {
deleteFile(children[i]);
@ -660,7 +660,7 @@ public class TestHRegion extends TestCase {
}
public void testCleanup() throws IOException {
if(!initialized) {
if (!initialized) {
throw new IllegalStateException();
}