// Path: src/org/apache/solr/hadoop/HdfsFileFieldNames.java
// public interface HdfsFileFieldNames {
// 
//   public static final String FILE_UPLOAD_URL = "file_upload_url";
//   public static final String FILE_DOWNLOAD_URL = "file_download_url";
//   public static final String FILE_SCHEME = "file_scheme";
//   public static final String FILE_HOST = "file_host";
//   public static final String FILE_PORT = "file_port";
//   public static final String FILE_PATH = "file_path";
//   public static final String FILE_NAME = "file_name";
//   public static final String FILE_LENGTH = "file_length";
//   public static final String FILE_LAST_MODIFIED = "file_last_modified";
//   public static final String FILE_OWNER = "file_owner";
//   public static final String FILE_GROUP = "file_group";
//   public static final String FILE_PERMISSIONS_USER = "file_permissions_user";
//   public static final String FILE_PERMISSIONS_GROUP = "file_permissions_group";
//   public static final String FILE_PERMISSIONS_OTHER = "file_permissions_other";
//   public static final String FILE_PERMISSIONS_STICKYBIT = "file_permissions_stickybit";
// 
// }


import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer.Context;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.hadoop.HdfsFileFieldNames;
/*
 * 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.solr.hadoop.dedup;



/**
 * UpdateConflictResolver implementation that orders colliding updates ascending
 * from least recent to most recent (partial) update, based on a configurable
 * numeric Solr field, which defaults to the file_last_modified timestamp.
 */
public class SortingUpdateConflictResolver implements UpdateConflictResolver, Configurable {

  private Configuration conf;
  private String orderByFieldName = ORDER_BY_FIELD_NAME_DEFAULT;
  
  public static final String ORDER_BY_FIELD_NAME_KEY = 
      SortingUpdateConflictResolver.class.getName() + ".orderByFieldName";
  
// Path: src/org/apache/solr/hadoop/HdfsFileFieldNames.java
// public interface HdfsFileFieldNames {
// 
//   public static final String FILE_UPLOAD_URL = "file_upload_url";
//   public static final String FILE_DOWNLOAD_URL = "file_download_url";
//   public static final String FILE_SCHEME = "file_scheme";
//   public static final String FILE_HOST = "file_host";
//   public static final String FILE_PORT = "file_port";
//   public static final String FILE_PATH = "file_path";
//   public static final String FILE_NAME = "file_name";
//   public static final String FILE_LENGTH = "file_length";
//   public static final String FILE_LAST_MODIFIED = "file_last_modified";
//   public static final String FILE_OWNER = "file_owner";
//   public static final String FILE_GROUP = "file_group";
//   public static final String FILE_PERMISSIONS_USER = "file_permissions_user";
//   public static final String FILE_PERMISSIONS_GROUP = "file_permissions_group";
//   public static final String FILE_PERMISSIONS_OTHER = "file_permissions_other";
//   public static final String FILE_PERMISSIONS_STICKYBIT = "file_permissions_stickybit";
// 
// }


// Path: src/org/apache/solr/hadoop/dedup/SortingUpdateConflictResolver.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer.Context;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.hadoop.HdfsFileFieldNames;

/*
 * 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.solr.hadoop.dedup;



/**
 * UpdateConflictResolver implementation that orders colliding updates ascending
 * from least recent to most recent (partial) update, based on a configurable
 * numeric Solr field, which defaults to the file_last_modified timestamp.
 */
public class SortingUpdateConflictResolver implements UpdateConflictResolver, Configurable {

  private Configuration conf;
  private String orderByFieldName = ORDER_BY_FIELD_NAME_DEFAULT;
  
  public static final String ORDER_BY_FIELD_NAME_KEY = 
      SortingUpdateConflictResolver.class.getName() + ".orderByFieldName";
  
  public static final String ORDER_BY_FIELD_NAME_DEFAULT = HdfsFileFieldNames.FILE_LAST_MODIFIED;