|
||||
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 package org.apache.spark.sql.connector.read.streaming; 0019 0020 import org.apache.spark.annotation.Evolving; 0021 0022 /** 0023 * An abstract representation of progress through a {@link MicroBatchStream} or 0024 * {@link ContinuousStream}. 0025 * During execution, offsets provided by the data source implementation will be logged and used as 0026 * restart checkpoints. Each source should provide an offset implementation which the source can use 0027 * to reconstruct a position in the stream up to which data has been seen/processed. 0028 * 0029 * @since 3.0.0 0030 */ 0031 @Evolving 0032 public abstract class Offset { 0033 /** 0034 * A JSON-serialized representation of an Offset that is 0035 * used for saving offsets to the offset log. 0036 * Note: We assume that equivalent/equal offsets serialize to 0037 * identical JSON strings. 0038 * 0039 * @return JSON string encoding 0040 */ 0041 public abstract String json(); 0042 0043 /** 0044 * Equality based on JSON string representation. We leverage the 0045 * JSON representation for normalization between the Offset's 0046 * in deserialized and serialized representations. 0047 */ 0048 @Override 0049 public boolean equals(Object obj) { 0050 if (obj instanceof Offset) { 0051 return this.json().equals(((Offset) obj).json()); 0052 } else { 0053 return false; 0054 } 0055 } 0056 0057 @Override 0058 public int hashCode() { 0059 return this.json().hashCode(); 0060 } 0061 0062 @Override 0063 public String toString() { 0064 return this.json(); 0065 } 0066 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |