當前位置: 首頁>>代碼示例>>Java>>正文


Java Instant.minus方法代碼示例

本文整理匯總了Java中org.joda.time.Instant.minus方法的典型用法代碼示例。如果您正苦於以下問題:Java Instant.minus方法的具體用法?Java Instant.minus怎麽用?Java Instant.minus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.Instant的用法示例。


在下文中一共展示了Instant.minus方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildBigQueryProcessedUrlsQuery

import org.joda.time.Instant; //導入方法依賴的package包/類
public static String buildBigQueryProcessedUrlsQuery(IndexerPipelineOptions options) {
	String timeWindow = null;

	if (options.getProcessedUrlHistorySec() != null) {
		if (options.getProcessedUrlHistorySec() != Integer.MAX_VALUE) {
			Instant fromTime = Instant.now();
			fromTime = fromTime.minus(options.getProcessedUrlHistorySec() * 1000L);
			Integer fromDateId = IdConverterUtils.getDateIdFromTimestamp(fromTime.getMillis());
			timeWindow = "PublicationDateId >= " + fromDateId;
		}
	}

	if (timeWindow != null)
		timeWindow = "WHERE " + timeWindow;

	String result = "SELECT Url, MAX(ProcessingTime) AS ProcessingTime\n" + "FROM " + options.getBigQueryDataset()
			+ "." + WEBRESOURCE_TABLE + "\n" + timeWindow + "\n" + "GROUP BY Url";

	return result;
}
 
開發者ID:GoogleCloudPlatform,項目名稱:dataflow-opinion-analysis,代碼行數:21,代碼來源:IndexerPipelineUtils.java

示例2: buildBigQueryProcessedDocsQuery

import org.joda.time.Instant; //導入方法依賴的package包/類
public static String buildBigQueryProcessedDocsQuery(IndexerPipelineOptions options) {
	String timeWindow = null;

	if (options.getProcessedUrlHistorySec() != null) {
		if (options.getProcessedUrlHistorySec() != Integer.MAX_VALUE) {
			Instant fromTime = Instant.now();
			fromTime = fromTime.minus(options.getProcessedUrlHistorySec() * 1000L);
			Integer fromDateId = IdConverterUtils.getDateIdFromTimestamp(fromTime.getMillis());
			timeWindow = "PublicationDateId >= " + fromDateId;
		}
	}

	if (timeWindow != null)
		timeWindow = "WHERE " + timeWindow;

	String result = "SELECT DocumentHash, MAX(ProcessingTime) AS ProcessingTime\n" + "FROM " + options.getBigQueryDataset()
			+ "." + DOCUMENT_TABLE + "\n" + timeWindow + "\n" + "GROUP BY DocumentHash";

	return result;
}
 
開發者ID:GoogleCloudPlatform,項目名稱:dataflow-opinion-analysis,代碼行數:21,代碼來源:IndexerPipelineUtils.java

示例3: buildBigQueryProcessedSocialCountsQuery

import org.joda.time.Instant; //導入方法依賴的package包/類
public static String buildBigQueryProcessedSocialCountsQuery(IndexerPipelineOptions options) {
	String timeWindow = null;

	if (options.getWrSocialCountHistoryWindowSec() != null) {
		if (options.getWrSocialCountHistoryWindowSec() != Integer.MAX_VALUE) {
			Instant fromTime = Instant.now();
			fromTime = fromTime.minus(options.getWrSocialCountHistoryWindowSec() * 1000L);
			Integer fromDateId = IdConverterUtils.getDateIdFromTimestamp(fromTime.getMillis());
			timeWindow = "WrPublicationDateId >= " + fromDateId;
		}
	}

	if (timeWindow != null)
		timeWindow = "WHERE " + timeWindow;

	String result = "SELECT WebResourceHash, MAX(CountTime) AS LastCountTime\n" + "FROM "
			+ options.getBigQueryDataset() + "." + WRSOCIALCOUNT_TABLE + "\n" + timeWindow + "\n"
			+ "GROUP BY WebResourceHash";

	return result;

}
 
開發者ID:GoogleCloudPlatform,項目名稱:dataflow-opinion-analysis,代碼行數:23,代碼來源:IndexerPipelineUtils.java

