Github user vdiravka commented on a diff in the pull request:

    https://github.com/apache/drill/pull/877#discussion_r132533745
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/MetadataVersion.java
 ---
    @@ -0,0 +1,156 @@
    +/*
    + * 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
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * 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.drill.exec.store.parquet;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.ComparisonChain;
    +import com.google.common.collect.ImmutableSortedSet;
    +import org.apache.drill.common.exceptions.DrillRuntimeException;
    +
    +import java.util.SortedSet;
    +import java.util.regex.Matcher;
    +import java.util.regex.Pattern;
    +
    +
    +public class MetadataVersion implements Comparable<MetadataVersion> {
    +
    +  private static final String FORMAT = "v?((?!0)\\d+)(\\.(\\d+))?";
    +  private static final Pattern PATTERN = Pattern.compile(FORMAT);
    +
    +  private final int major;
    +  private final int minor;
    +
    +  public MetadataVersion(int major, int minor) {
    +    this.major = major;
    +    this.minor = minor;
    +  }
    +
    +  public MetadataVersion(String metadataVersion) {
    +    Matcher matcher = PATTERN.matcher(metadataVersion);
    +    if (!matcher.matches()) {
    +      DrillRuntimeException.format("Could not parse metadata version '%s' 
using format '%s'", metadataVersion, FORMAT);
    +    }
    +    this.major = Integer.parseInt(matcher.group(1));
    +    this.minor = matcher.group(3) != null ? 
Integer.parseInt(matcher.group(3)) : 0;
    +  }
    +
    +  public int getMajor() {
    +    return major;
    +  }
    +
    +  public int getMinor() {
    +    return minor;
    +  }
    +
    +  @Override
    +  public boolean equals(Object o) {
    +    if (this == o) {
    +      return true;
    +    }
    +    if (!(o instanceof MetadataVersion)) {
    +      return false;
    +    }
    +    MetadataVersion that = (MetadataVersion) o;
    +    return this.major == that.major
    +        && this.minor == that.minor;
    +  }
    +
    +  @Override
    +  public int hashCode() {
    +    int result = major;
    +    result = 31 * result + minor;
    +    return result;
    +  }
    +
    +  /**
    +   * @return string representation of the metadata file version, for 
example: "v1", "v10", "v4.13"
    +   * <p>
    +   * String metadata version consists of the following characters:<p>
    +   * optional "v" letter,<p>
    --- End diff --
    
    Done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to