Package com.endeca.BulkLoad

This defines the API for writing programs to load bulk data into the Endeca data store.

See:
          Description

Interface Summary
AbortCallback Interface for handling abort conditions in BulkIngester.
ErrorCallback Interface for handling error conditions in BulkIngester.
FinishedCallback Interface for receiving notification that a BulkIngester ingestion has finished.
StatusCallback Interface for handling status updates in BulkIngester.
 

Class Summary
BulkIngester The primary entry point for the client-side Bulk Load Interface for loading data into an Endeca data domain.
 

Package com.endeca.BulkLoad Description

This defines the API for writing programs to load bulk data into the Endeca data store.

Before loading data into the data store, a client program needs to know the bulk load port of the data store. This can be obtained by using the allocateBulkPort web service method in the manage web service.

Usage

Here is a sample program that illustrates the basic usage of the Endeca Bulk Load API.
package com.endeca.BulkLoad;

import com.endeca.BulkLoad.Msg.Data;

public class BulkLoadDemo {

        private static Data.Record makeProductRecord(String name, int size, double price) {

                Data.Record.Builder recBuilder = Data.Record.newBuilder();

                Data.Assignment.Builder assgtBuilder = Data.Assignment.newBuilder();
                assgtBuilder.setName("Name");
                assgtBuilder.setStringValue(name);
                assgtBuilder.setDataType(Data.Assignment.DataType.STRING);
                Data.Assignment nameAssgt = assgtBuilder.build();
                recBuilder.setSpec(nameAssgt);

                assgtBuilder.clear();
                assgtBuilder.setName("Size");
                assgtBuilder.setInt32Value(size);
                assgtBuilder.setDataType(Data.Assignment.DataType.INT);
                recBuilder.addAssignments(assgtBuilder);

                assgtBuilder.clear();
                assgtBuilder.setName("Price");
                assgtBuilder.setDoubleValue(price);
                assgtBuilder.setDataType(Data.Assignment.DataType.DOUBLE);
                Data.Assignment priceAssgt = assgtBuilder.build();
                recBuilder.addAssignments(priceAssgt);

                return recBuilder.build();
        }

        public static void main(String[] args) throws Exception {

                ErrorCallback errorCallback = new ErrorCallback() {
                        public void handleError(String reason, Data.Record reject) {
                                System.out.println("Record "
                                                + reject.getSpec().getName()
                                                + " rejected: " + reason);
                        }
                };

                FinishedCallback finishedCallback = new FinishedCallback() {
                        public void handleFinish() {
                                System.out.println("Finished!");
                        }
                };

                AbortCallback abortCallback = new AbortCallback() {
                        public void handleAbort(String reason) {
                                System.out.println("Aborted: " + reason);
                        }
                };

                StatusCallback statusCallback = new StatusCallback() {
                        public void handleStatus(long recordsAdded,
                                          long recordsQueued,
                                          long recordsRejected,
                                          String state) {
                                System.out.println("Added: " + recordsAdded + "\n"
                                                + "Queued: " + recordsQueued + "\n"
                                                + "Rejected: " + recordsRejected + "\n"
                                                + "State: " + state + "\n");
                        }
                };

                BulkIngester ingester = new BulkIngester(
                                "host.com",  // host
                                1234,        // port
                                true,        // use SSL
                                true,        // doFinalMerge
                                true,        // doUpdateDictionary
                                60,          // timeout
                                errorCallback,
                                finishedCallback,
                                abortCallback,
                                statusCallback);

                Data.Record widget = makeProductRecord("Widget", 12, 99.95);
                Data.Record thing = makeProductRecord("Thing", 110, 3.14);

                ingester.begin();
                ingester.sendRecord(widget);
                ingester.requestStatusUpdate();
                ingester.sendRecord(thing);
                ingester.endIngest();

        }
}