Skip to content

Commit 5f4f7a8

Browse files
authored
Merge pull request #1624 from marklogic/release/6.4.1
Merge release/6.4.1 into master
2 parents 045acdc + 843e59c commit 5f4f7a8

File tree

10 files changed

+123
-68
lines changed

10 files changed

+123
-68
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=com.marklogic
2-
version=6.4.0
2+
version=6.4.1
33
describedName=MarkLogic Java Client API
44
publishUrl=file:../marklogic-java/releases
55

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.marklogic.client.fastfunctest;
2+
3+
import com.marklogic.client.document.GenericDocumentManager;
4+
import com.marklogic.client.io.SearchHandle;
5+
import com.marklogic.client.query.QueryManager;
6+
import com.marklogic.client.query.StructuredQueryDefinition;
7+
import org.junit.jupiter.api.Test;
8+
9+
import static org.junit.jupiter.api.Assertions.assertEquals;
10+
11+
/**
12+
* Added in 6.4.1; the 3 methods being tested had been commented out with a comment indicating that the server APIs
13+
* were not fully fleshed out, but those APIs - specifically, how the REST API receives a server timestamp - have long
14+
* been present in the REST API.
15+
*/
16+
public class ReadAndSearchWithTimestampTest extends AbstractFunctionalTest {
17+
18+
@Test
19+
void test() {
20+
final String collection = "timestamp-test";
21+
final String[] uris = writeJsonDocs(2, collection).toArray(new String[]{});
22+
23+
final QueryManager queryManager = client.newQueryManager();
24+
final GenericDocumentManager docManager = client.newDocumentManager();
25+
final StructuredQueryDefinition collectionQuery = queryManager.newStructuredQueryBuilder().collection(collection);
26+
27+
SearchHandle searchResults = queryManager.search(collectionQuery, new SearchHandle());
28+
assertEquals(2, searchResults.getTotalResults());
29+
final long serverTimestamp = searchResults.getServerTimestamp();
30+
logger.info("Server timestamp: " + serverTimestamp);
31+
32+
// Write additional docs to the same collection and verify they are not returned by subsequent point-in-time
33+
// queries. Note that the first 2 URIs are the same as the ones originally written.
34+
writeJsonDocs(5, collection);
35+
36+
// Verify each of the exposed methods in 6.4.1
37+
assertEquals(2, docManager.read(serverTimestamp, uris).size());
38+
assertEquals(2, docManager.read(serverTimestamp, null, uris).size());
39+
assertEquals(2, docManager.search(collectionQuery, 1, serverTimestamp).size());
40+
41+
assertEquals(5, docManager.search(collectionQuery, 1).size(),
42+
"A query without a timestamp should return all of the documents in the collection.");
43+
}
44+
}

marklogic-client-api/src/main/java/com/marklogic/client/document/DocumentManager.java

