@Test public void testSetLimitsFrom() { final ExecuteProperties base = ExecuteProperties.newBuilder() .setIsolationLevel(IsolationLevel.SNAPSHOT) .setReturnedRowLimit(ROW_LIMIT) .setTimeLimit(TIME_LIMIT) .setScannedRecordsLimit(RECORD_SCAN_LIMIT) .build(); final ExecuteProperties merge1 = base.setLimitsFrom(ExecuteProperties.newBuilder() .setReturnedRowLimit(ROW_LIMIT + 1) .build()); assertEquals(ROW_LIMIT + 1, merge1.getReturnedRowLimit()); assertEquals(TIME_LIMIT, merge1.getTimeLimit()); assertEquals(base.getState(), merge1.getState()); final ExecuteProperties merge2 = base.setLimitsFrom(ExecuteProperties.newBuilder() .setTimeLimit(TIME_LIMIT + 1) .build()); assertEquals(ROW_LIMIT, merge2.getReturnedRowLimit()); assertEquals(TIME_LIMIT + 1, merge2.getTimeLimit()); assertEquals(base.getState(), merge2.getState()); final ExecuteProperties merge3 = base.setLimitsFrom(ExecuteProperties.newBuilder() .setScannedRecordsLimit(RECORD_SCAN_LIMIT + 1) .build()); assertEquals(ROW_LIMIT, merge3.getReturnedRowLimit()); assertEquals(TIME_LIMIT, merge3.getTimeLimit()); assertNotEquals(base.getState(), merge3.getState()); for (int i = 0; i < RECORD_SCAN_LIMIT + 1; i++) { assertTrue(merge3.getState().getRecordScanLimiter().tryRecordScan()); } assertFalse(merge3.getState().getRecordScanLimiter().tryRecordScan()); }
@Nonnull public ExecuteProperties setLimitsFrom(@Nonnull ExecuteProperties other) { ExecuteProperties.Builder builder = toBuilder(); if (other.rowLimit != ReadTransaction.ROW_LIMIT_UNLIMITED) { builder.setReturnedRowLimit(other.rowLimit); } if (other.timeLimit != UNLIMITED_TIME) { builder.setTimeLimit(other.timeLimit); } if (other.state.getRecordScanLimiter().isEnforcing() || other.state.getByteScanLimiter().isEnforcing()) { builder.setState(other.state); } return builder.build(); }
ExecuteProperties { @Nonnull public ExecuteProperties setLimitsFrom(@Nonnull ExecuteProperties other) { ExecuteProperties.Builder builder = toBuilder(); if (other.rowLimit != ReadTransaction.ROW_LIMIT_UNLIMITED) { builder.setReturnedRowLimit(other.rowLimit); } if (other.timeLimit != UNLIMITED_TIME) { builder.setTimeLimit(other.timeLimit); } if (other.state.getRecordScanLimiter().isEnforcing() || other.state.getByteScanLimiter().isEnforcing()) { builder.setState(other.state); } return builder.build(); } }
ExecuteProperties { @Nonnull public ExecuteProperties setLimitsFrom(@Nonnull ExecuteProperties other) { ExecuteProperties.Builder builder = toBuilder(); if (other.rowLimit != ReadTransaction.ROW_LIMIT_UNLIMITED) { builder.setReturnedRowLimit(other.rowLimit); } if (other.timeLimit != UNLIMITED_TIME) { builder.setTimeLimit(other.timeLimit); } if (other.state.getRecordScanLimiter().isEnforcing() || other.state.getByteScanLimiter().isEnforcing()) { builder.setState(other.state); } return builder.build(); } private  ExecuteProperties(int skip, int rowLimit, @Nonnull IsolationLevel isolationLevel, long timeLimit,
                              @Nonnull ExecuteState state, boolean failOnScanLimitReached, @Nonnull CursorStreamingMode defaultCursorStreamingMode); }
