Tabnine Logo
ParsingError
Code IndexAdd Tabnine to your IDE (free)

How to use
ParsingError
in
com.yahoo.bullet.parsing

Best Java code snippets using com.yahoo.bullet.parsing.ParsingError (Showing top 6 results out of 315)

origin: com.yahoo.bullet/bullet-core

/**
 * Creates a ParsingError object with the root cause message from the given cause if available.
 *
 * @param cause A cause if available.
 *
 * @return A ParsingError representing this cause.
 */
public static ParsingError makeError(Throwable cause) {
  String message = ExceptionUtils.getRootCauseMessage(cause);
  message = message.isEmpty() ? GENERIC_JSON_ERROR : message;
  return new ParsingError(message, singletonList(GENERIC_JSON_RESOLUTION));
}
origin: com.yahoo.bullet/bullet-storm

private void onQuery(Tuple tuple) {
  String id = tuple.getString(TopologyConstants.ID_POSITION);
  String query = tuple.getString(TopologyConstants.QUERY_POSITION);
  Metadata metadata = (Metadata) tuple.getValue(TopologyConstants.QUERY_METADATA_POSITION);
  // bufferedMetadata has an entry for each query that exists in the JoinBolt; therefore, we check bufferedMetadata
  // for existing queries (as opposed to individually checking the queries, preStartBuffer, and postFinishBuffer maps)
  if (bufferedMetadata.containsKey(id)) {
    updateCount(duplicatedQueriesCount, 1L);
    log.error("Duplicate for request {} with query {}", id, query);
    return;
  }
  Querier querier;
  try {
    querier = createQuerier(Querier.Mode.ALL, id, query, config);
    Optional<List<BulletError>> optionalErrors = querier.initialize();
    if (!optionalErrors.isPresent()) {
      setupQuery(id, query, metadata, querier);
      return;
    }
    emitErrorsAsResult(id, metadata, optionalErrors.get());
  } catch (RuntimeException re) {
    // Includes JSONParseException
    emitErrorsAsResult(id, metadata, ParsingError.makeError(re, query));
  }
  log.error("Failed to initialize query for request {} with query {}", id, query);
}
origin: bullet-db/bullet-storm

private void onQuery(Tuple tuple) {
  String id = tuple.getString(TopologyConstants.ID_POSITION);
  String query = tuple.getString(TopologyConstants.QUERY_POSITION);
  Metadata metadata = (Metadata) tuple.getValue(TopologyConstants.QUERY_METADATA_POSITION);
  // bufferedMetadata has an entry for each query that exists in the JoinBolt; therefore, we check bufferedMetadata
  // for existing queries (as opposed to individually checking the queries, preStartBuffer, and postFinishBuffer maps)
  if (bufferedMetadata.containsKey(id)) {
    updateCount(duplicatedQueriesCount, 1L);
    log.error("Duplicate for request {} with query {}", id, query);
    return;
  }
  Querier querier;
  try {
    querier = createQuerier(Querier.Mode.ALL, id, query, config);
    Optional<List<BulletError>> optionalErrors = querier.initialize();
    if (!optionalErrors.isPresent()) {
      setupQuery(id, query, metadata, querier);
      return;
    }
    emitErrorsAsResult(id, metadata, optionalErrors.get());
  } catch (RuntimeException re) {
    // Includes JSONParseException
    emitErrorsAsResult(id, metadata, ParsingError.makeError(re, query));
  }
  log.error("Failed to initialize query for request {} with query {}", id, query);
}
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: com.yahoo.bullet/bullet-core

  /**
   * Creates a ParsingError object with the original query string and the root cause message from the given cause.
   *
   * @param cause A cause.
   * @param queryString The original query.
   *
   * @return A ParsingError representing this cause.
   */
  public static ParsingError makeError(RuntimeException cause, String queryString) {
    String message = ExceptionUtils.getRootCauseMessage(cause);
    message = message.isEmpty() ? "" : message;
    return new ParsingError(GENERIC_JSON_ERROR + ":\n" + queryString + "\n" + message,
                singletonList(GENERIC_JSON_RESOLUTION));
  }
}
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));
}
com.yahoo.bullet.parsingParsingError

Most used methods

  • makeError
    Creates a ParsingError object with the root cause message from the given cause if available.
  • <init>
    Constructor override.

Popular in Java

  • Reactive rest calls using spring rest template
  • getSupportFragmentManager (FragmentActivity)
  • requestLocationUpdates (LocationManager)
  • setScale (BigDecimal)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Option (scala)
  • Github Copilot alternatives
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