+3-41
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,9 @@ <T extends R> T read(DocumentDescriptor desc, DocumentMetadataReadHandle metadat
463463
* server via getServerTimestamp() on any handle.
464464
* @param uris the database uris identifying documents to retrieve
465465
* @return the DocumentPage of matching documents and metadata
466+
* @since 6.4.1
466467
*/
467-
/* Hide the following for now because the API isn't yet fully fleshed-out
468468
DocumentPage read(long serverTimestamp, String... uris);
469-
*/
470469

471470
/**
472471
* Reads from the database a list of documents matching the provided uris. Allows
@@ -492,10 +491,9 @@ <T extends R> T read(DocumentDescriptor desc, DocumentMetadataReadHandle metadat
492491
* @param transform the transform to be run on the server on each document (must already be installed)
493492
* @param uris the database uris identifying documents to retrieve
494493
* @return the DocumentPage of matching documents and metadata
494+
* @since 6.4.1
495495
*/
496-
/* Hide the following for now because the API isn't yet fully fleshed-out
497496
DocumentPage read(long serverTimestamp, ServerTransform transform, String... uris);
498-
*/
499497

500498
/**
501499
* Reads from the database a list of documents matching the provided uris. Allows
@@ -509,23 +507,6 @@ <T extends R> T read(DocumentDescriptor desc, DocumentMetadataReadHandle metadat
509507
*/
510508
DocumentPage read(Transaction transaction, String... uris);
511509

512-
/**
513-
* Reads from the database a list of documents matching the provided uris. Allows
514-
* iteration across matching documents and metadata (only if setMetadataCategories
515-
* has been called to request metadata). To find out how many of your uris matched,
516-
* call the {@link DocumentPage#size() DocumentPage.size()} method.
517-
*
518-
* @param serverTimestamp the point in time at which to read these
519-
* documents. The value must be a merge timestamp obtained from the
520-
* server via getServerTimestamp() on any handle.
521-
* @param transaction the transaction in which this read is participating
522-
* @param uris the database uris identifying documents to retrieve
523-
* @return the DocumentPage of matching documents and metadata
524-
*/
525-
/* Hide the following for now because the API isn't yet fully fleshed-out
526-
DocumentPage read(long serverTimestamp, Transaction transaction, String... uris);
527-
*/
528-
529510
/**
530511
* Reads from the database a list of documents matching the provided uris. Allows
531512
* iteration across matching documents and metadata (only if setMetadataCategories
@@ -539,24 +520,6 @@ <T extends R> T read(DocumentDescriptor desc, DocumentMetadataReadHandle metadat
539520
*/
540521
DocumentPage read(ServerTransform transform, Transaction transaction, String... uris);
541522

542-
/**
543-
* Reads from the database a list of documents matching the provided uris. Allows
544-
* iteration across matching documents and metadata (only if setMetadataCategories
545-
* has been called to request metadata). To find out how many of your uris matched,
546-
* call the {@link DocumentPage#size() DocumentPage.size()} method.
547-
*
548-
* @param serverTimestamp the point in time at which to read these
549-
* documents. The value must be a merge timestamp obtained from the
550-
* server via getServerTimestamp() on any handle.
551-
* @param transform the transform to be run on the server on each document (must already be installed)
552-
* @param transaction the transaction in which this read is participating
553-
* @param uris the database uris identifying documents to retrieve
554-
* @return the DocumentPage of matching documents and metadata
555-
*/
556-
/* Hide the following for now because the API isn't yet fully fleshed-out
557-
DocumentPage read(long serverTimestamp, ServerTransform transform, Transaction transaction, String... uris);
558-
*/
559-
560523
/**
561524
* Reads from the database the metadata for a list of documents matching the
562525
* provided uris. Allows iteration across the metadata for matching documents
@@ -619,10 +582,9 @@ <T extends R> T read(DocumentDescriptor desc, DocumentMetadataReadHandle metadat
619582
* documents. The value must be a merge timestamp obtained from the
620583
* server via getServerTimestamp() on any handle.
621584
* @return the DocumentPage of matching documents and metadata
585+
* @since 6.4.1
622586
*/
623-
/* Hide the following for now because the API isn't yet fully fleshed-out
624587
DocumentPage search(SearchQueryDefinition querydef, long start, long serverTimestamp);
625-
*/
626588

627589
/**
628590
* Just like {@link QueryManager#search(SearchQueryDefinition, SearchReadHandle, long, Transaction) QueryManager.search}

marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ private void addCategoryParams(Set<Metadata> categories, RequestParameters param
16271627
}
16281628
}
16291629
private void addCategoryParam(RequestParameters params, Metadata category) {
1630-
addCategoryParam(params, category.name().toLowerCase());
1630+
addCategoryParam(params, category.toString().toLowerCase());
16311631
}
16321632
private void addCategoryParam(RequestParameters params, String category) {
16331633
params.add("category", category);

marklogic-client-api/src/test/java/com/marklogic/client/test/StringSearchTest.java

+24-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
import com.marklogic.client.ResourceNotFoundException;
2121
import com.marklogic.client.ResourceNotResendableException;
2222
import com.marklogic.client.admin.QueryOptionsManager;
23+
import com.marklogic.client.document.DocumentManager;
24+
import com.marklogic.client.document.DocumentPage;
25+
import com.marklogic.client.document.DocumentRecord;
26+
import com.marklogic.client.document.XMLDocumentManager;
2327
import com.marklogic.client.io.DocumentMetadataHandle;
2428
import com.marklogic.client.io.Format;
2529
import com.marklogic.client.io.SearchHandle;
@@ -32,17 +36,15 @@
3236
import org.junit.jupiter.api.Test;
3337
import org.slf4j.Logger;
3438
import org.slf4j.LoggerFactory;
35-
import org.xml.sax.SAXException;
3639

37-
import javax.xml.parsers.ParserConfigurationException;
3840
import java.io.ByteArrayOutputStream;
3941
import java.io.IOException;
4042

4143
import static org.junit.jupiter.api.Assertions.*;
4244

4345
public class StringSearchTest {
4446
@SuppressWarnings("unused")
45-
private static final Logger logger = (Logger) LoggerFactory.getLogger(StringSearchTest.class);
47+
private static final Logger logger = LoggerFactory.getLogger(StringSearchTest.class);
4648

4749
@BeforeAll
4850
public static void beforeClass() {
@@ -54,9 +56,27 @@ public static void beforeClass() {
5456
public static void afterClass() {
5557
}
5658

59+
@Test
60+
void returnDocumentsWithMetadataValues() {
61+
XMLDocumentManager mgr = Common.client.newXMLDocumentManager();
62+
mgr.write("/metadata/test.xml",
63+
new DocumentMetadataHandle().withMetadataValue("hello", "world"),
64+
new StringHandle("<test>metadataabc</test>"));
65+
66+
mgr.setMetadataCategories(DocumentManager.Metadata.METADATAVALUES);
67+
68+
DocumentPage page = mgr.search(Common.client.newQueryManager().newStructuredQueryBuilder().term("metadataabc"), 1);
69+
assertTrue(page.hasNext());
70+
71+
DocumentRecord record = page.next();
72+
assertEquals("/metadata/test.xml", record.getUri());
73+
DocumentMetadataHandle.DocumentMetadataValues values = record.getMetadata(new DocumentMetadataHandle()).getMetadataValues();
74+
assertEquals("world", values.get("hello"));
75+
}
76+
5777
@Test
5878
public void testStringSearch()
59-
throws IOException, ParserConfigurationException, SAXException, FailedRequestException, ForbiddenUserException,
79+
throws FailedRequestException, ForbiddenUserException,
6080
ResourceNotFoundException, ResourceNotResendableException
6181
{
6282
String optionsName = writeOptions();

marklogic-client-api/src/test/java/com/marklogic/client/test/rows/ExportTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void fromSparql() {
8686
@Test
8787
public void fromSql() {
8888
verifyExportedPlanReturnsSameRowCount(
89-
op.fromSql("select * from opticUnitTest.musician")
89+
op.fromSql("select * from opticUnitTest.musician_ml10")
9090
);
9191
}
9292

@@ -103,7 +103,7 @@ public void fromTriples() {
103103
@Test
104104
public void fromView() {
105105
verifyExportedPlanReturnsSameRowCount(
106-
op.fromView("opticUnitTest", "musician"), null
106+
op.fromView("opticUnitTest", "musician_ml10"), null
107107
);
108108
}
109109

marklogic-client-api/src/test/java/com/marklogic/client/test/rows/ResultRowsWithTimestampTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void deleteNewMusician() {
3232

3333
@Test
3434
void testResultRowsWithPointInTimeQueryTimestamp() {
35-
final RawQueryDSLPlan plan = rowManager.newRawQueryDSLPlan(new StringHandle("op.fromView('opticUnitTest', 'musician')"));
35+
final RawQueryDSLPlan plan = rowManager.newRawQueryDSLPlan(new StringHandle("op.fromView('opticUnitTest', 'musician_ml10')"));
3636

3737
JacksonHandle result = new JacksonHandle();
3838
JsonNode doc = rowManager.resultDoc(plan, result).get();

marklogic-client-api/src/test/java/com/marklogic/client/test/rows/RowManagerTest.java

+18-16
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public class RowManagerTest {
6868
private static RowStructure[] rowstructs = null;
6969
private static RowSetPart[] datatypeStyles = null;
7070

71+
private final static String VIEW_NAME = "musician_ml10";
72+
7173
@SuppressWarnings("unchecked")
7274
@BeforeAll
7375
public static void beforeClass() throws IOException, InterruptedException {
@@ -452,7 +454,7 @@ public void testView() {
452454
PlanBuilder p = rowMgr.newPlanBuilder();
453455

454456
PlanBuilder.ExportablePlan builtPlan =
455-
p.fromView("opticUnitTest", "musician")
457+
p.fromView("opticUnitTest", VIEW_NAME)
456458
.where(
457459
p.cts.andQuery(
458460
p.cts.jsonPropertyWordQuery("instrument", "trumpet"),
@@ -484,7 +486,7 @@ public void testSQL() {
484486
RowManager rowMgr = Common.client.newRowManager();
485487
PlanBuilder p = rowMgr.newPlanBuilder();
486488
PlanBuilder.ExportablePlan builtPlan =
487-
p.fromSql("select * from opticUnitTest.musician");
489+
p.fromSql("select * from opticUnitTest.musician_ml10");
488490
int rowNum = 0;
489491
String exception = "";
490492
try {
@@ -503,7 +505,7 @@ public void testSQL0Result() {
503505
RowManager rowMgr = Common.client.newRowManager();
504506
PlanBuilder p = rowMgr.newPlanBuilder();
505507
PlanBuilder.ExportablePlan builtPlan =
506-
p.fromSql("select * from opticUnitTest.musician where lastName = 'x'");
508+
p.fromSql("select * from opticUnitTest.musician_ml10 where lastName = 'x'");
507509
int rowNum = 0;
508510
String exception = "";
509511
try {
@@ -564,7 +566,7 @@ public void testSearch() {
564566
PlanBuilder.ExportablePlan builtPlan =
565567
p.fromSearch(p.cts.jsonPropertyValueQuery("instrument", "trumpet"))
566568
.joinInner(
567-
p.fromView("opticUnitTest", "musician", "", viewDocId),
569+
p.fromView("opticUnitTest", VIEW_NAME, "", viewDocId),
568570
p.on(p.fragmentIdCol("fragmentId"), viewDocId)
569571
)
570572
.orderBy(p.col("lastName"));
@@ -623,7 +625,7 @@ public void testJoinSrcDoc() throws IOException {
623625
PlanBuilder p = rowMgr.newPlanBuilder();
624626

625627
PlanBuilder.ExportablePlan builtPlan =
626-
p.fromView("opticUnitTest", "musician", "", p.fragmentIdCol("musicianDocId"))
628+
p.fromView("opticUnitTest", VIEW_NAME, "", p.fragmentIdCol("musicianDocId"))
627629
.joinDoc(p.col("musicianDoc"), p.fragmentIdCol("musicianDocId"))
628630
.orderBy(p.col("lastName"))
629631
.select(
@@ -654,7 +656,7 @@ public void testJoinDocUri() throws IOException {
654656
PlanBuilder p = rowMgr.newPlanBuilder();
655657

656658
PlanBuilder.ExportablePlan builtPlan =
657-
p.fromView("opticUnitTest", "musician", "", p.fragmentIdCol("musicianDocId"))
659+
p.fromView("opticUnitTest", VIEW_NAME, "", p.fragmentIdCol("musicianDocId"))
658660
.joinDocUri(p.col("musicianDocUri"), p.fragmentIdCol("musicianDocId"))
659661
.orderBy(p.col("lastName"))
660662
.select(p.col("lastName"), p.col("firstName"), p.col("musicianDocUri"))
@@ -1286,7 +1288,7 @@ public void testColumnInfo() {
12861288
RowManager rowMgr = Common.client.newRowManager();
12871289
PlanBuilder p = rowMgr.newPlanBuilder();
12881290
PlanBuilder.PreparePlan builtPlan =
1289-
p.fromView("opticUnitTest", "musician")
1291+
p.fromView("opticUnitTest", VIEW_NAME)
12901292
.where(
12911293
p.cts.andQuery(
12921294
p.cts.jsonPropertyWordQuery("instrument", "trumpet"),
@@ -1296,10 +1298,10 @@ public void testColumnInfo() {
12961298
.orderBy(p.col("lastName"));
12971299

12981300
String[] expectedColumnInfos = new String[]{
1299-
"{\"schema\":\"opticUnitTest\", \"view\":\"musician\", \"column\":\"lastName\", \"type\":\"string\"",
1300-
"{\"schema\":\"opticUnitTest\", \"view\":\"musician\", \"column\":\"firstName\", \"type\":\"string\"",
1301-
"{\"schema\":\"opticUnitTest\", \"view\":\"musician\", \"column\":\"dob\", \"type\":\"date\"",
1302-
"{\"schema\":\"opticUnitTest\", \"view\":\"musician\", \"column\":\"rowid\", \"type\":\"rowid\""
1301+
"{\"schema\":\"opticUnitTest\", \"view\":\"musician_ml10\", \"column\":\"lastName\", \"type\":\"string\"",
1302+
"{\"schema\":\"opticUnitTest\", \"view\":\"musician_ml10\", \"column\":\"firstName\", \"type\":\"string\"",
1303+
"{\"schema\":\"opticUnitTest\", \"view\":\"musician_ml10\", \"column\":\"dob\", \"type\":\"date\"",
1304+
"{\"schema\":\"opticUnitTest\", \"view\":\"musician_ml10\", \"column\":\"rowid\", \"type\":\"rowid\""
13031305
};
13041306

13051307
String stringHandleResult = rowMgr.columnInfo(builtPlan, new StringHandle()).get();
@@ -1317,7 +1319,7 @@ public void testGenerateView() throws IOException {
13171319
PlanBuilder p = rowMgr.newPlanBuilder();
13181320

13191321
PlanBuilder.PreparePlan builtPlan =
1320-
p.fromView("opticUnitTest", "musician")
1322+
p.fromView("opticUnitTest", VIEW_NAME)
13211323
.where(
13221324
p.cts.andQuery(
13231325
p.cts.jsonPropertyWordQuery("instrument", "trumpet"),
@@ -1363,7 +1365,7 @@ private DOMHandle initNamespaces(DOMHandle handle) {
13631365
@Test
13641366
public void testRawSQL() throws IOException {
13651367
String plan = "SELECT *\n" +
1366-
"FROM opticUnitTest.musician AS ''\n" +
1368+
"FROM opticUnitTest.musician_ml10 AS ''\n" +
13671369
"WHERE lastName IN ('Armstrong', 'Davis')" +
13681370
"ORDER BY lastName;\n";
13691371

@@ -1404,7 +1406,7 @@ public void testRawSPARQLSelect() throws IOException {
14041406
@Test
14051407
public void testRawQueryDSL() throws IOException {
14061408
String plan =
1407-
"op.fromView('opticUnitTest', 'musician')\n" +
1409+
"op.fromView('opticUnitTest', 'musician_ml10')\n" +
14081410
" .where(cts.andQuery([\n"+
14091411
" cts.jsonPropertyWordQuery('instrument', 'trumpet'),\n"+
14101412
" cts.jsonPropertyWordQuery('lastName', ['Armstrong', 'Davis'])\n"+
@@ -1447,7 +1449,7 @@ public void testSampleBy() throws IOException {
14471449
PlanSampleByOptions options = p.sampleByOptions().withLimit(2);
14481450

14491451
PlanBuilder.ExportablePlan builtPlan =
1450-
p.fromView("opticUnitTest", "musician")
1452+
p.fromView("opticUnitTest", VIEW_NAME)
14511453
.sampleBy(options);
14521454

14531455
RowSet<RowRecord> rows = rowMgr.resultRows(builtPlan);
@@ -1461,7 +1463,7 @@ public void testSampleByNoArg() throws IOException {
14611463
PlanBuilder p = rowMgr.newPlanBuilder();
14621464

14631465
PlanBuilder.ExportablePlan builtPlan =
1464-
p.fromView("opticUnitTest", "musician")
1466+
p.fromView("opticUnitTest", VIEW_NAME)
14651467
.sampleBy();
14661468

14671469
RowSet<RowRecord> rows = rowMgr.resultRows(builtPlan);

marklogic-client-api/src/test/java/com/marklogic/client/test/rows/RowRecordTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public void testDatatypeRoundtrip() throws Exception {
257257
@Test
258258
public void aliasTest() throws IOException {
259259
PlanBuilder.ModifyPlan plan =
260-
p.fromView("opticUnitTest", "musician")
260+
p.fromView("opticUnitTest", "musician_ml10")
261261
.orderBy(p.col("lastName"))
262262
.limit(1);
263263

@@ -267,7 +267,7 @@ public void aliasTest() throws IOException {
267267

268268
RowRecord row = rowItr.next();
269269

270-
for (String colName: new String[]{"opticUnitTest.musician.lastName", "musician.lastName", "lastName"}) {
270+
for (String colName: new String[]{"opticUnitTest.musician_ml10.lastName", "musician_ml10.lastName", "lastName"}) {
271271
RowRecord.ColumnKind expectedKind = RowRecord.ColumnKind.ATOMIC_VALUE;
272272
RowRecord.ColumnKind actualKind = row.getKind(colName);
273273
assertEquals(expectedKind, actualKind);

0 commit comments

Comments
 (0)