Tabnine Logo
Clip.of
Code IndexAdd Tabnine to your IDE (free)

How to use
of
method
in
com.yahoo.bullet.result.Clip

Best Java code snippets using com.yahoo.bullet.result.Clip.of (Showing top 20 results out of 315)

origin: com.yahoo.bullet/bullet-core

/**
 * Gets the result from the data presented to the sketch as a {@link Clip}. Also adds {@link Meta} if
 * asked for.
 *
 * @param metaKey If set to a non-null value, Sketch metadata will be added to the result.
 * @param conceptKeys If provided, these {@link Concept} names will be added to the metadata.
 * @return A {@link Clip} of the results.
 */
public Clip getResult(String metaKey, Map<String, String> conceptKeys) {
  // Subclasses are charge of adding data. We'll just create an empty Clip with the metadata.
  return Clip.of(getMetadata(metaKey, conceptKeys));
}
origin: com.yahoo.bullet/bullet-core

/**
 * Gets the aggregated records so far since the last call to {@link #reset()}. The records have a size that is at
 * most the maximum specified by the {@link Aggregation}.
 *
 * @return a {@link Clip} of the records so far.
 */
@Override
public Clip getResult() {
  return Clip.of(getRecords());
}
origin: com.yahoo.bullet/bullet-core

@Override
public Clip getResult() {
  return Clip.of(getRecords());
}
origin: com.yahoo.bullet/bullet-storm

  /**
   * Write this error as a JSON Bullet error response in the {@link Meta} of a {@link Clip}.
   *
   * @return A String JSON version of this error.
   */
  public String asJSONClip() {
    return Clip.of(Meta.of(this)).asJSON();
  }
}
origin: bullet-db/bullet-storm

  /**
   * Write this error as a JSON Bullet error response in the {@link Meta} of a {@link Clip}.
   *
   * @return A String JSON version of this error.
   */
  public String asJSONClip() {
    return Clip.of(Meta.of(this)).asJSON();
  }
}
origin: com.yahoo.bullet/bullet-core

@Override
public Clip getResult() {
  // This has already called aggregation.getMetadata
  Clip clip = Clip.of(getMetadata());
  clip.add(aggregation.getRecords());
  return clip;
}
origin: bullet-db/bullet-storm

private void emitErrorsAsResult(String id, Metadata metadata, List<BulletError> errors) {
  updateCount(improperQueriesCount, 1L);
  emitResult(id, withSignal(metadata, Metadata.Signal.FAIL), Clip.of(Meta.of(errors)));
}
origin: com.yahoo.bullet/bullet-storm

private void emitErrorsAsResult(String id, Metadata metadata, List<BulletError> errors) {
  updateCount(improperQueriesCount, 1L);
  emitResult(id, withSignal(metadata, Metadata.Signal.FAIL), Clip.of(Meta.of(errors)));
}
origin: bullet-db/bullet-storm

@Test
public void testFailJoiningForNoQuery() {
  List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42");
  Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).asJSON(), COMPLETED);
  Assert.assertFalse(wasResultEmitted(expected));
  Assert.assertEquals(collector.getEmittedCount(), 0);
}
origin: bullet-db/bullet-storm

@Test
public void testJoining() {
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{}", EMPTY);
  bolt.execute(query);
  List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42");
  Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).asJSON(), COMPLETED);
  Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
  Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, null));
  Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
  Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.RESULT_STREAM).count(), 1);
  Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.FEEDBACK_STREAM).count(), 1);
}
origin: bullet-db/bullet-storm

@Test
public void testRawQueryDoneButNotTimedOutWithExcessRecords() {
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeAggregationQuery(RAW, 5), EMPTY);
  bolt.execute(query);
  // This will send 2 batches of 3 records each (total of 6 records).
  List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42", 5, 3);
  List<BulletRecord> actualSent = sent.subList(0, 5);
  Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(actualSent).asJSON(), COMPLETED);
  Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
  Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, null));
  Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
  Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.RESULT_STREAM).count(), 1);
  Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.FEEDBACK_STREAM).count(), 1);
}
origin: bullet-db/bullet-storm

@Test
public void testErrorInQueryWithoutMetadata() {
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{\"aggregation\": {\"type\": \"garbage\"}}");
  bolt.execute(query);
  Assert.assertEquals(collector.getEmittedCount(), 1);
  BulletError expectedError = Aggregation.TYPE_NOT_SUPPORTED_ERROR;
  Meta expectedMetadata = Meta.of(expectedError);
  List<Object> expected = TupleUtils.makeTuple("42", Clip.of(expectedMetadata).asJSON(), FAILED).getValues();
  List<Object> actual = collector.getNthTupleEmittedTo(TopologyConstants.RESULT_STREAM, 1).get();
  Assert.assertTrue(isSameResult(actual, expected));
  Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.RESULT_STREAM).count(), 1);
  Assert.assertEquals(collector.getEmittedCount(), 1);
}
origin: bullet-db/bullet-storm

@Test
public void testMissingMetadataIsEmitted() {
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{}");
  bolt.execute(query);
  List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42", RAW_MAX_SIZE);
  Assert.assertEquals(collector.getEmittedCount(), 2);
  Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).asJSON(), COMPLETED);
  Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
  Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, null));
  Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
}
origin: bullet-db/bullet-storm

