apache / apache/arrow-java

[Java] Unable to update VectorSchemaRoot field vectors.

オープン
#46 コメント 12 件 リアクション 0 件 担当者 0 名 GitHub で見る
Type: usage
主要言語
Java
スター
94
フォーク
152
平均マージ
3日 16時間
マージ済み PR(30日)
11

説明

### Describe the usage question you have. Please include as many useful details as possible.

Hi community,

I have a trying to modify data buffers of string column.
if i print the buffer readable bytes after ` buffers.set(index, compressedBuf); `, i see the right value.
```
List buffers = fieldVector.getFieldBuffers();
int index = buffers.size() - 1;
ArrowBuf compressedBuf = null;
ArrowBuf originalBuf = buffers.get(index);
ByteBuffer originalBuffer = originalBuf.nioBuffer(0, (int) originalBuf.readableBytes());

// Compress the buffer using LZ4
byte[] originalBytes = new byte[originalBuffer.remaining()];
System.out.println("This is buffer id: "+ index + " originalbytes: "+ originalBuf.readableBytes());
originalBuffer.get(originalBytes);

int maxCompressedLength = compressor.maxCompressedLength(originalBytes.length);
byte[] compressedBytes = new byte[maxCompressedLength];
int compressedLength = compressor.compress(originalBytes, 0, originalBytes.length, compressedBytes, 0, maxCompressedLength);

// Allocate a new ArrowBuf for the compressed data
compressedBuf = allocator.buffer(compressedLength);

compressedBuf.writeBytes(compressedBytes, 0, compressedLength);
compressedBuf.writerIndex(compressedLength);
System.out.println("This is buffer id: "+ index+ " compressedbytes: "+ compressedBuf.readableBytes());

buffers.set(index, compressedBuf); // Replace with compressed buffer

```

When i update my fieldvector.

```
int nullCount = fieldVector.getNullCount(); // Get the null count
ArrowFieldNode fieldNode = new ArrowFieldNode(fieldVectorValueCount, nullCount);
ArrowBuf validityBuffer = fieldVector.getValidityBuffer(); // Assuming it exists
ArrowBuf offsetBuffer = fieldVector.getOffsetBuffer(); // Assuming it exists

// Update FieldVector with the new compressed buffers
fieldVector.clear(); // Clear existing buffers (to prevent memory leaks)
fieldVector.loadFieldBuffers(fieldNode,java.util.Arrays.asList(validityBuffer, offsetBuffer, compressedBuf)); // Load the new (compressed) buffers
fieldVector.setValueCount(fieldVectorValueCount); // Reset value count after buffer replacement
Field field1 = fieldVector.getField();
```

and i check the buffers again then buffers reflect old value.

please advise .

### Component(s)

Java

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

getFieldBuffers()、clear()、loadFieldBuffers() に関係する VectorSchemaRoot および FieldVector の API を、まずそれらのバッファ所有権と置換の契約から確認してください。示されているシーケンスを再現し、結果のベクターが compressedBuf と元のバッファのどちらを公開するかを検証してください。サポートされている更新経路を特定するか、対象を絞ったテストで動作を確認できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
data-engineering
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。