flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] fhueske commented on a change in pull request #6621: [FLINK-8686] [sql-client] Limit result size for prototyping modes
Date Mon, 27 Aug 2018 15:44:06 GMT
fhueske commented on a change in pull request #6621:  [FLINK-8686] [sql-client] Limit result
size for prototyping modes
URL: https://github.com/apache/flink/pull/6621#discussion_r213021336
 
 

 ##########
 File path: flink-libraries/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/result/MaterializedCollectStreamResult.java
 ##########
 @@ -112,30 +129,43 @@ else if (!isRetrieving()) {
 	@Override
 	protected void processRecord(Tuple2<Boolean, Row> change) {
 		synchronized (resultLock) {
-			final Row row = change.f1;
 			// insert
 			if (change.f0) {
-				materializedTable.add(row);
-				rowPositionCache.put(row, materializedTable.size() - 1);
+				processInsert(change.f1);
 			}
 			// delete
 			else {
-				// delete the newest record first to minimize per-page changes
-				final Integer cachedPos = rowPositionCache.get(row);
-				final int startSearchPos;
-				if (cachedPos != null) {
-					startSearchPos = Math.min(cachedPos, materializedTable.size() - 1);
-				} else {
-					startSearchPos = materializedTable.size() - 1;
-				}
-
-				for (int i = startSearchPos; i >= 0; i--) {
-					if (materializedTable.get(i).equals(row)) {
-						materializedTable.remove(i);
-						rowPositionCache.remove(row);
-						break;
-					}
-				}
+				processDelete(change.f1);
+			}
+		}
+	}
+
+	// --------------------------------------------------------------------------------------------
+
+	private void processInsert(Row row) {
+		// limit the materialized table
+		if (materializedTable.size() >= maxRowCount) {
+			processDelete(materializedTable.get(0));
 
 Review comment:
   Or we just set elements to `null` and have an `startOffset` counter that we increase.
   Once the counter equals `1000` (magic number!), we shrink the `ArrayList`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message