alfonsonishikawa commented on a change in pull request #178: GORA-485 Apache 
Kudu datastore for Gora
URL: https://github.com/apache/gora/pull/178#discussion_r317838072
 
 

 ##########
 File path: 
gora-kudu/src/main/java/org/apache/gora/kudu/mapping/KuduMappingBuilder.java
 ##########
 @@ -0,0 +1,162 @@
+/*
+ * 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.mapping;
+
+import com.google.inject.ConfigurationException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.invoke.MethodHandles;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.gora.kudu.store.KuduStore;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.util.GoraException;
+import org.apache.kudu.Type;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Builder for Mapping definitions of Kudu.
+ */
+public class KuduMappingBuilder<K, T extends PersistentBase> {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+  /**
+   * Mapping instance being built
+   */
+  private KuduMapping kuduMapping;
+
+  private final KuduStore<K, T> dataStore;
+
+  /**
+   * Constructor for KuduMappingBuilder
+   *
+   * @param store KuduStore instance
+   */
+  public KuduMappingBuilder(final KuduStore<K, T> store) {
+    this.kuduMapping = new KuduMapping();
+    this.dataStore = store;
+  }
+
+  /**
+   * Returns the Kudu Mapping being built
+   *
+   * @return Kudu Mapping instance
+   */
+  public KuduMapping getKuduMapping() {
+    return kuduMapping;
+  }
+
+  /**
+   * Reads Kudu mappings from file
+   *
+   * @param inputStream Mapping input stream
+   * @throws org.apache.gora.util.GoraException Error reading mapping file
+   */
+  public void readMappingFile(InputStream inputStream) throws GoraException {
+    try {
+      SAXBuilder saxBuilder = new SAXBuilder();
+      if (inputStream == null) {
+        LOG.error("The mapping input stream is null!");
+        throw new GoraException("The mapping input stream is null!");
+      }
+      Document document = saxBuilder.build(inputStream);
+      if (document == null) {
+        LOG.error("The mapping document is null!");
+        throw new GoraException("The mapping document is null!");
+      }
+      @SuppressWarnings("unchecked")
+      List<Element> classes = document.getRootElement().getChildren("class");
+      for (Element classElement : classes) {
 
 Review comment:
   After this `for` should fail if it does not find the needed mapping, like in 
https://github.com/apache/gora/blob/apache-gora-0.9/gora-hbase/src/main/java/org/apache/gora/hbase/store/HBaseStore.java#L822

----------------------------------------------------------------
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

Reply via email to