Zhangyx39 commented on a change in pull request #986: SAMZA-2156: Couchbase support for Samza Table API URL: https://github.com/apache/samza/pull/986#discussion_r273203113
########## File path: samza-kv-remote/src/main/java/org/apache/samza/table/remote/couchbase/BaseCouchbaseTableFunction.java ########## @@ -0,0 +1,277 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.samza.table.remote.couchbase; + +import com.couchbase.client.java.Bucket; +import com.couchbase.client.java.error.TemporaryFailureException; +import com.couchbase.client.java.error.TemporaryLockFailureException; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.io.Serializable; +import java.time.Duration; +import java.util.List; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.samza.context.Context; +import org.apache.samza.operators.functions.ClosableFunction; +import org.apache.samza.operators.functions.InitableFunction; +import org.apache.samza.serializers.Serde; + + +/** + * Base class for {@link CouchbaseTableReadFunction} and {@link CouchbaseTableWriteFunction} + * @param <V> Type of values to read from / write to couchbase + */ +public abstract class BaseCouchbaseTableFunction<V> implements InitableFunction, ClosableFunction, Serializable { + + // Clients + private final static CouchbaseBucketRegistry COUCHBASE_BUCKET_REGISTRY = new CouchbaseBucketRegistry(); + protected transient Bucket bucket; + + // Function Settings + protected Serde<V> valueSerde = null; + protected Duration timeout = Duration.ZERO; // default value 0 means no timeout + protected Duration ttl = Duration.ZERO; // default value 0 means no ttl, data will be stored forever Review comment: These defaults are consistent with Couchbase client. Actually, even if I don't set ttl, it will still be 0 in a Couchbase document. So I use those default values to be consistent with Couchbase client API. Otherwise, we need to add extra logic to check those values in read/write function, making it a little more complicated. How do you think? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