示例4: testExplodeWindowsManyWindowsMultipleWindowedValues

import org.joda.time.Instant; //導入方法依賴的package包/類
@Test
public void testExplodeWindowsManyWindowsMultipleWindowedValues() {
  Instant now = Instant.now();
  BoundedWindow centerWindow = new IntervalWindow(now.minus(1000L), now.plus(1000L));
  BoundedWindow pastWindow = new IntervalWindow(now.minus(1500L), now.plus(500L));
  BoundedWindow futureWindow = new IntervalWindow(now.minus(500L), now.plus(1500L));
  BoundedWindow futureFutureWindow = new IntervalWindow(now, now.plus(2000L));
  PaneInfo pane = PaneInfo.createPane(false, false, Timing.ON_TIME, 3L, 0L);
  WindowedValue<String> value =
      WindowedValue.of(
          "foo",
          now,
          ImmutableList.of(pastWindow, centerWindow, futureWindow, futureFutureWindow),
          pane);

  assertThat(
      value.explodeWindows(),
      containsInAnyOrder(
          WindowedValue.of("foo", now, futureFutureWindow, pane),
          WindowedValue.of("foo", now, futureWindow, pane),
          WindowedValue.of("foo", now, centerWindow, pane),
          WindowedValue.of("foo", now, pastWindow, pane)));
}
 
開發者ID:apache,項目名稱:beam,代碼行數:24,代碼來源:WindowedValueTest.java

示例5: decode

import org.joda.time.Instant; //導入方法依賴的package包/類
@Override
public IntervalWindow decode(InputStream inStream)
    throws IOException, CoderException {
  Instant end = instantCoder.decode(inStream);
  ReadableDuration duration = durationCoder.decode(inStream);
  return new IntervalWindow(end.minus(duration), end);
}
 
開發者ID:apache,項目名稱:beam,代碼行數:8,代碼來源:IntervalWindow.java

示例6: testExplodeWindowsInOneWindowEquals

import org.joda.time.Instant; //導入方法依賴的package包/類
@Test
public void testExplodeWindowsInOneWindowEquals() {
  Instant now = Instant.now();
  BoundedWindow window = new IntervalWindow(now.minus(1000L), now.plus(1000L));
  WindowedValue<String> value =
      WindowedValue.of("foo", now, window, PaneInfo.ON_TIME_AND_ONLY_FIRING);

  assertThat(Iterables.getOnlyElement(value.explodeWindows()), equalTo(value));
}
 
開發者ID:apache,項目名稱:beam,代碼行數:10,代碼來源:WindowedValueTest.java

示例7: testTrivialProcessFnPropagatesOutputWindowAndTimestamp

import org.joda.time.Instant; //導入方法依賴的package包/類
@Test
public void testTrivialProcessFnPropagatesOutputWindowAndTimestamp() throws Exception {
  // Tests that ProcessFn correctly propagates the window and timestamp of the element
  // inside the KeyedWorkItem.
  // The underlying DoFn is actually monolithic, so this doesn't test splitting.
  DoFn<Integer, String> fn = new ToStringFn();

  Instant base = Instant.now();

  IntervalWindow w =
      new IntervalWindow(
          base.minus(Duration.standardMinutes(1)), base.plus(Duration.standardMinutes(1)));

  ProcessFnTester<Integer, String, SomeRestriction, SomeRestrictionTracker> tester =
      new ProcessFnTester<>(
          base,
          fn,
          BigEndianIntegerCoder.of(),
          SerializableCoder.of(SomeRestriction.class),
          MAX_OUTPUTS_PER_BUNDLE,
          MAX_BUNDLE_DURATION);
  tester.startElement(
      WindowedValue.of(
          KV.of(42, new SomeRestriction()),
          base,
          Collections.singletonList(w),
          PaneInfo.ON_TIME_AND_ONLY_FIRING));

  assertEquals(
      Arrays.asList(
          TimestampedValue.of("42a", base),
          TimestampedValue.of("42b", base),
          TimestampedValue.of("42c", base)),
      tester.peekOutputElementsInWindow(w));
}
 
開發者ID:apache,項目名稱:beam,代碼行數:36,代碼來源:SplittableParDoProcessFnTest.java


注:本文中的org.joda.time.Instant.minus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。