@Test
public void testErrorEmittedProperly() {
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "garbage", EMPTY);
  bolt.execute(query);
  Assert.assertEquals(collector.getEmittedCount(), 1);
  String error = ParsingError.GENERIC_JSON_ERROR + ":\ngarbage\n" +
          "IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $";
  BulletError expectedError = ParsingError.makeError(error, ParsingError.GENERIC_JSON_RESOLUTION);
  Meta expectedMetadata = Meta.of(expectedError);
  List<Object> expected = TupleUtils.makeTuple("42", Clip.of(expectedMetadata).asJSON(), FAILED).getValues();
  List<Object> actual = collector.getNthTupleEmittedTo(TopologyConstants.RESULT_STREAM, 1).get();
  Assert.assertTrue(isSameResult(actual, expected));
}
origin: bullet-db/bullet-storm

@Test
public void testUnknownAggregation() {
  // Lowercase "top" is not valid and will not be parsed since there is no enum for it
  // In this case aggregation type should be set to null and an error should be emitted
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42",
                     "{\"aggregation\": {\"type\": \"garbage\"}}", EMPTY);
  bolt.execute(query);
  Assert.assertEquals(collector.getEmittedCount(), 1);
  BulletError expectedError = Aggregation.TYPE_NOT_SUPPORTED_ERROR;
  Meta expectedMetadata = Meta.of(expectedError);
  List<Object> expected = TupleUtils.makeTuple("42", Clip.of(expectedMetadata).asJSON(), FAILED).getValues();
  List<Object> actual = collector.getNthTupleEmittedTo(TopologyConstants.RESULT_STREAM, 1).get();
  Assert.assertTrue(isSameResult(actual, expected));
}
origin: bullet-db/bullet-storm

@Test
public void testDataWithoutQuery() {
  sendRawRecordTuplesTo(bolt, "42", RAW_MAX_SIZE - 2);
  Assert.assertEquals(collector.getEmittedCount(), 0);
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{}");
  bolt.execute(query);
  List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42", RAW_MAX_SIZE);
  Assert.assertEquals(collector.getEmittedCount(), 2);
  Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).asJSON(), COMPLETED);
  Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
  Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, null));
  Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
}
origin: bullet-db/bullet-storm

@Test
public void testMetadataIsNotReplaced() {
  Metadata actualMetadata = new Metadata(null, "foo");
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{}", actualMetadata);
  bolt.execute(query);
  List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42", RAW_MAX_SIZE);
  Metadata expectedMetadata = new Metadata(Metadata.Signal.COMPLETE, "foo");
  Assert.assertEquals(collector.getEmittedCount(), 2);
  Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).asJSON(), expectedMetadata);
  Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
  Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, "foo"));
  Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
}
origin: bullet-db/bullet-storm

@Test
public void testUnhandledExceptionErrorEmitted() {
  // An empty query should throw an null-pointer exception which should be caught in JoinBolt
  // and an error should be emitted
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "", EMPTY);
  bolt.execute(query);
  sendRawRecordTuplesTo(bolt, "42");
  Assert.assertEquals(collector.getEmittedCount(), 1);
  String error = ParsingError.GENERIC_JSON_ERROR + ":\n\nNullPointerException: ";
  BulletError expectedError = ParsingError.makeError(error, ParsingError.GENERIC_JSON_RESOLUTION);
  Meta expectedMetadata = Meta.of(expectedError);
  List<Object> expected = TupleUtils.makeTuple("42", Clip.of(expectedMetadata).asJSON(), FAILED).getValues();
  List<Object> actual = collector.getNthTupleEmittedTo(TopologyConstants.RESULT_STREAM, 1).get();
  Assert.assertTrue(isSameResult(actual, expected));
}
origin: bullet-db/bullet-storm

@Test
public void testQueryIdentifierMetadata() {
  config = configWithRawMaxAndEmptyMeta();
  enableMetadataInConfig(config, Concept.QUERY_METADATA.getName(), "meta");
  enableMetadataInConfig(config, Concept.QUERY_ID.getName(), "id");
  setup(new JoinBolt(config));
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{}", EMPTY);
  bolt.execute(query);
  List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42");
  Meta meta = new Meta();
  meta.add("meta", singletonMap("id", "42"));
  Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).add(meta).asJSON(), COMPLETED);
  Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
  Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, null));
  Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
  Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.RESULT_STREAM).count(), 1);
  Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.FEEDBACK_STREAM).count(), 1);
}
origin: bullet-db/bullet-storm

@Test
public void testRateLimitingOnCombine() {
  RateLimitError rateLimitError = new RateLimitError(42.0, 5.0);
  bolt = new RateLimitedJoinBolt(2, rateLimitError, config);
  setup(bolt);
  Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeAggregationQuery(RAW, 10));
  bolt.execute(query);
  // After consuming the 3rd one, it is rate limited and the fourth is not consumed
  List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42", 4);
  Assert.assertEquals(collector.getEmittedCount(), 2);
  Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42",
                     Clip.of(sent.subList(0, 3)).add(rateLimitError.makeMeta()).asJSON(),
                     new Metadata(Metadata.Signal.FAIL, null));
  Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
  Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.KILL, null));
  Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
}
com.yahoo.bullet.resultClipof

Javadoc

Construct a Clip with the given BulletRecord.

Popular methods of Clip

  • add
    Adds all the BulletRecord to the records in the Clip.
  • asJSON
  • getMeta
  • <init>
  • getRecords

Popular in Java

  • Making http requests using okhttp
  • getExternalFilesDir (Context)
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now