aglinxinyuan commented on code in PR #4784: URL: https://github.com/apache/texera/pull/4784#discussion_r3177498906
########## amber/src/test/scala/org/apache/texera/amber/engine/common/ambermessage/DataPayloadSpec.scala: ########## @@ -0,0 +1,77 @@ +/* + * 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.texera.amber.engine.common.ambermessage + +import org.apache.texera.amber.core.tuple.{Attribute, AttributeType, Schema, Tuple} +import org.scalatest.flatspec.AnyFlatSpec + +class DataPayloadSpec extends AnyFlatSpec { + + private val schema: Schema = + Schema().add(new Attribute("v", AttributeType.INTEGER)) + + private def tuple(v: Int): Tuple = + Tuple.builder(schema).add(new Attribute("v", AttributeType.INTEGER), Integer.valueOf(v)).build() Review Comment: Done in 33b3f09db0. The `tuple` helper now uses `schema.getAttribute("v")` so the helper stays consistent with the schema under test. ########## amber/src/test/scala/org/apache/texera/amber/engine/common/ambermessage/DataPayloadSpec.scala: ########## @@ -0,0 +1,77 @@ +/* + * 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.texera.amber.engine.common.ambermessage + +import org.apache.texera.amber.core.tuple.{Attribute, AttributeType, Schema, Tuple} +import org.scalatest.flatspec.AnyFlatSpec + +class DataPayloadSpec extends AnyFlatSpec { + + private val schema: Schema = + Schema().add(new Attribute("v", AttributeType.INTEGER)) + + private def tuple(v: Int): Tuple = + Tuple.builder(schema).add(new Attribute("v", AttributeType.INTEGER), Integer.valueOf(v)).build() + + "DataFrame.inMemSize" should "be zero for an empty frame" in { + assert(DataFrame(Array.empty).inMemSize == 0L) + } + + it should "be the sum of inMemSize across the contained tuples" in { + val a = tuple(1) + val b = tuple(2) + val df = DataFrame(Array(a, b)) + assert(df.inMemSize == a.inMemSize + b.inMemSize) + } + + "DataFrame.equals" should "consider two empty frames equal" in { + assert(DataFrame(Array.empty) == DataFrame(Array.empty)) + } Review Comment: Done in 33b3f09db0. Split the empty-frame equality test into a true reflexivity case (`val df = ...; assert(df == df)`) and a separate case for two distinct empty-frame instances, so the test name matches the assertion. -- 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]
