rdblue commented on code in PR #3202: URL: https://github.com/apache/parquet-java/pull/3202#discussion_r2069427878
########## parquet-variant/src/test/java/org/apache/parquet/variant/VariantTestUtil.java: ########## @@ -0,0 +1,116 @@ +/* + * 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.parquet.variant; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.security.SecureRandom; +import java.time.Instant; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import org.junit.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class VariantTestUtil { + private static final Logger LOG = LoggerFactory.getLogger(VariantTestUtil.class); + private static final String RANDOM_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + + /** Random number generator for generating random strings */ + private static SecureRandom random = new SecureRandom(new byte[] {1, 2, 3, 4, 5}); + + static final ByteBuffer EMPTY_METADATA = ByteBuffer.wrap(new byte[] {0b1}); + + static void checkType(Variant v, int expectedBasicType, Variant.Type expectedType) { + Assert.assertEquals(expectedBasicType, v.value.get(v.value.position()) & VariantUtil.BASIC_TYPE_MASK); + Assert.assertEquals(expectedType, v.getType()); + } + + static long microsSinceEpoch(Instant instant) { Review Comment: Why is this interacting with `Instant`? There is no need to have a conversion here because the write methods are called with `long` values not `Instant`. Tests only need to validate that the value passed in matches the value read back and that the type is preserved. Conversion from a date/time representation is the responsibility of engines, not Parquet. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