ExecuteProperties { @Nonnull public ExecuteProperties setLimitsFrom(@Nonnull ExecuteProperties other) { ExecuteProperties.Builder builder = toBuilder(); if (other.rowLimit != ReadTransaction.ROW_LIMIT_UNLIMITED) { builder.setReturnedRowLimit(other.rowLimit); } if (other.timeLimit != UNLIMITED_TIME) { builder.setTimeLimit(other.timeLimit); } if (other.state.getRecordScanLimiter().isEnforcing() || other.state.getByteScanLimiter().isEnforcing()) { builder.setState(other.state); } return builder.build(); } private  ExecuteProperties(int skip, int rowLimit, @Nonnull IsolationLevel isolationLevel, long timeLimit,
                              @Nonnull ExecuteState state, boolean failOnScanLimitReached, @Nonnull CursorStreamingMode defaultCursorStreamingMode); @Nonnull IsolationLevel getIsolationLevel(); int getSkip(); @Nonnull ExecuteProperties setSkip(final int skip); int getReturnedRowLimit(); @Nonnull ExecuteProperties setReturnedRowLimit(final int rowLimit); long getTimeLimit(); int getScannedRecordsLimit(); long getScannedBytesLimit(); @Nonnull ExecuteState getState(); @Nonnull ExecuteProperties setState(@Nonnull ExecuteState newState); @Nonnull ExecuteProperties clearState(); boolean isFailOnScanLimitReached(); ExecuteProperties setFailOnScanLimitReached(boolean failOnScanLimitReached); @Nonnull ExecuteProperties clearReturnedRowLimit(); @Nonnull ExecuteProperties clearRowAndTimeLimits(); @Nonnull ExecuteProperties clearSkipAndLimit(); @Nonnull ExecuteProperties clearSkipAndAdjustLimit(); int getReturnedRowLimitOrMax(); @Nonnull ExecuteProperties setLimitsFrom(@Nonnull ExecuteProperties other); CursorStreamingMode getDefaultCursorStreamingMode(); ExecuteProperties setDefaultCursorStreamingMode(CursorStreamingMode defaultCursorStreamingMode); @Nonnull ExecuteProperties resetState(); @Nonnull ScanProperties asScanProperties(boolean reverse); @Nonnull static Builder newBuilder(); @Nonnull Builder toBuilder(); @Nonnull @Override String toString(); }
ExecuteProperties { @Nonnull public ExecuteProperties setLimitsFrom(@Nonnull ExecuteProperties other) { ExecuteProperties.Builder builder = toBuilder(); if (other.rowLimit != ReadTransaction.ROW_LIMIT_UNLIMITED) { builder.setReturnedRowLimit(other.rowLimit); } if (other.timeLimit != UNLIMITED_TIME) { builder.setTimeLimit(other.timeLimit); } if (other.state.getRecordScanLimiter().isEnforcing() || other.state.getByteScanLimiter().isEnforcing()) { builder.setState(other.state); } return builder.build(); } private  ExecuteProperties(int skip, int rowLimit, @Nonnull IsolationLevel isolationLevel, long timeLimit,
                              @Nonnull ExecuteState state, boolean failOnScanLimitReached, @Nonnull CursorStreamingMode defaultCursorStreamingMode); @Nonnull IsolationLevel getIsolationLevel(); int getSkip(); @Nonnull ExecuteProperties setSkip(final int skip); int getReturnedRowLimit(); @Nonnull ExecuteProperties setReturnedRowLimit(final int rowLimit); long getTimeLimit(); int getScannedRecordsLimit(); long getScannedBytesLimit(); @Nonnull ExecuteState getState(); @Nonnull ExecuteProperties setState(@Nonnull ExecuteState newState); @Nonnull ExecuteProperties clearState(); boolean isFailOnScanLimitReached(); ExecuteProperties setFailOnScanLimitReached(boolean failOnScanLimitReached); @Nonnull ExecuteProperties clearReturnedRowLimit(); @Nonnull ExecuteProperties clearRowAndTimeLimits(); @Nonnull ExecuteProperties clearSkipAndLimit(); @Nonnull ExecuteProperties clearSkipAndAdjustLimit(); int getReturnedRowLimitOrMax(); @Nonnull ExecuteProperties setLimitsFrom(@Nonnull ExecuteProperties other); CursorStreamingMode getDefaultCursorStreamingMode(); ExecuteProperties setDefaultCursorStreamingMode(CursorStreamingMode defaultCursorStreamingMode); @Nonnull ExecuteProperties resetState(); @Nonnull ScanProperties asScanProperties(boolean reverse); @Nonnull static Builder newBuilder(); @Nonnull Builder toBuilder(); @Nonnull @Override String toString(); static final long UNLIMITED_TIME; static final ExecuteProperties SERIAL_EXECUTE; }