Package com.datasift.client.core

Examples of com.datasift.client.core.Stream


        DataSiftDynamicList dynamiclist = new DataSiftDynamicList(config);

        DynamicList list = dynamiclist.create(DataSiftDynamicList.ListType.STRING, "example list").sync();
        if (list.isSuccessful()) {
            // create a stream that references the dynamic list, using the list_any operator
            Stream stream = datasift
                    .compile(String.format("interaction.content list_any \"%s\"", list.getId())).sync();

            // even after the stream was created, we can manipulate the list, even if the stream is running
            List<String> items = new ArrayList<>();
            items.add("keyword1");
View Full Code Here


public class HistoricsApi {
    private HistoricsApi() throws InterruptedException {
        DataSiftConfig config = new DataSiftConfig("zcourts", "44067e0ff342b76b52b36a63eea8e21a");
        DataSiftClient datasift = new DataSiftClient(config);
        Stream stream = Stream.fromString("13e9347e7da32f19fcdb08e297019d2e");

        S3 s3 = PushConnectors
                .s3()
                .accessKey("s3-access-key")
                .secretKey("s3-access-key")
                .bucket("apitests")
                .directory("java-client")
                .acl("private")
                .deliveryFrequency(0)
                .maxSize(10485760)
                .filePrefix("DataSiftJava-");

        DateTime fiveHrsAgo = DateTime.now().minusHours(5);
        DateTime fourHrsAgo = fiveHrsAgo.plusHours(1);
        String name = "My awesome Historics";
        //prepare our query
        PreparedHistoricsQuery query = datasift.historics().prepare(stream.hash(), fiveHrsAgo, fourHrsAgo, name).sync();
        //have to create a push subscription to the newly created historics before starting
        datasift.push().create(s3, FutureData.wrap(query), "Subscription name").sync();
        DataSiftResult historics = datasift.historics().start(query).sync();

        //stop a query
View Full Code Here

            public void onDelete(DeletedInteraction di) {
                System.out.println("DELETED:\n " + di);
            }
        });

        Stream stream = Stream.fromString("13e9347e7da32f19fcdb08e297019d2e");

        datasift.liveStream().subscribe(new StreamSubscription(stream) {
            public void onDataSiftLogMessage(DataSiftMessage di) {
                //di.isWarning() is also available
                System.out.println((di.isError() ? "Error" : di.isInfo() ? "Info" : "Warning") + ":\n" + di);
View Full Code Here

    }

    public static void main(String... args) throws InterruptedException {
        DataSiftConfig config = new DataSiftConfig("zcourts", "44067e0ff342b76b52b36a63eea8e21a");
        final DataSiftClient datasift = new DataSiftClient(config);
        Stream stream = Stream.fromString("13e9347e7da32f19fcdb08e297019d2e");
        S3 s3 = PushConnectors.s3()
                .accessKey("amazon-access-key")
                .secretKey("amazone-secret")
                .maxSize(102400)
                .deliveryFrequency(0)
View Full Code Here

     * to list the hash for the compiled CSDL
     */
    public FutureData<Stream> compile(String csdl) {
        FutureData<Stream> future = new FutureData<Stream>();
        URI uri = newParams().forURL(config.newAPIEndpointURI(COMPILE));
        POST request = config.http().POST(uri, new PageReader(newRequestCallback(future, new Stream(), config)))
                .form("csdl", csdl);
        applyConfig(request).execute();
        return future;
    }
View Full Code Here

        //what's left of your rate limit quota
        result.rateLimitRemaining();

        Usage usage = datasift.usage().sync();

        Stream stream = Stream.fromString("13e9347e7da32f19fcdb08e297019d2e");
        Dpu dpu = datasift.dpu(stream).sync();

        Balance balance = datasift.balance().sync();
        //synchronously validate a CSDL
        Validation validation = datasift.validate(csdl).sync();
View Full Code Here

    }

    public static void main(String... args) throws InterruptedException {
        DataSiftConfig config = new DataSiftConfig("zcourts", "130894088ba71db4e793585e40528bc1");
        final DataSiftClient datasift = new DataSiftClient(config);
        Stream result = datasift.compile("interaction.content contains \"music\"").sync();
        //handle exceptions that can't necessarily be linked to a specific stream
        datasift.liveStream().onError(new ErrorHandler());

        //handle delete message
        datasift.liveStream().onStreamEvent(new DeleteHandler());

        //process interactions
        datasift.liveStream().subscribe(new Subscription(Stream.fromString(result.hash())));
        //process interactions for another stream
        datasift.liveStream().subscribe(new Subscription(Stream.fromString("another-stream-hash")));

        //at some point later if you want unsubscribe
        datasift.liveStream().unsubscribe(Stream.fromString(result.hash()));
    }
View Full Code Here

     * to list the hash for the compiled CSDL
     */
    public FutureData<Stream> compile(String csdl) {
        FutureData<Stream> future = new FutureData<Stream>();
        URI uri = newParams().forURL(config.newAPIEndpointURI(COMPILE));
        POST request = config.http().POST(uri, new PageReader(newRequestCallback(future, new Stream(), config)))
                .form("csdl", csdl);
        performRequest(future, request);
        return future;
    }
View Full Code Here

TOP

Related Classes of com.datasift.client.core.Stream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.