public LinkFileWriter(Writer out, Configuration config) { this.out = out; if (config != null) this.idprops = config.getIdentityProperties(); }
protected void indexById(Record record) { for (Property idprop : config.getIdentityProperties()) for (String id : record.getValues(idprop.getName())) idmap.put(id, record); }
/** * Add the record to the index. */ public void index(Record record) { for (Property p : config.getIdentityProperties()) { Collection<String> values = record.getValues(p.getName()); if (values == null) continue; for (String id : values) idindex.put(id, record); } records.add(record); }
private String getId(Record r) { for (Property idprop : config.getIdentityProperties()) { String v = r.getValue(idprop.getName()); if (v != null) return v; } return null; }
/** * Look up record by identity. */ public Record findRecordById(String id) { if (directory == null) init(); Property idprop = config.getIdentityProperties().iterator().next(); for (Record r : lookup(idprop, id)) if (r.getValue(idprop.getName()).equals(id)) return r; return null; // not found }
private String getIdentity(Record r) { for (Property p : config.getIdentityProperties()) for (String v : r.getValues(p.getName())) return v; throw new RuntimeException("No identity found in record [" + PrintMatchListener.toString(r) + "]"); }
private boolean isSameAs(Record r1, Record r2) { for (Property idp : config.getIdentityProperties()) { Collection<String> vs2 = r2.getValues(idp.getName()); Collection<String> vs1 = r1.getValues(idp.getName()); if (vs1 == null) continue; for (String v1 : vs1) if (vs2.contains(v1)) return true; } return false; }
private void delete(Record record) { // removes previous copy of this record from the index, if it's there Property idprop = config.getIdentityProperties().iterator().next(); Query q = parseTokens(idprop.getName(), record.getValue(idprop.getName())); try { iwriter.deleteDocuments(q); } catch (IOException e) { throw new DukeException(e); } }
private String getIdentity(Record r) { for (Property p : config.getIdentityProperties()) { Collection<String> vs = r.getValues(p.getName()); if (vs == null) continue; for (String v : vs) return v; } throw new DukeException("No identity found in record [" + PrintMatchListener.toString(r) + "]"); }
private void init(LinkDatabase linkdb, Configuration config, boolean debug, Processor processor, boolean showmatches, boolean pretty) { this.golddb = linkdb; this.dukedb = new InMemoryLinkDatabase(); //((InMemoryLinkDatabase) this.dukedb).setDoInference(true); this.idprops = config.getIdentityProperties(); this.props = config.getProperties(); this.debug = debug; this.processor = processor; this.database = processor.getDatabase(); this.linkage = !config.isDeduplicationMode(); this.showmatches = showmatches; this.pretty = pretty; }
.getIdentityProperties(); if (identityProperties == null || identityProperties.size() != 1) { throw new java.lang.IllegalStateException(
public LinkFileWriter(Writer out, Configuration config) { this.out = out; if (config != null) this.idprops = config.getIdentityProperties(); }
/** * Add the record to the index. */ public void index(Record record) { // FIXME: check if record is already indexed // allocate an ID for this record long id = store.makeNewRecordId(); store.registerRecord(id, record); // go through ID properties and register them for (Property p : config.getIdentityProperties()) for (String extid : record.getValues(p.getName())) store.registerId(id, extid); // go through lookup properties and register those for (Property p : config.getLookupProperties()) { String propname = p.getName(); for (String value : record.getValues(propname)) { String[] tokens = StringUtils.split(value); for (int ix = 0; ix < tokens.length; ix++) store.registerToken(id, propname, tokens[ix]); } } }
String fname = parser.getOptionValue("linkfile"); if (fname.endsWith(".ntriples")) linkfile = new NTriplesLinkFileListener(fname, config.getIdentityProperties()); else linkfile = new LinkFileListener(fname, config.getIdentityProperties(), interactive, parser.getOptionValue("testfile"));
protected void indexById(Record record) { for (Property idprop : config.getIdentityProperties()) for (String id : record.getValues(idprop.getName())) idmap.put(id, record); }
private String getId(Record r) { for (Property idprop : config.getIdentityProperties()) { String v = r.getValue(idprop.getName()); if (v != null) return v; } return null; }
/** * Look up record by identity. */ public Record findRecordById(String id) { if (directory == null) init(); Property idprop = config.getIdentityProperties().iterator().next(); for (Record r : lookup(idprop, id)) if (r.getValue(idprop.getName()).equals(id)) return r; return null; // not found }
private String getIdentity(Record r) { for (Property p : config.getIdentityProperties()) for (String v : r.getValues(p.getName())) return v; throw new RuntimeException("No identity found in record [" + PrintMatchListener.toString(r) + "]"); }
private void delete(Record record) { // removes previous copy of this record from the index, if it's there Property idprop = config.getIdentityProperties().iterator().next(); Query q = parseTokens(idprop.getName(), record.getValue(idprop.getName())); try { iwriter.deleteDocuments(q); } catch (IOException e) { throw new DukeException(e); } }
private String getIdentity(Record r) { for (Property p : config.getIdentityProperties()) { Collection<String> vs = r.getValues(p.getName()); if (vs == null) continue; for (String v : vs) return v; } throw new DukeException("No identity found in record [" + PrintMatchListener.toString(r) + "]"); }