Tabnine Logo
GranularityType.fromPeriod
Code IndexAdd Tabnine to your IDE (free)

How to use
fromPeriod
method
in
org.apache.druid.java.util.common.granularity.GranularityType

Best Java code snippets using org.apache.druid.java.util.common.granularity.GranularityType.fromPeriod (Showing top 8 results out of 315)

origin: apache/incubator-druid

@Override
public DateTimeFormatter getFormatter(Formatter type)
{
 GranularityType granularityType = GranularityType.fromPeriod(period);
 switch (type) {
  case DEFAULT:
   return DateTimeFormat.forPattern(granularityType.getDefaultFormat());
  case HIVE:
   return DateTimeFormat.forPattern(granularityType.getHiveFormat());
  case LOWER_DEFAULT:
   return DateTimeFormat.forPattern(granularityType.getLowerDefaultFormat());
  default:
   throw new IAE("There is no format for type %s", type);
 }
}
origin: apache/incubator-druid

@Override
public void serialize(JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
  throws IOException
{
 // Retain the same behavior as before #3850.
 // i.e. when Granularity class was an enum.
 if (GranularityType.isStandard(this)) {
  jsonGenerator.writeString(GranularityType.fromPeriod(getPeriod()).toString());
 } else {
  jsonGenerator.writeStartObject();
  jsonGenerator.writeStringField("type", "period");
  jsonGenerator.writeObjectField("period", getPeriod());
  jsonGenerator.writeObjectField("timeZone", getTimeZone());
  jsonGenerator.writeObjectField("origin", getOrigin());
  jsonGenerator.writeEndObject();
 }
}
origin: apache/incubator-druid

@Override
public DateTime toDate(String filePath, Formatter formatter)
{
 Integer[] vals = getDateValues(filePath, formatter);
 GranularityType granularityType = GranularityType.fromPeriod(period);
 DateTime date = granularityType.getDateTime(vals);
 if (date != null) {
  return bucketStart(date);
 }
 return null;
}
origin: apache/incubator-druid

  dimensionsSpec,
  metricsSpec,
  GranularityType.fromPeriod(interval.toPeriod()).getDefaultGranularity(),
  jsonMapper
);
origin: apache/incubator-druid

@Test
public void testCustomNestedPeriodFail()
{
 try {
  Period p = Period.years(6).withMonths(3).withSeconds(23);
  GranularityType.fromPeriod(p);
  Assert.fail("Complicated period creation should fail b/c of unsupported granularity type.");
 }
 catch (IAE e) {
  // pass
 }
}
origin: org.apache.druid/java-util

@Override
public DateTimeFormatter getFormatter(Formatter type)
{
 GranularityType granularityType = GranularityType.fromPeriod(period);
 switch (type) {
  case DEFAULT:
   return DateTimeFormat.forPattern(granularityType.getDefaultFormat());
  case HIVE:
   return DateTimeFormat.forPattern(granularityType.getHiveFormat());
  case LOWER_DEFAULT:
   return DateTimeFormat.forPattern(granularityType.getLowerDefaultFormat());
  default:
   throw new IAE("There is no format for type %s", type);
 }
}
origin: org.apache.druid/java-util

@Override
public void serialize(
  JsonGenerator jsonGenerator, SerializerProvider serializerProvider
) throws IOException, JsonProcessingException
{
 // Retain the same behavior as before #3850.
 // i.e. when Granularity class was an enum.
 if (GranularityType.isStandard(this)) {
  jsonGenerator.writeString(GranularityType.fromPeriod(getPeriod()).toString());
 } else {
  jsonGenerator.writeStartObject();
  jsonGenerator.writeStringField("type", "period");
  jsonGenerator.writeObjectField("period", getPeriod());
  jsonGenerator.writeObjectField("timeZone", getTimeZone());
  jsonGenerator.writeObjectField("origin", getOrigin());
  jsonGenerator.writeEndObject();
 }
}
origin: org.apache.druid/java-util

@Override
public DateTime toDate(String filePath, Formatter formatter)
{
 Integer[] vals = getDateValues(filePath, formatter);
 GranularityType granularityType = GranularityType.fromPeriod(period);
 DateTime date = granularityType.getDateTime(vals);
 if (date != null) {
  return bucketStart(date);
 }
 return null;
}
org.apache.druid.java.util.common.granularityGranularityTypefromPeriod

Javadoc

Note: This is only an estimate based on the values in period. This will not work for complicated periods that represent say 1 year 1 day

Popular methods of GranularityType

  • getDefaultGranularity
  • values
  • create
  • getDateTime
  • getDefaultFormat
  • getHiveFormat
  • getLowerDefaultFormat
  • isStandard
    For a select subset of granularites, users can specify them directly as string. These are "predefine
  • toString
  • valueOf
  • name
  • name

Popular in Java

  • Parsing JSON documents to java classes using gson
  • findViewById (Activity)
  • setContentView (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Collectors (java.util.stream)
  • Top Vim plugins
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