Révision 2430
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 2430) | ||
|---|---|---|
| 120 | 120 |
|
| 121 | 121 |
|
| 122 | 122 |
/** |
| 123 |
* Instantiates a new partition.
|
|
| 123 |
* Computes the Partition using a list of queries.
|
|
| 124 | 124 |
* |
| 125 | 125 |
* @param corpus the corpus |
| 126 | 126 |
* @param name the name |
| ... | ... | |
| 137 | 137 |
Log.fine(NLS.bind(SearchEngineCoreMessages.info_creatingNewPartition, this.getParent(), this.userName)); |
| 138 | 138 |
long start = System.currentTimeMillis(); |
| 139 | 139 |
|
| 140 |
if (monitor != null) monitor.beginTask("Building parts...", pQueries.size());
|
|
| 140 |
this.beginTask("Building parts...", pQueries.size());
|
|
| 141 | 141 |
|
| 142 | 142 |
for (int i = 0; i < pQueries.size(); i++) {
|
| 143 | 143 |
String queryS = pQueries.get(i); |
| ... | ... | |
| 150 | 150 |
partName = "-"; //$NON-NLS-1$ |
| 151 | 151 |
} |
| 152 | 152 |
new Part(this, partName, queryS); |
| 153 |
if (monitor != null) monitor.worked(1); |
|
| 153 |
|
|
| 154 |
this.worked(1); |
|
| 154 | 155 |
} |
| 155 | 156 |
long end = System.currentTimeMillis(); |
| 156 | 157 |
Log.fine(NLS.bind(SearchEngineCoreMessages.info_partitionCreatedInXMs, this.userName, (end - start))); |
| ... | ... | |
| 253 | 254 |
@Override |
| 254 | 255 |
protected boolean _compute() throws Exception {
|
| 255 | 256 |
|
| 256 |
// Parts already created |
|
| 257 |
// Parts already created but not computed |
|
| 258 |
// This case happens at TXM start, when Parts have not been yet computed |
|
| 259 |
// FIXME: SJ: problem, this code is executed and THEN Partition.compute() calls again Part.compute() of all its children |
|
| 260 |
// FIXME: SJ: need to remove this code, the compute of children should not be done here |
|
| 257 | 261 |
if (this.getParts().size() > 0) {
|
| 258 | 262 |
|
| 259 |
if (monitor != null) monitor.beginTask("Building parts...", this.getParts().size());
|
|
| 263 |
this.beginTask("Building partition parts...", this.getParts().size());
|
|
| 264 |
Log.info("Building partition parts...");
|
|
| 265 |
|
|
| 260 | 266 |
// FIXME: temporary fix, compute all the children parts |
| 261 | 267 |
List<Part> parts = (List<Part>) getChildren(Part.class); |
| 262 | 268 |
for (int i = 0; i < parts.size(); i++) {
|
| 269 |
this.worked(1); |
|
| 263 | 270 |
parts.get(i).compute(); |
| 264 |
if (monitor != null) monitor.worked(1); |
|
| 265 | 271 |
} |
| 266 | 272 |
} |
| 267 | 273 |
else {
|
| ... | ... | |
| 274 | 280 |
_compute_with_lists(); |
| 275 | 281 |
} |
| 276 | 282 |
} |
| 277 |
totalsize = -1; // refresh total size at next call of getTotalSize |
|
| 283 |
this.totalsize = -1; // refresh total size at next call of getTotalSize
|
|
| 278 | 284 |
return true; |
| 279 | 285 |
} |
| 280 | 286 |
|
| 281 |
/* |
|
| 282 |
* (non-Javadoc) |
|
| 283 |
* @see org.txm.objects.TxmObject#load() |
|
| 284 |
*/ |
|
| 285 |
protected boolean _load(Element e) {
|
|
| 286 |
|
|
| 287 |
// partition already computed |
|
| 288 |
if (this.hasBeenComputedOnce) {
|
|
| 289 |
return true; |
|
| 290 |
} |
|
| 291 |
|
|
| 292 |
if (e != null && this.getParent() != null) {
|
|
| 293 |
NodeList partList = e.getChildNodes(); |
|
| 294 |
for (int i = 0; i < partList.getLength(); i++) {
|
|
| 295 |
if (partList.item(i).getNodeType() == 1) {
|
|
| 296 |
Element c = (Element) partList.item(i); |
|
| 297 |
if (c.getNodeName().equals("part")) { //$NON-NLS-1$
|
|
| 298 |
String pname = c.getAttribute("name"); //$NON-NLS-1$
|
|
| 299 |
String pshortname = c.getAttribute("shortname"); //$NON-NLS-1$
|
|
| 300 |
String pquery = c.getAttribute("query"); //$NON-NLS-1$
|
|
| 301 |
for (Part part : getParts()) {
|
|
| 302 |
if (part.getName().equals(pname)) {
|
|
| 303 |
part.setName(pname); |
|
| 304 |
part.setQuery(new CQLQuery(pquery)); |
|
| 305 |
} |
|
| 306 |
} |
|
| 307 |
} |
|
| 308 |
} |
|
| 309 |
} |
|
| 310 |
// this.loadMetadata(); |
|
| 311 |
return true; |
|
| 312 |
} |
|
| 313 |
|
|
| 314 |
return false; |
|
| 315 |
} |
|
| 316 | 287 |
|
| 317 | 288 |
@Override |
| 318 | 289 |
public boolean canCompute() {
|
| ... | ... | |
| 378 | 349 |
// } |
| 379 | 350 |
|
| 380 | 351 |
|
| 352 |
/* |
|
| 353 |
* (non-Javadoc) |
|
| 354 |
* @see org.txm.objects.TxmObject#load() |
|
| 355 |
*/ |
|
| 356 |
protected boolean _load(Element e) {
|
|
| 357 |
|
|
| 358 |
// partition already computed |
|
| 359 |
if (this.hasBeenComputedOnce) {
|
|
| 360 |
return true; |
|
| 361 |
} |
|
| 362 |
|
|
| 363 |
if (e != null && this.getParent() != null) {
|
|
| 364 |
NodeList partList = e.getChildNodes(); |
|
| 365 |
for (int i = 0; i < partList.getLength(); i++) {
|
|
| 366 |
if (partList.item(i).getNodeType() == 1) {
|
|
| 367 |
Element c = (Element) partList.item(i); |
|
| 368 |
if (c.getNodeName().equals("part")) { //$NON-NLS-1$
|
|
| 369 |
String pname = c.getAttribute("name"); //$NON-NLS-1$
|
|
| 370 |
String pshortname = c.getAttribute("shortname"); //$NON-NLS-1$
|
|
| 371 |
String pquery = c.getAttribute("query"); //$NON-NLS-1$
|
|
| 372 |
for (Part part : getParts()) {
|
|
| 373 |
if (part.getName().equals(pname)) {
|
|
| 374 |
part.setName(pname); |
|
| 375 |
part.setQuery(new CQLQuery(pquery)); |
|
| 376 |
} |
|
| 377 |
} |
|
| 378 |
} |
|
| 379 |
} |
|
| 380 |
} |
|
| 381 |
// this.loadMetadata(); |
|
| 382 |
return true; |
|
| 383 |
} |
|
| 384 |
|
|
| 385 |
return false; |
|
| 386 |
} |
|
| 387 |
|
|
| 388 |
|
|
| 381 | 389 |
@Override |
| 382 | 390 |
public String getDetails() {
|
| 383 | 391 |
return this.getName(); |
Formats disponibles : Unified diff