Skip to content

Commit f39960f

Browse files
#914 - Moved to datamovement package from example package
1 parent f0fc88f commit f39960f

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed
Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package com.marklogic.client.example.cookbook.datamovement;
16+
package com.marklogic.client.datamovement;
1717

1818
import java.io.IOException;
1919
import java.util.ArrayList;
@@ -29,10 +29,6 @@
2929
import com.fasterxml.jackson.core.JsonParser;
3030
import com.fasterxml.jackson.core.JsonToken;
3131
import com.marklogic.client.MarkLogicIOException;
32-
import com.marklogic.client.datamovement.BatchFailureListener;
33-
import com.marklogic.client.datamovement.QueryBatchListener;
34-
import com.marklogic.client.datamovement.QueryBatch;
35-
import com.marklogic.client.datamovement.QueryBatcher;
3632
import com.marklogic.client.expression.PlanBuilder;
3733
import com.marklogic.client.io.JacksonParserHandle;
3834
import com.marklogic.client.io.StringHandle;
@@ -54,7 +50,7 @@
5450
* <pre>{@code
5551
* StructuredQueryDefinition query = new StructuredQueryBuilder().directory(1, "/employees/");
5652
* QueryBatcher qb = moveMgr.newQueryBatcher(query)
57-
* .onUrisReady(new ExtractViaTemplateListener().withTemplate(templateUri).onTypedRowReady(row -&gt; {
53+
* .onUrisReady(new ExtractRowsViaTemplateListener().withTemplate(templateUri).onTypedRowReady(row -&gt; {
5854
* System.out.println("row:" + row);
5955
* }));
6056
* moveMgr.startJob(qb);
@@ -85,17 +81,17 @@
8581
* emitted by the rows. Also, the templates should emit only rows and not
8682
* triples.
8783
*/
88-
public class ExtractViaTemplateListener implements QueryBatchListener, AutoCloseable {
84+
public class ExtractRowsViaTemplateListener implements QueryBatchListener, AutoCloseable {
8985
private static Logger logger =
90-
LoggerFactory.getLogger(ExtractViaTemplateListener.class);
86+
LoggerFactory.getLogger(ExtractRowsViaTemplateListener.class);
9187
private List<String> templateUris = new ArrayList<>();
9288
private String templateDb;
9389
private List<Consumer<TypedRow>> rowListeners = new ArrayList<>();
9490
private List<BatchFailureListener<QueryBatch>> failureListeners = new ArrayList<>();
9591
private PlanBuilder pb;
9692

97-
public ExtractViaTemplateListener() {
98-
logger.debug("new ExtractViaTemplateListener - this should print once/job; " +
93+
public ExtractRowsViaTemplateListener() {
94+
logger.debug("new ExtractRowsViaTemplateListener - this should print once/job; " +
9995
"if you see this once/batch, fix your job configuration");
10096
}
10197

@@ -106,12 +102,12 @@ public ExtractViaTemplateListener() {
106102
* @param templateUri the uri of the template to be applied to each batch.
107103
* @return the instance for chaining
108104
*/
109-
public ExtractViaTemplateListener withTemplate(String templateUri) {
105+
public ExtractRowsViaTemplateListener withTemplate(String templateUri) {
110106
this.templateUris.add(templateUri);
111107
return this;
112108
}
113109

114-
private ExtractViaTemplateListener withTemplateDatabase(String templateDatabase) {
110+
private ExtractRowsViaTemplateListener withTemplateDatabase(String templateDatabase) {
115111
this.templateDb = templateDatabase;
116112
return this;
117113
}
@@ -123,7 +119,7 @@ private ExtractViaTemplateListener withTemplateDatabase(String templateDatabase)
123119
* @param listener the listener which needs to be applied to each row
124120
* @return the instance for chaining
125121
*/
126-
public ExtractViaTemplateListener onTypedRowReady(Consumer<TypedRow> listener) {
122+
public ExtractRowsViaTemplateListener onTypedRowReady(Consumer<TypedRow> listener) {
127123
rowListeners.add(listener);
128124
return this;
129125
}
@@ -136,7 +132,7 @@ public ExtractViaTemplateListener onTypedRowReady(Consumer<TypedRow> listener) {
136132
*
137133
* @return this instance for method chaining
138134
*/
139-
public ExtractViaTemplateListener onFailure(BatchFailureListener<QueryBatch> listener) {
135+
public ExtractRowsViaTemplateListener onFailure(BatchFailureListener<QueryBatch> listener) {
140136
failureListeners.add(listener);
141137
return this;
142138
}
@@ -147,7 +143,7 @@ public void initializeListener(QueryBatcher queryBatcher) {
147143
}
148144

149145
/**
150-
* This is the method QueryBatcher calls for ExtractViaTemplateListener to do
146+
* This is the method QueryBatcher calls for ExtractRowsViaTemplateListener to do
151147
* its thing. You should not need to call it.
152148
*
153149
* @param batch the batch of uris and some metadata about the current status
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package com.marklogic.client.example.cookbook.datamovement;
16+
package com.marklogic.client.datamovement;
1717

1818
import java.util.LinkedHashMap;
1919
import com.marklogic.client.type.XsAnyAtomicTypeVal;
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.fasterxml.jackson.core.JsonParser.Feature;
2525
import com.fasterxml.jackson.databind.ObjectMapper;
2626

27+
import com.marklogic.client.datamovement.ExtractRowsViaTemplateListener;
2728
import com.marklogic.client.document.JSONDocumentManager;
2829
import com.marklogic.client.DatabaseClient;
2930
import com.marklogic.client.datamovement.DataMovementManager;
@@ -43,7 +44,7 @@
4344
* to a Tableau TDE (Tableau Data Extract) file.
4445
*
4546
*/
46-
public class ExtractViaTemplate {
47+
public class ExtractRowsViaTemplate {
4748
private static int threadCount = 3;
4849
private static int batchSize = 3;
4950
private String templateUri = "employees.tde";
@@ -57,7 +58,7 @@ public class ExtractViaTemplate {
5758
new SimpleDateFormat("yyyy-MM-dd");
5859

5960
public static void main(String[] args) throws ParseException, IOException {
60-
new ExtractViaTemplate().run();
61+
new ExtractRowsViaTemplate().run();
6162
}
6263

6364
public void run() throws ParseException, IOException {
@@ -67,7 +68,7 @@ public void run() throws ParseException, IOException {
6768
.onUrisReady(
6869
// This object will be closed by the QueryBatcher when stopJob is
6970
// called and hence there won't be a resource leak.
70-
new ExtractViaTemplateListener()
71+
new ExtractRowsViaTemplateListener()
7172
.withTemplate(templateUri)
7273
.onTypedRowReady( row -> {
7374
System.out.println("row:" + row);
@@ -88,7 +89,7 @@ public void run() throws ParseException, IOException {
8889
*
8990
* QueryBatcher qbConsumer = moveMgr.newQueryBatcher(query)
9091
* .onUrisReady(
91-
* new ExtractViaTemplateListener()
92+
* new ExtractRowsViaTemplateListener()
9293
* .withTemplate(templateName)
9394
* .onTypedRowReady(tableauWriter)
9495
* );
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
import org.junit.Test;
1919

20-
import com.marklogic.client.example.cookbook.datamovement.ExtractViaTemplate;
20+
import com.marklogic.client.example.cookbook.datamovement.ExtractRowsViaTemplate;
2121

22-
public class ExtractViaTemplateTest {
22+
public class ExtractRowsViaTemplateTest {
2323
@Test
2424
public void testMain() throws Exception {
25-
ExtractViaTemplate.main(new String[0]);
25+
ExtractRowsViaTemplate.main(new String[0]);
2626
}
2727
}

0 commit comments

Comments
 (0)