gjacoby126 commented on a change in pull request #750: PHOENIX-5799 - Inline Index Verification Output API URL: https://github.com/apache/phoenix/pull/750#discussion_r404312606
########## File path: phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java ########## @@ -0,0 +1,285 @@ +/* + * 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.phoenix.mapreduce.index; + +import com.google.common.annotations.VisibleForTesting; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.hbase.client.ResultScanner; +import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.phoenix.coprocessor.MetaDataProtocol; +import org.apache.phoenix.hbase.index.table.HTableFactory; +import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.util.ByteUtil; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class IndexVerificationOutputRepository { + public static final byte[] ROW_KEY_SEPARATOR_BYTE = Bytes.toBytes("|"); + private Table indexHTable; + private byte[] indexName; + private Table outputHTable; + public final static String OUTPUT_TABLE_NAME = "PHOENIX_INDEX_TOOL"; + public final static byte[] OUTPUT_TABLE_NAME_BYTES = Bytes.toBytes(OUTPUT_TABLE_NAME); + public final static byte[] OUTPUT_TABLE_COLUMN_FAMILY = QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES; + + public final static String DATA_TABLE_NAME = "DTName"; + public final static byte[] DATA_TABLE_NAME_BYTES = Bytes.toBytes(DATA_TABLE_NAME); + public static String INDEX_TABLE_NAME = "ITName"; + public final static byte[] INDEX_TABLE_NAME_BYTES = Bytes.toBytes(INDEX_TABLE_NAME); + public static String DATA_TABLE_ROW_KEY = "DTRowKey"; + public final static byte[] DATA_TABLE_ROW_KEY_BYTES = Bytes.toBytes(DATA_TABLE_ROW_KEY); + public static String INDEX_TABLE_ROW_KEY = "ITRowKey"; + public final static byte[] INDEX_TABLE_ROW_KEY_BYTES = Bytes.toBytes(INDEX_TABLE_ROW_KEY); + public static String DATA_TABLE_TS = "DTTS"; + public final static byte[] DATA_TABLE_TS_BYTES = Bytes.toBytes(DATA_TABLE_TS); + public static String INDEX_TABLE_TS = "ITTS"; + public final static byte[] INDEX_TABLE_TS_BYTES = Bytes.toBytes(INDEX_TABLE_TS); + public static String ERROR_MESSAGE = "Error"; + public final static byte[] ERROR_MESSAGE_BYTES = Bytes.toBytes(ERROR_MESSAGE); + + public static String VERIFICATION_PHASE = "Phase"; + public final static byte[] VERIFICATION_PHASE_BYTES = Bytes.toBytes(VERIFICATION_PHASE); + public final static String EXPECTED_VALUE = "ExpectedValue"; + public final static byte[] EXPECTED_VALUE_BYTES = Bytes.toBytes(EXPECTED_VALUE); + public final static String ACTUAL_VALUE = "ActualValue"; + public final static byte[] ACTUAL_VALUE_BYTES = Bytes.toBytes(ACTUAL_VALUE); + public static final byte[] E_VALUE_PREFIX_BYTES = Bytes.toBytes(" E:"); + public static final byte[] A_VALUE_PREFIX_BYTES = Bytes.toBytes(" A:"); + public static final int PREFIX_LENGTH = 3; + public static final int TOTAL_PREFIX_LENGTH = 6; + public static final byte[] PHASE_BEFORE_VALUE = Bytes.toBytes("BEFORE"); + public static final byte[] PHASE_AFTER_VALUE = Bytes.toBytes("AFTER"); + + /** + * Only usable for the read path or for testing + */ + public IndexVerificationOutputRepository(){ Review comment: The constructor's needed for a case in IndexTool where we're just creating the tables but not reading or writing the tables. I've added setters so that a developer can use the default constructor and still write after using the setters. Is that sufficient? ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
