Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyxu committed Sep 3, 2022
1 parent 576d2ff commit 451e5b0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cpp/src/lance/encodings/binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ::arrow::Result<std::shared_ptr<::arrow::Array>> VarBinaryDecoder<T>::ToArray(
return ::arrow::Status::IndexError(
fmt::format("VarBinaryDecoder::ToArray: out of range: start={} length={} page_length={}\n",
start,
length.value_or(length_),
length.value_or(-1),
length_));
}

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/lance/encodings/plain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ class PlainDecoderImpl : public Decoder {
length.value_or(-1),
length_));
}
auto byte_length = type_->byte_width();
auto byte_width = type_->byte_width();
ARROW_ASSIGN_OR_RAISE(auto buf,
infile_->ReadAt(position_ + start * byte_length, len * byte_length));
infile_->ReadAt(position_ + start * byte_width, len * byte_width));
return std::make_shared<ArrayType>(type_, len, buf);
}

Expand Down
7 changes: 4 additions & 3 deletions cpp/src/lance/encodings/plain_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ TEST_CASE("Test Write Int32 array") {
}
}

TEST_CASE("Read not full batch") {
auto arr = lance::arrow::ToArray({1, 2, 3, 4, 5, 6, 7, 8}).ValueOrDie();
TEST_CASE("Do not read full batch") {
auto arr = lance::arrow::ToArray({10, 20, 30, 40, 50, 60, 70, 80}).ValueOrDie();
CHECK(arr->length() == 8);

auto sink = arrow::io::BufferOutputStream::Create().ValueOrDie();
Expand All @@ -60,8 +60,9 @@ TEST_CASE("Read not full batch") {
CHECK(decoder.Init().ok());
decoder.Reset(offset, arr->length());

// Decode arr[6:8]
auto values = decoder.ToArray(6, 8).ValueOrDie();
CHECK(values->Equals(lance::arrow::ToArray({7, 8}).ValueOrDie()));
CHECK(values->Equals(lance::arrow::ToArray({70, 80}).ValueOrDie()));
}

TEST_CASE("Test take plain values") {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/lance/io/exec/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "filter.h"
#include "lance/io/exec/filter.h"

#include <arrow/array.h>
#include <arrow/compute/api.h>
Expand Down Expand Up @@ -45,7 +45,6 @@ ::arrow::Result<ScanBatch> Filter::Next() {
}
ARROW_ASSIGN_OR_RAISE(auto indices_and_values, Apply(*batch.batch));
auto [indices, values] = indices_and_values;
assert(indices->length() == values->num_rows());
ARROW_ASSIGN_OR_RAISE(auto values_arr, values->ToStructArray());
ARROW_ASSIGN_OR_RAISE(
auto struct_arr,
Expand All @@ -71,6 +70,7 @@ Filter::Apply(const ::arrow::RecordBatch& batch) const {
auto indices = std::static_pointer_cast<::arrow::Int32Array>(indices_datum.make_array());
auto values_arr = values.make_array();
ARROW_ASSIGN_OR_RAISE(auto result_batch, ::arrow::RecordBatch::FromStructArray(values_arr));
assert(indices->length() == result_batch->num_rows());
return std::make_tuple(indices, result_batch);
}

Expand Down

0 comments on commit 451e5b0

Please sign in to comment.