Added getStringKey() method for when it is difficult to generate integer keys that don't collide
git-svn-id: http://google-refine.googlecode.com/svn/trunk@2515 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
5dffd249de
commit
4cfb921082
@ -70,8 +70,8 @@ public class GuidBasedReconConfig extends StrictReconConfig {
|
||||
String guid;
|
||||
|
||||
@Override
|
||||
public int getKey() {
|
||||
return guid.hashCode();
|
||||
public String getStringKey() {
|
||||
return guid;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,8 @@ public class IdBasedReconConfig extends StrictReconConfig {
|
||||
String id;
|
||||
|
||||
@Override
|
||||
public int getKey() {
|
||||
return id.hashCode();
|
||||
public String getStringKey() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,8 @@ public class KeyBasedReconConfig extends StrictReconConfig {
|
||||
String key;
|
||||
|
||||
@Override
|
||||
public int getKey() {
|
||||
return key.hashCode();
|
||||
public String getStringKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,5 +34,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
package com.google.refine.model.recon;
|
||||
|
||||
abstract public class ReconJob {
|
||||
abstract public int getKey();
|
||||
public int getKey() {
|
||||
return this.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is added because sometimes it's hard to generate integer keys that
|
||||
* are not prone to collision. If a ReconJob class cannot guarantee no collision of
|
||||
* integer keys, then that class should override this new method.
|
||||
*/
|
||||
public String getStringKey() {
|
||||
return Integer.toString(getKey());
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ public class ReconOperation extends EngineDependentOperation {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
|
||||
Map<Integer, JobGroup> jobKeyToGroup = new HashMap<Integer, JobGroup>();
|
||||
Map<String, JobGroup> jobKeyToGroup = new HashMap<String, JobGroup>();
|
||||
|
||||
for (ReconEntry entry : _entries) {
|
||||
ReconJob job = _reconConfig.createJob(
|
||||
@ -263,7 +263,7 @@ public class ReconOperation extends EngineDependentOperation {
|
||||
entry.cell
|
||||
);
|
||||
|
||||
int key = job.getKey();
|
||||
String key = job.getStringKey();
|
||||
JobGroup group = jobKeyToGroup.get(key);
|
||||
if (group == null) {
|
||||
group = new JobGroup(job);
|
||||
|
Loading…
Reference in New Issue
Block a user