Code Monkey home page Code Monkey logo

ml-javaclient-util-issue-136's Introduction

Build Status

ml-javaclient-util is a library of Java classes that provide some useful functionality on top of the MarkLogic Java Client API. Those features include:

This is a lower-level library that is primarily used via ml-app-deployer and ml-gradle and ml-junit. But you can use it by itself too.

Loading Modules

Here's a sample of loading modules - though it's best to look at the aforementioned projects to see all the ways this can be done:

DatabaseClient client = DatabaseClientFactory.newClient(...); // Use the ML Java Client API
XccAssetLoader assetLoader = new XccAssetLoader(client); // Can use XCC or the REST API to load asset modules
DefaultModulesLoader modulesLoader = new DefaultModulesLoader(assetLoader);
File modulesDir = new File("src/main/ml-modules");
ModulesFinder modulesFinder = new DefaultModulesFinder(); // Allows for adjusting where modules are stored on a filesystem
modulesLoader.loadModules(modulesDir, modulesFinder, client);

Parallelized batch writes

The BatchWriter library was created primarily for applications using marklogic-spring-batch. But it can be used in any environment. It provides the following features:

  1. Uses Spring's TaskExecutor library for parallelizing writes
  2. Supports writes via the REST API or XCC

Via Spring's TaskExecutor library, you can essentially throw an infinite number of documents at this interface. The library will default to a sensible implementation of ThreadPoolTaskExecutor, but you can override that with any TaskExecutor implementation you like.

Once MarkLogic 9 is available, an implementation will be used that depends on the new Data Movement SDK, which is being added to the MarkLogic Java Client API.

Here's a sample using two DatabaseClient instances:

	// This is all basic Java Client API stuff
DatabaseClient client1 = DatabaseClientFactory.newClient("host1", ...);
DatabaseClient client2 = DatabaseClientFactory.newClient("host2", ...);
DocumentWriteOperation doc1 = new DocumentWriteOperationImpl("test1.xml", ...);
DocumentWriteOperation doc2 = new DocumentWriteOperationImpl("test2.xml", ...);

// Here's how BatchWriter works
BatchWriter writer = new RestBatchWriter(Arrays.asList(client1, client2));
writer.initialize();
writer.write(Arrays.asList(doc1, doc2));
writer.waitForCompletion();

ml-javaclient-util-issue-136's People

Contributors

nikos avatar paxtonhare avatar rjrudin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.