kamaci commented on a change in pull request #178: GORA-485 Apache Kudu datastore for Gora URL: https://github.com/apache/gora/pull/178#discussion_r310401137
########## File path: gora-kudu/src/main/java/org/apache/gora/kudu/store/KuduStore.java ########## @@ -0,0 +1,655 @@ +/* + * 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.gora.kudu.store; + +import org.apache.gora.kudu.query.KuduResult; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; +import org.apache.gora.kudu.mapping.Column; +import org.apache.gora.kudu.mapping.KuduMapping; +import org.apache.gora.kudu.mapping.KuduMappingBuilder; +import org.apache.gora.kudu.utils.KuduParameters; +import org.apache.gora.persistency.impl.PersistentBase; +import org.apache.gora.query.PartitionQuery; +import org.apache.gora.query.Query; +import org.apache.gora.query.Result; +import org.apache.gora.store.impl.DataStoreBase; +import org.apache.gora.util.AvroUtils; +import org.apache.gora.util.GoraException; +import org.apache.kudu.ColumnSchema; +import org.apache.avro.Schema; +import org.apache.avro.specific.SpecificDatumReader; +import org.apache.avro.specific.SpecificDatumWriter; +import org.apache.avro.util.Utf8; +import org.apache.gora.kudu.query.KuduQuery; +import org.apache.gora.kudu.utils.KuduClientUtils; +import org.apache.gora.persistency.Persistent; +import org.apache.gora.query.impl.PartitionQueryImpl; +import org.apache.gora.util.IOUtils; +import org.apache.kudu.Type; +import org.apache.kudu.client.CreateTableOptions; +import org.apache.kudu.client.Delete; +import org.apache.kudu.client.KuduClient; +import org.apache.kudu.client.KuduException; +import org.apache.kudu.client.KuduPredicate; +import org.apache.kudu.client.KuduScanner; +import org.apache.kudu.client.KuduSession; +import org.apache.kudu.client.KuduTable; +import org.apache.kudu.client.OperationResponse; +import org.apache.kudu.client.PartialRow; +import org.apache.kudu.client.RowResult; +import org.apache.kudu.client.RowResultIterator; +import org.apache.kudu.client.SessionConfiguration; +import org.apache.kudu.client.Update; +import org.apache.kudu.client.Upsert; +import org.apache.kudu.util.DecimalUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Implementation of a Apache Kudu data store to be used by Apache Gora. + * + * @param <K> class to be used for the key + * @param <T> class to be persisted within the store + */ +public class KuduStore<K, T extends PersistentBase> extends DataStoreBase<K, T> { + + private static final Logger LOG = LoggerFactory.getLogger(KuduStore.class); + private static final String PARSE_MAPPING_FILE_KEY = "gora.kudu.mapping.file"; + private static final String DEFAULT_MAPPING_FILE = "gora-kudu-mapping.xml"; + private static final String XML_MAPPING_DEFINITION = "gora.mapping"; + private KuduParameters kuduParameters; + private KuduMapping kuduMapping; + private KuduClient client; + private KuduSession session; + private KuduTable table; + + private static final ConcurrentHashMap<Schema, SpecificDatumReader<?>> readerMap = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap<Schema, SpecificDatumWriter<?>> writerMap = new ConcurrentHashMap<>(); + + @Override + public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException { + try { + super.initialize(keyClass, persistentClass, properties); + KuduMappingBuilder<K, T> builder = new KuduMappingBuilder<K, T>(this); + InputStream mappingStream; + if (properties.containsKey(XML_MAPPING_DEFINITION)) { + if (LOG.isTraceEnabled()) { + LOG.trace(XML_MAPPING_DEFINITION + " = " + properties.getProperty(XML_MAPPING_DEFINITION)); Review comment: Use parameterized logging. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services