Skip to content

Commit

Permalink
fixed #159
Browse files Browse the repository at this point in the history
  • Loading branch information
dsukhoroslov committed Mar 11, 2018
1 parent 3f01ef2 commit 3213214
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bagri-distr/src/main/resources/test/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@
<entry name="bdb.schema.dict.backup.sync">0</entry>
<entry name="bdb.schema.trans.backup.sync">1</entry>
<entry name="bdb.schema.query.backup.sync">0</entry>
<entry name="bdb.schema.buffer.size">16</entry>
<entry name="bdb.schema.buffer.size">128</entry>
<entry name="bdb.schema.dict.backup.async">1</entry>
<entry name="bdb.schema.dict.backup.read">true</entry>
<entry name="bdb.schema.trans.backup.read">false</entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,17 @@ public DocumentKey getLastRevisionKeyForUri(String uri) {
Query query = new Query(CN_XDM_DOCUMENT, Predicates.equal("__key#hash", hash), IterationType.ENTRY, null, null);
DocumentKey last = null;
boolean foundUri = false;
int partId = getPartitionId(hash);

QueryResult rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_DOCUMENT).runPartitionIndexOrPartitionScanQueryOnGivenOwnedPartition(query, partId);
// this one just scans partition, it does not use index
//QueryResult rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_DOCUMENT).runPartitionIndexOrPartitionScanQueryOnGivenOwnedPartition(query, partId);
QueryResult rs;
try {
rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_DOCUMENT).runIndexOrPartitionScanQueryOnOwnedPartitions(query);
} catch (ExecutionException | InterruptedException ex) {
logger.error("getLastKeyForUri.error: ", ex);
return null;
}

for (QueryResultRow row: rs.getRows()) {
DocumentKey key = nodeEngine.toObject(row.getKey());
Document doc = nodeEngine.toObject(row.getValue());
Expand Down Expand Up @@ -231,7 +239,7 @@ public DocumentKey getLastRevisionKeyForUri(String uri) {
if (!foundUri && last != null) {
last = factory.newDocumentKey(uri, last.getRevision() + 1, dvFirst);
}

logger.trace("getLastRevisionKeyForUri; uri: {}; returning: {}", uri, last);
return last;
}
Expand All @@ -240,8 +248,8 @@ public DocumentKey getLastKeyForUri(String uri) {
MapService svc = nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext mapCtx = svc.getMapServiceContext();
Query query = new Query(CN_XDM_DOCUMENT, Predicates.equal("uri", uri), IterationType.KEY, null, null);
DocumentKey last = null;
try {
DocumentKey last = null;
QueryResult rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_DOCUMENT).runIndexOrPartitionScanQueryOnOwnedPartitions(query);
for (QueryResultRow row: rs.getRows()) {
DocumentKey key = nodeEngine.toObject(row.getKey());
Expand All @@ -253,12 +261,11 @@ public DocumentKey getLastKeyForUri(String uri) {
}
}
}
logger.trace("getLastKeyForUri; uri: {}; returning: {}", uri, last);
return last;
} catch (ExecutionException | InterruptedException ex) {
logger.error("getLastKeyForUri.error: ", ex);
}
return null;
logger.trace("getLastKeyForUri; uri: {}; returning: {}", uri, last);
return last;
//List<DocumentKey> keys = getCachedObject(CN_XDM_KEY, new UrlHashKey(uri), true);
//if (keys != null) {
// return keys.get(keys.size() - 1);
Expand All @@ -278,12 +285,11 @@ public Collection<DocumentKey> getLastKeysForQuery(Predicate<DocumentKey, Docume
DocumentKey key = nodeEngine.toObject(row.getKey());
results.add(key);
}
logger.trace("getLastKeysForQuery; query: {}; returning: {}", query, results.size());
return results;
} catch (ExecutionException | InterruptedException ex) {
logger.error("getLastDocumentsForQuery.error: ", ex);
}
return null;
logger.trace("getLastKeysForQuery; query: {}; returning: {}", query, results.size());
return results;
}

public Collection<DocumentKey> getLastKeysForQuery(Predicate<DocumentKey, Document> query, int fetchSize) {
Expand Down Expand Up @@ -316,8 +322,8 @@ public Document getLastDocumentForUri(String uri) {
MapService svc = nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext mapCtx = svc.getMapServiceContext();
Query query = new Query(CN_XDM_DOCUMENT, Predicates.equal("uri", uri), IterationType.VALUE, null, null);
Document last = null;
try {
Document last = null;
QueryResult rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_DOCUMENT).runIndexOrPartitionScanQueryOnOwnedPartitions(query);
for (QueryResultRow row: rs.getRows()) {
Document doc = nodeEngine.toObject(row.getValue());
Expand All @@ -329,12 +335,11 @@ public Document getLastDocumentForUri(String uri) {
}
}
}
logger.trace("getLastDocumentForUri; uri: {}; returning: {}", uri, last);
return last;
} catch (ExecutionException | InterruptedException ex) {
logger.error("getLastDocumentForUri.error: ", ex);
}
return null;
logger.trace("getLastDocumentForUri; uri: {}; returning: {}", uri, last);
return last;
}

public Collection<Document> getLastDocumentsForQuery(Predicate<DocumentKey, Document> query) {
Expand All @@ -351,12 +356,11 @@ public Collection<Document> getLastDocumentsForQuery(Predicate<DocumentKey, Docu
results.put(doc.getUri(), doc);
//}
}
logger.trace("getLastDocumentsForQuery; returning: {}", results.size());
return results.values();
} catch (ExecutionException | InterruptedException ex) {
logger.error("getLastDocumentsForQuery.error: ", ex);
}
return null;
logger.trace("getLastDocumentsForQuery; returning: {}", results.size());
return results.values();
}

public Collection<Document> getLastDocumentsForQuery(Predicate<DocumentKey, Document> query, int fetchSize) {
Expand Down Expand Up @@ -394,7 +398,6 @@ public Collection<DataKey> getElementKeys(long docId) {
for (QueryResultRow row: rs.getRows()) {
result.add((DataKey) nodeEngine.toObject(row.getKey()));
}
return result;
} catch (ExecutionException | InterruptedException ex) {
logger.error("getElementKeys.error", ex);
}
Expand All @@ -412,7 +415,6 @@ public Map<DataKey, Elements> getElements(long docId) {
for (QueryResultRow row: rs.getRows()) {
result.put((DataKey) nodeEngine.toObject(row.getKey()), (Elements) nodeEngine.toObject(row.getValue()));
}
return result;
} catch (ExecutionException | InterruptedException ex) {
logger.error("getElementKeys.error", ex);
}
Expand Down

0 comments on commit 3213214

Please sign in to comment.