You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metamodel.apache.org by ka...@apache.org on 2017/05/10 03:54:34 UTC
[32/43] metamodel git commit: Updated line-endings
Updated line-endings
Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/3f4c6d38
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/3f4c6d38
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/3f4c6d38
Branch: refs/heads/5.x
Commit: 3f4c6d38724efc4213cc055ad21e8841d9a3aa64
Parents: e68ef42
Author: Kasper Sørensen <i....@gmail.com>
Authored: Sun Nov 13 11:00:44 2016 -0800
Committer: Kasper Sørensen <i....@gmail.com>
Committed: Sun Nov 13 11:00:44 2016 -0800
----------------------------------------------------------------------
.../naming/AlphabeticColumnNamingStrategy.java | 86 ++---
.../schema/naming/ColumnNamingContext.java | 104 +++---
.../schema/naming/ColumnNamingContextImpl.java | 128 +++----
.../schema/naming/ColumnNamingStrategies.java | 90 ++---
.../schema/naming/ColumnNamingStrategy.java | 62 ++--
.../naming/CustomColumnNamingStrategy.java | 124 +++----
...tingIntrinsicSwitchColumnNamingStrategy.java | 120 +++---
.../naming/UniqueColumnNamingStrategy.java | 124 +++----
.../insert/AbstractRowInsertionBuilderTest.java | 98 ++---
.../rest/JestElasticSearchUpdateCallback.java | 330 ++++++++--------
.../fixedwidth/FixedWidthColumnSpec.java | 90 ++---
.../fixedwidth/FixedWidthConfiguration.java | 372 +++++++++----------
.../FixedWidthConfigurationReader.java | 352 +++++++++---------
.../FixedWidthConfigurationReaderTest.java | 178 ++++-----
.../src/test/resources/metadata_spec1/data.txt | 10 +-
.../metadata_spec1/sas-formatfile-metadata.txt | 8 +-
.../metadata_spec1/sas-input-metadata.txt | 38 +-
17 files changed, 1157 insertions(+), 1157 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
index f6575c7..34498de 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
@@ -1,43 +1,43 @@
-/**
- * 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.metamodel.schema.naming;
-
-import org.apache.metamodel.util.AlphabeticSequence;
-
-public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public ColumnNamingSession startColumnNamingSession() {
- return new ColumnNamingSession() {
- private final AlphabeticSequence seq = new AlphabeticSequence();
-
- @Override
- public String getNextColumnName(ColumnNamingContext ctx) {
- return seq.next();
- }
-
- @Override
- public void close() {
- }
- };
- }
-
-}
+/**
+ * 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.metamodel.schema.naming;
+
+import org.apache.metamodel.util.AlphabeticSequence;
+
+public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ColumnNamingSession startColumnNamingSession() {
+ return new ColumnNamingSession() {
+ private final AlphabeticSequence seq = new AlphabeticSequence();
+
+ @Override
+ public String getNextColumnName(ColumnNamingContext ctx) {
+ return seq.next();
+ }
+
+ @Override
+ public void close() {
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
index b613913..b43ad87 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
@@ -1,52 +1,52 @@
-/**
- * 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.metamodel.schema.naming;
-
-import org.apache.metamodel.schema.Table;
-
-/**
- * Defines the context for naming a single column in a
- * {@link ColumnNamingStrategy} session.
- */
-public interface ColumnNamingContext {
-
- /**
- * Gets the index of the column being named.
- *
- * @return
- */
- public int getColumnIndex();
-
- /**
- * Gets the {@link Table} that the column is to pertain to. If the table is
- * not yet available then this may return null.
- *
- * @return
- */
- public Table getTable();
-
- /**
- * Gets the intrinsic column name, if this is defined in the datastore
- * itself. This may be in the form of a header or such. Sometimes intrinsic
- * column names exist only for some columns and sometimes there may be
- * duplicate names or other anomalies which are often discouraged.
- *
- * @return
- */
- public String getIntrinsicColumnName();
-}
+/**
+ * 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.metamodel.schema.naming;
+
+import org.apache.metamodel.schema.Table;
+
+/**
+ * Defines the context for naming a single column in a
+ * {@link ColumnNamingStrategy} session.
+ */
+public interface ColumnNamingContext {
+
+ /**
+ * Gets the index of the column being named.
+ *
+ * @return
+ */
+ public int getColumnIndex();
+
+ /**
+ * Gets the {@link Table} that the column is to pertain to. If the table is
+ * not yet available then this may return null.
+ *
+ * @return
+ */
+ public Table getTable();
+
+ /**
+ * Gets the intrinsic column name, if this is defined in the datastore
+ * itself. This may be in the form of a header or such. Sometimes intrinsic
+ * column names exist only for some columns and sometimes there may be
+ * duplicate names or other anomalies which are often discouraged.
+ *
+ * @return
+ */
+ public String getIntrinsicColumnName();
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
index cc7a24e..ec77440 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
@@ -1,64 +1,64 @@
-/**
- * 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.metamodel.schema.naming;
-
-import org.apache.metamodel.schema.Table;
-
-public class ColumnNamingContextImpl implements ColumnNamingContext {
-
- private final int columnIndex;
- private final Table table;
- private final String intrinsicColumnName;
-
- /**
- *
- * @param table
- * @param intrinsicColumnName
- * @param columnIndex
- */
- public ColumnNamingContextImpl(Table table, String intrinsicColumnName, int columnIndex) {
- this.table = table;
- this.intrinsicColumnName = intrinsicColumnName;
- this.columnIndex = columnIndex;
- }
-
- /**
- *
- * @param columnIndex
- */
- public ColumnNamingContextImpl(int columnIndex) {
- this(null, null, columnIndex);
- }
-
- @Override
- public int getColumnIndex() {
- return columnIndex;
- }
-
- @Override
- public Table getTable() {
- return table;
- }
-
- @Override
- public String getIntrinsicColumnName() {
- return intrinsicColumnName;
- }
-
-}
+/**
+ * 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.metamodel.schema.naming;
+
+import org.apache.metamodel.schema.Table;
+
+public class ColumnNamingContextImpl implements ColumnNamingContext {
+
+ private final int columnIndex;
+ private final Table table;
+ private final String intrinsicColumnName;
+
+ /**
+ *
+ * @param table
+ * @param intrinsicColumnName
+ * @param columnIndex
+ */
+ public ColumnNamingContextImpl(Table table, String intrinsicColumnName, int columnIndex) {
+ this.table = table;
+ this.intrinsicColumnName = intrinsicColumnName;
+ this.columnIndex = columnIndex;
+ }
+
+ /**
+ *
+ * @param columnIndex
+ */
+ public ColumnNamingContextImpl(int columnIndex) {
+ this(null, null, columnIndex);
+ }
+
+ @Override
+ public int getColumnIndex() {
+ return columnIndex;
+ }
+
+ @Override
+ public Table getTable() {
+ return table;
+ }
+
+ @Override
+ public String getIntrinsicColumnName() {
+ return intrinsicColumnName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
index 0696376..f0da83a 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
@@ -1,45 +1,45 @@
-/**
- * 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.metamodel.schema.naming;
-
-import java.util.List;
-
-/**
- * Constructors and common utilities for {@link ColumnNamingStrategy} objects.
- */
-public class ColumnNamingStrategies {
-
- private static final DelegatingIntrinsicSwitchColumnNamingStrategy DEFAULT_STRATEGY = new DelegatingIntrinsicSwitchColumnNamingStrategy(
- new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
-
- private ColumnNamingStrategies() {
- }
-
- public static ColumnNamingStrategy defaultStrategy() {
- return DEFAULT_STRATEGY;
- }
-
- public static ColumnNamingStrategy customNames(List<String> columnNames) {
- return new CustomColumnNamingStrategy(columnNames);
- }
-
- public static ColumnNamingStrategy customNames(String ... columnNames) {
- return new CustomColumnNamingStrategy(columnNames);
- }
-}
+/**
+ * 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.metamodel.schema.naming;
+
+import java.util.List;
+
+/**
+ * Constructors and common utilities for {@link ColumnNamingStrategy} objects.
+ */
+public class ColumnNamingStrategies {
+
+ private static final DelegatingIntrinsicSwitchColumnNamingStrategy DEFAULT_STRATEGY = new DelegatingIntrinsicSwitchColumnNamingStrategy(
+ new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
+
+ private ColumnNamingStrategies() {
+ }
+
+ public static ColumnNamingStrategy defaultStrategy() {
+ return DEFAULT_STRATEGY;
+ }
+
+ public static ColumnNamingStrategy customNames(List<String> columnNames) {
+ return new CustomColumnNamingStrategy(columnNames);
+ }
+
+ public static ColumnNamingStrategy customNames(String ... columnNames) {
+ return new CustomColumnNamingStrategy(columnNames);
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
index 6ccccbf..27e85ea 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
@@ -1,31 +1,31 @@
-/**
- * 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.metamodel.schema.naming;
-
-import java.io.Serializable;
-
-/**
- * A strategy that defines how columns are logically named. Such strategies are
- * mostly used when a particular datastore is not itself intrinsically
- * specifying the column name.
- */
-public interface ColumnNamingStrategy extends Serializable {
-
- public ColumnNamingSession startColumnNamingSession();
-}
+/**
+ * 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.metamodel.schema.naming;
+
+import java.io.Serializable;
+
+/**
+ * A strategy that defines how columns are logically named. Such strategies are
+ * mostly used when a particular datastore is not itself intrinsically
+ * specifying the column name.
+ */
+public interface ColumnNamingStrategy extends Serializable {
+
+ public ColumnNamingSession startColumnNamingSession();
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
index e6cc706..39397d7 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
@@ -1,62 +1,62 @@
-/**
- * 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.metamodel.schema.naming;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * A {@link ColumnNamingStrategy} that allows the user to supply his own list of
- * custom column names.
- */
-public class CustomColumnNamingStrategy implements ColumnNamingStrategy {
-
- private static final long serialVersionUID = 1L;
-
- private final List<String> columnNames;
-
- public CustomColumnNamingStrategy(List<String> columnNames) {
- this.columnNames = columnNames;
- }
-
- public CustomColumnNamingStrategy(String... columnNames) {
- this(Arrays.asList(columnNames));
- }
-
- @Override
- public ColumnNamingSession startColumnNamingSession() {
- final Iterator<String> iterator = columnNames.iterator();
- return new ColumnNamingSession() {
-
- @Override
- public String getNextColumnName(ColumnNamingContext ctx) {
- if (iterator.hasNext()) {
- return iterator.next();
- }
- return null;
- }
-
- @Override
- public void close() {
- }
- };
- }
-
-}
+/**
+ * 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.metamodel.schema.naming;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * A {@link ColumnNamingStrategy} that allows the user to supply his own list of
+ * custom column names.
+ */
+public class CustomColumnNamingStrategy implements ColumnNamingStrategy {
+
+ private static final long serialVersionUID = 1L;
+
+ private final List<String> columnNames;
+
+ public CustomColumnNamingStrategy(List<String> columnNames) {
+ this.columnNames = columnNames;
+ }
+
+ public CustomColumnNamingStrategy(String... columnNames) {
+ this(Arrays.asList(columnNames));
+ }
+
+ @Override
+ public ColumnNamingSession startColumnNamingSession() {
+ final Iterator<String> iterator = columnNames.iterator();
+ return new ColumnNamingSession() {
+
+ @Override
+ public String getNextColumnName(ColumnNamingContext ctx) {
+ if (iterator.hasNext()) {
+ return iterator.next();
+ }
+ return null;
+ }
+
+ @Override
+ public void close() {
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
index e18cb3a..35a0f39 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
@@ -1,60 +1,60 @@
-/**
- * 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.metamodel.schema.naming;
-
-/**
- * A {@link ColumnNamingStrategy} that switches between two other
- * {@link ColumnNamingStrategy} delegates depending on the availability of a
- * intrinsic column name.
- */
-public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNamingStrategy {
-
- private static final long serialVersionUID = 1L;
- private final ColumnNamingStrategy intrinsicStrategy;
- private final ColumnNamingStrategy nonIntrinsicStrategy;
-
- public DelegatingIntrinsicSwitchColumnNamingStrategy(ColumnNamingStrategy intrinsicStrategy,
- ColumnNamingStrategy nonIntrinsicStrategy) {
- this.intrinsicStrategy = intrinsicStrategy;
- this.nonIntrinsicStrategy = nonIntrinsicStrategy;
- }
-
- @Override
- public ColumnNamingSession startColumnNamingSession() {
- final ColumnNamingSession intrinsicSession = intrinsicStrategy.startColumnNamingSession();
- final ColumnNamingSession nonIntrinsicSession = nonIntrinsicStrategy.startColumnNamingSession();
- return new ColumnNamingSession() {
-
- @Override
- public String getNextColumnName(ColumnNamingContext ctx) {
- final String intrinsicColumnName = ctx.getIntrinsicColumnName();
- if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {
- return nonIntrinsicSession.getNextColumnName(ctx);
- }
- return intrinsicSession.getNextColumnName(ctx);
- }
-
- @Override
- public void close() {
- intrinsicSession.close();
- nonIntrinsicSession.close();
- }
- };
- }
-}
+/**
+ * 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.metamodel.schema.naming;
+
+/**
+ * A {@link ColumnNamingStrategy} that switches between two other
+ * {@link ColumnNamingStrategy} delegates depending on the availability of a
+ * intrinsic column name.
+ */
+public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNamingStrategy {
+
+ private static final long serialVersionUID = 1L;
+ private final ColumnNamingStrategy intrinsicStrategy;
+ private final ColumnNamingStrategy nonIntrinsicStrategy;
+
+ public DelegatingIntrinsicSwitchColumnNamingStrategy(ColumnNamingStrategy intrinsicStrategy,
+ ColumnNamingStrategy nonIntrinsicStrategy) {
+ this.intrinsicStrategy = intrinsicStrategy;
+ this.nonIntrinsicStrategy = nonIntrinsicStrategy;
+ }
+
+ @Override
+ public ColumnNamingSession startColumnNamingSession() {
+ final ColumnNamingSession intrinsicSession = intrinsicStrategy.startColumnNamingSession();
+ final ColumnNamingSession nonIntrinsicSession = nonIntrinsicStrategy.startColumnNamingSession();
+ return new ColumnNamingSession() {
+
+ @Override
+ public String getNextColumnName(ColumnNamingContext ctx) {
+ final String intrinsicColumnName = ctx.getIntrinsicColumnName();
+ if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {
+ return nonIntrinsicSession.getNextColumnName(ctx);
+ }
+ return intrinsicSession.getNextColumnName(ctx);
+ }
+
+ @Override
+ public void close() {
+ intrinsicSession.close();
+ nonIntrinsicSession.close();
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
index d4d21dd..9321998 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
@@ -1,62 +1,62 @@
-/**
- * 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.metamodel.schema.naming;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but
- * ensures that all column names are unique. When duplicate names are
- * encountered a number will be appended yielding column names like "name",
- * "name_2", "name_3" etc.
- */
-public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public ColumnNamingSession startColumnNamingSession() {
- return new ColumnNamingSession() {
-
- private final Set<String> names = new HashSet<>();
-
- @Override
- public String getNextColumnName(ColumnNamingContext ctx) {
- final String intrinsicName = ctx.getIntrinsicColumnName();
- boolean unique = names.add(intrinsicName);
- if (unique) {
- return intrinsicName;
- }
-
- String newName = null;
- for (int i = 2; !unique; i++) {
- newName = intrinsicName + '_' + i;
- unique = names.add(newName);
- }
- return newName;
- }
-
- @Override
- public void close() {
- }
- };
- }
-
-}
+/**
+ * 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.metamodel.schema.naming;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but
+ * ensures that all column names are unique. When duplicate names are
+ * encountered a number will be appended yielding column names like "name",
+ * "name_2", "name_3" etc.
+ */
+public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ColumnNamingSession startColumnNamingSession() {
+ return new ColumnNamingSession() {
+
+ private final Set<String> names = new HashSet<>();
+
+ @Override
+ public String getNextColumnName(ColumnNamingContext ctx) {
+ final String intrinsicName = ctx.getIntrinsicColumnName();
+ boolean unique = names.add(intrinsicName);
+ if (unique) {
+ return intrinsicName;
+ }
+
+ String newName = null;
+ for (int i = 2; !unique; i++) {
+ newName = intrinsicName + '_' + i;
+ unique = names.add(newName);
+ }
+ return newName;
+ }
+
+ @Override
+ public void close() {
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java b/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
index fc9f6bd..1b8ea7c 100644
--- a/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
+++ b/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
@@ -1,49 +1,49 @@
-/**
- * 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.metamodel.insert;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.metamodel.MetaModelException;
-import org.apache.metamodel.UpdateCallback;
-import org.apache.metamodel.schema.MutableColumn;
-import org.apache.metamodel.schema.MutableTable;
-import org.junit.Test;
-
-public class AbstractRowInsertionBuilderTest {
-
- @Test
- public void testToString() {
- final MutableTable table = new MutableTable("tbl");
- final MutableColumn col1 = new MutableColumn("col1").setTable(table);
- final MutableColumn col2 = new MutableColumn("col2").setTable(table);
- table.addColumn(col1).addColumn(col2);
-
- final AbstractRowInsertionBuilder<UpdateCallback> builder = new AbstractRowInsertionBuilder<UpdateCallback>(
- null, table) {
- @Override
- public void execute() throws MetaModelException {
- throw new UnsupportedOperationException();
- }
- };
-
- builder.value(col1, "value1").value(col2, "value2");
- assertEquals("INSERT INTO tbl(col1,col2) VALUES (\"value1\",\"value2\")", builder.toString());
- }
-}
+/**
+ * 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.metamodel.insert;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.schema.MutableColumn;
+import org.apache.metamodel.schema.MutableTable;
+import org.junit.Test;
+
+public class AbstractRowInsertionBuilderTest {
+
+ @Test
+ public void testToString() {
+ final MutableTable table = new MutableTable("tbl");
+ final MutableColumn col1 = new MutableColumn("col1").setTable(table);
+ final MutableColumn col2 = new MutableColumn("col2").setTable(table);
+ table.addColumn(col1).addColumn(col2);
+
+ final AbstractRowInsertionBuilder<UpdateCallback> builder = new AbstractRowInsertionBuilder<UpdateCallback>(
+ null, table) {
+ @Override
+ public void execute() throws MetaModelException {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ builder.value(col1, "value1").value(col2, "value2");
+ assertEquals("INSERT INTO tbl(col1,col2) VALUES (\"value1\",\"value2\")", builder.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
index 521955d..94e557c 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
@@ -1,165 +1,165 @@
-/**
- * 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.metamodel.elasticsearch.rest;
-
-import java.util.List;
-
-import org.apache.metamodel.AbstractUpdateCallback;
-import org.apache.metamodel.MetaModelException;
-import org.apache.metamodel.UpdateCallback;
-import org.apache.metamodel.create.TableCreationBuilder;
-import org.apache.metamodel.delete.RowDeletionBuilder;
-import org.apache.metamodel.drop.TableDropBuilder;
-import org.apache.metamodel.insert.RowInsertionBuilder;
-import org.apache.metamodel.schema.Schema;
-import org.apache.metamodel.schema.Table;
-import org.elasticsearch.action.bulk.BulkRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import io.searchbox.action.Action;
-import io.searchbox.action.BulkableAction;
-import io.searchbox.client.JestResult;
-import io.searchbox.core.Bulk;
-import io.searchbox.core.Bulk.Builder;
-import io.searchbox.core.BulkResult;
-import io.searchbox.core.BulkResult.BulkResultItem;
-import io.searchbox.indices.Refresh;
-
-/**
- * {@link UpdateCallback} implementation for
- * {@link ElasticSearchRestDataContext}.
- */
-final class JestElasticSearchUpdateCallback extends AbstractUpdateCallback {
-
- private static final Logger logger = LoggerFactory.getLogger(JestElasticSearchUpdateCallback.class);
-
- private static final int BULK_BUFFER_SIZE = 1000;
-
- private Bulk.Builder bulkBuilder;
- private int bulkActionCount = 0;
- private final boolean isBatch;
-
- public JestElasticSearchUpdateCallback(ElasticSearchRestDataContext dataContext, boolean isBatch) {
- super(dataContext);
- this.isBatch = isBatch;
- }
-
- private boolean isBatch() {
- return isBatch;
- }
-
- @Override
- public ElasticSearchRestDataContext getDataContext() {
- return (ElasticSearchRestDataContext) super.getDataContext();
- }
-
- @Override
- public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
- IllegalStateException {
- return new JestElasticSearchCreateTableBuilder(this, schema, name);
- }
-
- @Override
- public boolean isDropTableSupported() {
- return true;
- }
-
- @Override
- public TableDropBuilder dropTable(Table table) throws IllegalArgumentException, IllegalStateException,
- UnsupportedOperationException {
- return new JestElasticSearchDropTableBuilder(this, table);
- }
-
- @Override
- public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException,
- UnsupportedOperationException {
- return new JestElasticSearchInsertBuilder(this, table);
- }
-
- @Override
- public boolean isDeleteSupported() {
- return true;
- }
-
- @Override
- public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
- UnsupportedOperationException {
- return new JestElasticSearchDeleteBuilder(this, table);
- }
-
- public void onExecuteUpdateFinished() {
- if (isBatch()) {
- flushBulkActions();
- }
-
- final String indexName = getDataContext().getIndexName();
- final Refresh refresh = new Refresh.Builder().addIndex(indexName).build();
-
- JestClientExecutor.execute(getDataContext().getElasticSearchClient(), refresh, false);
- }
-
- private void flushBulkActions() {
- if (bulkBuilder == null || bulkActionCount == 0) {
- // nothing to flush
- return;
- }
- final Bulk bulk = getBulkBuilder().build();
- logger.info("Flushing {} actions to ElasticSearch index {}", bulkActionCount, getDataContext().getIndexName());
- executeBlocking(bulk);
-
- bulkActionCount = 0;
- bulkBuilder = null;
- }
-
- public void execute(Action<?> action) {
- if (isBatch() && action instanceof BulkableAction) {
- final Bulk.Builder bulkBuilder = getBulkBuilder();
- bulkBuilder.addAction((BulkableAction<?>) action);
- bulkActionCount++;
- if (bulkActionCount == BULK_BUFFER_SIZE) {
- flushBulkActions();
- }
- } else {
- executeBlocking(action);
- }
- }
-
- private void executeBlocking(Action<?> action) {
- final JestResult result = JestClientExecutor.execute(getDataContext().getElasticSearchClient(), action);
- if (!result.isSucceeded()) {
- if (result instanceof BulkResult) {
- final List<BulkResultItem> failedItems = ((BulkResult) result).getFailedItems();
- for (int i = 0; i < failedItems.size(); i++) {
- final BulkResultItem failedItem = failedItems.get(i);
- logger.error("Bulk failed with item no. {} of {}: id={} op={} status={} error={}", i+1, failedItems.size(), failedItem.id, failedItem.operation, failedItem.status, failedItem.error);
- }
- }
- throw new MetaModelException(result.getResponseCode() + " - " + result.getErrorMessage());
- }
- }
-
- private Builder getBulkBuilder() {
- if (bulkBuilder == null) {
- bulkBuilder = new Bulk.Builder();
- bulkBuilder.defaultIndex(getDataContext().getIndexName());
- }
- return bulkBuilder;
- }
-}
+/**
+ * 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.metamodel.elasticsearch.rest;
+
+import java.util.List;
+
+import org.apache.metamodel.AbstractUpdateCallback;
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.create.TableCreationBuilder;
+import org.apache.metamodel.delete.RowDeletionBuilder;
+import org.apache.metamodel.drop.TableDropBuilder;
+import org.apache.metamodel.insert.RowInsertionBuilder;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.searchbox.action.Action;
+import io.searchbox.action.BulkableAction;
+import io.searchbox.client.JestResult;
+import io.searchbox.core.Bulk;
+import io.searchbox.core.Bulk.Builder;
+import io.searchbox.core.BulkResult;
+import io.searchbox.core.BulkResult.BulkResultItem;
+import io.searchbox.indices.Refresh;
+
+/**
+ * {@link UpdateCallback} implementation for
+ * {@link ElasticSearchRestDataContext}.
+ */
+final class JestElasticSearchUpdateCallback extends AbstractUpdateCallback {
+
+ private static final Logger logger = LoggerFactory.getLogger(JestElasticSearchUpdateCallback.class);
+
+ private static final int BULK_BUFFER_SIZE = 1000;
+
+ private Bulk.Builder bulkBuilder;
+ private int bulkActionCount = 0;
+ private final boolean isBatch;
+
+ public JestElasticSearchUpdateCallback(ElasticSearchRestDataContext dataContext, boolean isBatch) {
+ super(dataContext);
+ this.isBatch = isBatch;
+ }
+
+ private boolean isBatch() {
+ return isBatch;
+ }
+
+ @Override
+ public ElasticSearchRestDataContext getDataContext() {
+ return (ElasticSearchRestDataContext) super.getDataContext();
+ }
+
+ @Override
+ public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
+ IllegalStateException {
+ return new JestElasticSearchCreateTableBuilder(this, schema, name);
+ }
+
+ @Override
+ public boolean isDropTableSupported() {
+ return true;
+ }
+
+ @Override
+ public TableDropBuilder dropTable(Table table) throws IllegalArgumentException, IllegalStateException,
+ UnsupportedOperationException {
+ return new JestElasticSearchDropTableBuilder(this, table);
+ }
+
+ @Override
+ public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException,
+ UnsupportedOperationException {
+ return new JestElasticSearchInsertBuilder(this, table);
+ }
+
+ @Override
+ public boolean isDeleteSupported() {
+ return true;
+ }
+
+ @Override
+ public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
+ UnsupportedOperationException {
+ return new JestElasticSearchDeleteBuilder(this, table);
+ }
+
+ public void onExecuteUpdateFinished() {
+ if (isBatch()) {
+ flushBulkActions();
+ }
+
+ final String indexName = getDataContext().getIndexName();
+ final Refresh refresh = new Refresh.Builder().addIndex(indexName).build();
+
+ JestClientExecutor.execute(getDataContext().getElasticSearchClient(), refresh, false);
+ }
+
+ private void flushBulkActions() {
+ if (bulkBuilder == null || bulkActionCount == 0) {
+ // nothing to flush
+ return;
+ }
+ final Bulk bulk = getBulkBuilder().build();
+ logger.info("Flushing {} actions to ElasticSearch index {}", bulkActionCount, getDataContext().getIndexName());
+ executeBlocking(bulk);
+
+ bulkActionCount = 0;
+ bulkBuilder = null;
+ }
+
+ public void execute(Action<?> action) {
+ if (isBatch() && action instanceof BulkableAction) {
+ final Bulk.Builder bulkBuilder = getBulkBuilder();
+ bulkBuilder.addAction((BulkableAction<?>) action);
+ bulkActionCount++;
+ if (bulkActionCount == BULK_BUFFER_SIZE) {
+ flushBulkActions();
+ }
+ } else {
+ executeBlocking(action);
+ }
+ }
+
+ private void executeBlocking(Action<?> action) {
+ final JestResult result = JestClientExecutor.execute(getDataContext().getElasticSearchClient(), action);
+ if (!result.isSucceeded()) {
+ if (result instanceof BulkResult) {
+ final List<BulkResultItem> failedItems = ((BulkResult) result).getFailedItems();
+ for (int i = 0; i < failedItems.size(); i++) {
+ final BulkResultItem failedItem = failedItems.get(i);
+ logger.error("Bulk failed with item no. {} of {}: id={} op={} status={} error={}", i+1, failedItems.size(), failedItem.id, failedItem.operation, failedItem.status, failedItem.error);
+ }
+ }
+ throw new MetaModelException(result.getResponseCode() + " - " + result.getErrorMessage());
+ }
+ }
+
+ private Builder getBulkBuilder() {
+ if (bulkBuilder == null) {
+ bulkBuilder = new Bulk.Builder();
+ bulkBuilder.defaultIndex(getDataContext().getIndexName());
+ }
+ return bulkBuilder;
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
index dedfbcd..5f53ff5 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
@@ -1,45 +1,45 @@
-/**
- * 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.metamodel.fixedwidth;
-
-import org.apache.metamodel.util.HasName;
-
-/**
- * Represents the specification of a single column for a
- * {@link FixedWidthDataContext}.
- */
-final class FixedWidthColumnSpec implements HasName {
-
- private final String name;
- private final int width;
-
- public FixedWidthColumnSpec(String name, int width) {
- this.name = name;
- this.width = width;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- public int getWidth() {
- return width;
- }
-}
+/**
+ * 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.metamodel.fixedwidth;
+
+import org.apache.metamodel.util.HasName;
+
+/**
+ * Represents the specification of a single column for a
+ * {@link FixedWidthDataContext}.
+ */
+final class FixedWidthColumnSpec implements HasName {
+
+ private final String name;
+ private final int width;
+
+ public FixedWidthColumnSpec(String name, int width) {
+ this.name = name;
+ this.width = width;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+}
http://git-wip-us.apache.org/repos/asf/metamodel/blob/3f4c6d38/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
index c53ff16..79aac36 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@ -1,186 +1,186 @@
-/**
- * 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.metamodel.fixedwidth;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.metamodel.data.DataSet;
-import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
-import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
-import org.apache.metamodel.util.BaseObject;
-import org.apache.metamodel.util.CollectionUtils;
-import org.apache.metamodel.util.FileHelper;
-import org.apache.metamodel.util.HasNameMapper;
-
-/**
- * Configuration of metadata about a fixed width values data context.
- */
-public class FixedWidthConfiguration extends BaseObject implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final int NO_COLUMN_NAME_LINE = 0;
- public static final int DEFAULT_COLUMN_NAME_LINE = 1;
-
- private final String encoding;
- private final int fixedValueWidth;
- private final int[] valueWidths;
- private final int columnNameLineNumber;
- private final boolean failOnInconsistentLineWidth;
- private final ColumnNamingStrategy columnNamingStrategy;
-
- public FixedWidthConfiguration(int fixedValueWidth) {
- this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, fixedValueWidth);
- }
-
- public FixedWidthConfiguration(int[] valueWidth) {
- this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, valueWidth, false);
- }
-
- public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth) {
- this(columnNameLineNumber, encoding, fixedValueWidth, false);
- }
-
- public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth,
- boolean failOnInconsistentLineWidth) {
- this.encoding = encoding;
- this.fixedValueWidth = fixedValueWidth;
- this.columnNameLineNumber = columnNameLineNumber;
- this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
- this.columnNamingStrategy = null;
- this.valueWidths = new int[0];
- }
-
- public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int[] valueWidths,
- boolean failOnInconsistentLineWidth) {
- this(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);
- }
-
- public FixedWidthConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,
- int[] valueWidths, boolean failOnInconsistentLineWidth) {
- this.encoding = encoding;
- this.fixedValueWidth = -1;
- this.columnNameLineNumber = columnNameLineNumber;
- this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
- this.columnNamingStrategy = columnNamingStrategy;
- this.valueWidths = valueWidths;
- }
-
- public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs) {
- this(encoding, columnSpecs, false);
- }
-
- public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs,
- boolean failOnInconsistentLineWidth) {
- this.encoding = encoding;
- this.fixedValueWidth = -1;
- this.columnNameLineNumber = NO_COLUMN_NAME_LINE;
- this.columnNamingStrategy = ColumnNamingStrategies.customNames(CollectionUtils.map(columnSpecs,
- new HasNameMapper()));
- this.valueWidths = new int[columnSpecs.size()];
- for (int i = 0; i < valueWidths.length; i++) {
- valueWidths[i] = columnSpecs.get(i).getWidth();
- }
- this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
- }
-
- /**
- * The line number (1 based) from which to get the names of the columns.
- *
- * @return an int representing the line number of the column headers/names.
- */
- public int getColumnNameLineNumber() {
- return columnNameLineNumber;
- }
-
- /**
- * Gets a {@link ColumnNamingStrategy} to use if needed.
- * @return column naming strategy
- */
- public ColumnNamingStrategy getColumnNamingStrategy() {
- if (columnNamingStrategy == null) {
- return ColumnNamingStrategies.defaultStrategy();
- }
- return columnNamingStrategy;
- }
-
- /**
- * Gets the file encoding to use for reading the file.
- *
- * @return the text encoding to use for reading the file.
- */
- public String getEncoding() {
- return encoding;
- }
-
- /**
- * Gets the width of each value within the fixed width value file.
- *
- * @return the fixed width to use when parsing the file.
- */
- public int getFixedValueWidth() {
- return fixedValueWidth;
- }
-
- public int[] getValueWidths() {
- return valueWidths;
- }
-
- /**
- * Determines if the {@link DataSet#next()} should throw an exception in
- * case of inconsistent line width in the fixed width value file.
- *
- * @return a boolean indicating whether or not to fail on inconsistent line
- * widths.
- */
- public boolean isFailOnInconsistentLineWidth() {
- return failOnInconsistentLineWidth;
- }
-
- @Override
- protected void decorateIdentity(List<Object> identifiers) {
- identifiers.add(columnNameLineNumber);
- identifiers.add(encoding);
- identifiers.add(fixedValueWidth);
- identifiers.add(valueWidths);
- identifiers.add(failOnInconsistentLineWidth);
- }
-
- @Override
- public String toString() {
- return "FixedWidthConfiguration[encoding=" + encoding
- + ", fixedValueWidth=" + fixedValueWidth + ", valueWidths="
- + Arrays.toString(valueWidths) + ", columnNameLineNumber="
- + columnNameLineNumber + ", failOnInconsistentLineWidth="
- + failOnInconsistentLineWidth + "]";
- }
-
- public boolean isConstantValueWidth() {
- return fixedValueWidth != -1;
- }
-
- public int getValueWidth(int columnIndex) {
- if (isConstantValueWidth()) {
- return fixedValueWidth;
- }
- return valueWidths[columnIndex];
- }
-}
+/**
+ * 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.metamodel.fixedwidth;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
+import org.apache.metamodel.util.BaseObject;
+import org.apache.metamodel.util.CollectionUtils;
+import org.apache.metamodel.util.FileHelper;
+import org.apache.metamodel.util.HasNameMapper;
+
+/**
+ * Configuration of metadata about a fixed width values data context.
+ */
+public class FixedWidthConfiguration extends BaseObject implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final int NO_COLUMN_NAME_LINE = 0;
+ public static final int DEFAULT_COLUMN_NAME_LINE = 1;
+
+ private final String encoding;
+ private final int fixedValueWidth;
+ private final int[] valueWidths;
+ private final int columnNameLineNumber;
+ private final boolean failOnInconsistentLineWidth;
+ private final ColumnNamingStrategy columnNamingStrategy;
+
+ public FixedWidthConfiguration(int fixedValueWidth) {
+ this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, fixedValueWidth);
+ }
+
+ public FixedWidthConfiguration(int[] valueWidth) {
+ this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, valueWidth, false);
+ }
+
+ public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth) {
+ this(columnNameLineNumber, encoding, fixedValueWidth, false);
+ }
+
+ public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth,
+ boolean failOnInconsistentLineWidth) {
+ this.encoding = encoding;
+ this.fixedValueWidth = fixedValueWidth;
+ this.columnNameLineNumber = columnNameLineNumber;
+ this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+ this.columnNamingStrategy = null;
+ this.valueWidths = new int[0];
+ }
+
+ public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int[] valueWidths,
+ boolean failOnInconsistentLineWidth) {
+ this(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);
+ }
+
+ public FixedWidthConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,
+ int[] valueWidths, boolean failOnInconsistentLineWidth) {
+ this.encoding = encoding;
+ this.fixedValueWidth = -1;
+ this.columnNameLineNumber = columnNameLineNumber;
+ this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+ this.columnNamingStrategy = columnNamingStrategy;
+ this.valueWidths = valueWidths;
+ }
+
+ public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs) {
+ this(encoding, columnSpecs, false);
+ }
+
+ public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs,
+ boolean failOnInconsistentLineWidth) {
+ this.encoding = encoding;
+ this.fixedValueWidth = -1;
+ this.columnNameLineNumber = NO_COLUMN_NAME_LINE;
+ this.columnNamingStrategy = ColumnNamingStrategies.customNames(CollectionUtils.map(columnSpecs,
+ new HasNameMapper()));
+ this.valueWidths = new int[columnSpecs.size()];
+ for (int i = 0; i < valueWidths.length; i++) {
+ valueWidths[i] = columnSpecs.get(i).getWidth();
+ }
+ this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+ }
+
+ /**
+ * The line number (1 based) from which to get the names of the columns.
+ *
+ * @return an int representing the line number of the column headers/names.
+ */
+ public int getColumnNameLineNumber() {
+ return columnNameLineNumber;
+ }
+
+ /**
+ * Gets a {@link ColumnNamingStrategy} to use if needed.
+ * @return column naming strategy
+ */
+ public ColumnNamingStrategy getColumnNamingStrategy() {
+ if (columnNamingStrategy == null) {
+ return ColumnNamingStrategies.defaultStrategy();
+ }
+ return columnNamingStrategy;
+ }
+
+ /**
+ * Gets the file encoding to use for reading the file.
+ *
+ * @return the text encoding to use for reading the file.
+ */
+ public String getEncoding() {
+ return encoding;
+ }
+
+ /**
+ * Gets the width of each value within the fixed width value file.
+ *
+ * @return the fixed width to use when parsing the file.
+ */
+ public int getFixedValueWidth() {
+ return fixedValueWidth;
+ }
+
+ public int[] getValueWidths() {
+ return valueWidths;
+ }
+
+ /**
+ * Determines if the {@link DataSet#next()} should throw an exception in
+ * case of inconsistent line width in the fixed width value file.
+ *
+ * @return a boolean indicating whether or not to fail on inconsistent line
+ * widths.
+ */
+ public boolean isFailOnInconsistentLineWidth() {
+ return failOnInconsistentLineWidth;
+ }
+
+ @Override
+ protected void decorateIdentity(List<Object> identifiers) {
+ identifiers.add(columnNameLineNumber);
+ identifiers.add(encoding);
+ identifiers.add(fixedValueWidth);
+ identifiers.add(valueWidths);
+ identifiers.add(failOnInconsistentLineWidth);
+ }
+
+ @Override
+ public String toString() {
+ return "FixedWidthConfiguration[encoding=" + encoding
+ + ", fixedValueWidth=" + fixedValueWidth + ", valueWidths="
+ + Arrays.toString(valueWidths) + ", columnNameLineNumber="
+ + columnNameLineNumber + ", failOnInconsistentLineWidth="
+ + failOnInconsistentLineWidth + "]";
+ }
+
+ public boolean isConstantValueWidth() {
+ return fixedValueWidth != -1;
+ }
+
+ public int getValueWidth(int columnIndex) {
+ if (isConstantValueWidth()) {
+ return fixedValueWidth;
+ }
+ return valueWidths[columnIndex];
+ }
+}