Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
70a4e4e
change tsfile version
HTHou Jul 3, 2025
aca5f97
Insert FileNode
HTHou Jul 3, 2025
c93161e
add read_object scalar function
shuwenwei Jul 3, 2025
11f4ed0
remove ReadObjectFunctionHelper
shuwenwei Jul 3, 2025
adfbd4a
debug
HTHou Jul 3, 2025
007e732
fix query
shuwenwei Jul 3, 2025
9890fd6
gen file name
HTHou Jul 3, 2025
e495ee9
Merge branch 'object_type' of github.com:apache/iotdb into object_type
HTHou Jul 3, 2025
059f3d9
merge read part
HTHou Jul 3, 2025
85ef82d
allocate memory
shuwenwei Jul 4, 2025
af051df
validate offset & impl relativePath
HTHou Jul 7, 2025
53cdbb6
objectFileId recover
HTHou Jul 7, 2025
75c8629
Muti FileNode
HTHou Jul 7, 2025
b546aff
remove bin.tmp when recover
HTHou Jul 7, 2025
b5642ad
add 4G file limit
HTHou Jul 7, 2025
2f0ed6c
fix bug
HTHou Jul 7, 2025
a060b09
Add Model Writer and Reader
SpriCoder Jul 7, 2025
259fbb2
Merge remote-tracking branch 'origin/object_type' into object_type
SpriCoder Jul 7, 2025
e940c15
update write interface return to byte[]
SpriCoder Jul 7, 2025
726cacc
move object file to object dir
HTHou Jul 7, 2025
d48f2c5
Merge branch 'object_type' of github.com:apache/iotdb into object_type
HTHou Jul 7, 2025
b51e5da
resolve conflicts
JackieTien97 Jul 7, 2025
3a68517
fix error value
HTHou Jul 7, 2025
b2e5faf
object string format
JackieTien97 Jul 7, 2025
f4ec316
update utils
SpriCoder Jul 7, 2025
1389293
Merge remote-tracking branch 'origin/object_type' into object_type
SpriCoder Jul 7, 2025
618120a
add getAbsoluteObjectFilePath method
HTHou Jul 7, 2025
aaa3bec
Add Object Read Example
JackieTien97 Jul 7, 2025
75f04ad
Merge branch 'object_type' of https://github.com/apache/iotdb into ob…
JackieTien97 Jul 7, 2025
3c3de7a
Support READ_OBJECT
JackieTien97 Jul 7, 2025
95cc48b
fix serde bug for object type
JackieTien97 Jul 7, 2025
a044407
to public (#15881)
ppppoooo Jul 7, 2025
d851d0f
impl wal consensus
HTHou Jul 7, 2025
48520ed
add GeoPenetrate function
JackieTien97 Jul 7, 2025
1bc950d
Merge branch 'object_type' of https://github.com/apache/iotdb into ob…
JackieTien97 Jul 7, 2025
5d0563d
update utils
SpriCoder Jul 7, 2025
61e8f54
add ObjectReadExample for tiff
JackieTien97 Jul 7, 2025
c8cff8d
Change example
JackieTien97 Jul 8, 2025
331500b
remove wrong logic
HTHou Jul 8, 2025
3436baf
add object type case
shuwenwei Jul 8, 2025
9f66256
fix same case
shuwenwei Jul 8, 2025
73c681a
decide how to sync log
JackieTien97 Jul 8, 2025
60dc05e
dev
HTHou Jul 8, 2025
156dfcc
Merge branch 'object_type' of github.com:apache/iotdb into object_type
HTHou Jul 8, 2025
0921520
refactor write
HTHou Jul 8, 2025
56b4a71
finally iotv1 worked
HTHou Jul 8, 2025
848f4dd
modify compaction
shuwenwei Jul 8, 2025
a5b60d4
Add back logic
HTHou Jul 8, 2025
ffd7027
Merge branch 'object_type' of github.com:apache/iotdb into object_type
HTHou Jul 8, 2025
a6efa42
read point compaction performer
shuwenwei Jul 8, 2025
4584fdd
fix bug
HTHou Jul 8, 2025
cf07c44
Merge branch 'object_type' of github.com:apache/iotdb into object_type
HTHou Jul 8, 2025
400bb5c
add tiff example
JackieTien97 Jul 9, 2025
763fd09
fix bug
shuwenwei Jul 9, 2025
c75bb03
fix null tag
HTHou Jul 9, 2025
e7a0587
delete object file when drop database
HTHou Jul 9, 2025
4b12a4c
only allow ttl to delete object files
shuwenwei Jul 9, 2025
21851d1
fix bug
shuwenwei Jul 9, 2025
6fb0839
fix bug
shuwenwei Jul 9, 2025
0be124c
spotless
shuwenwei Jul 9, 2025
5ed0151
fix iotv1 bug
HTHou Jul 10, 2025
7ee4df7
add compress tiff version1
SpriCoder Jul 10, 2025
2ba2148
ignore ttl for object type
shuwenwei Jul 10, 2025
03d3c26
fix iotv1 bug
HTHou Jul 10, 2025
344c234
Merge branch 'object_type' of github.com:apache/iotdb into object_type
HTHou Jul 10, 2025
c3c4e1a
update unLinkAndSeize
SpriCoder Jul 10, 2025
1c19dc9
try to fix OOM
HTHou Jul 10, 2025
363d39e
Merge remote-tracking branch 'origin/object_type' into object_type
SpriCoder Jul 10, 2025
70ef28c
fix out of order
SpriCoder Jul 10, 2025
3e80102
use gdal to manage
SpriCoder Jul 10, 2025
50a9d6e
avoid memory problem
SpriCoder Jul 10, 2025
a588d8d
we need to close file before read by using FlushCache
SpriCoder Jul 10, 2025
dfb0a5f
fix WALEntryHandler oom
HTHou Jul 10, 2025
b8d5f48
fix iot sync error
HTHou Jul 10, 2025
7d87cff
Support fetch the device's leader through corresponding database and …
CRZbulabula Jul 10, 2025
0c064ea
Support null tag for device fetch leader interface (#15909)
CRZbulabula Jul 10, 2025
cb9ea50
Add VirtualFilePath and Path Generation
SpriCoder Jul 10, 2025
7d6fcfd
resolve conflicts
JackieTien97 Jul 11, 2025
be6b485
revert dependencies change
JackieTien97 Jul 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions example/session/src/main/java/org/apache/iotdb/ObjectExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* 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.iotdb;

import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.session.TableSessionBuilder;

import org.apache.tsfile.enums.ColumnCategory;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.write.record.Tablet;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class ObjectExample {
private static final String LOCAL_URL = "127.0.0.1:6667";

public static void main(String[] args) {

// don't specify database in constructor
try (ITableSession session =
new TableSessionBuilder()
.nodeUrls(Collections.singletonList(LOCAL_URL))
.username("root")
.password("root")
.build()) {
session.executeNonQueryStatement("CREATE DATABASE IF NOT EXISTS test1");
session.executeNonQueryStatement("use test1");

// insert table data by tablet
List<String> columnNameList =
Arrays.asList("region_id", "plant_id", "device_id", "temperature", "file");
List<TSDataType> dataTypeList =
Arrays.asList(
TSDataType.STRING,
TSDataType.STRING,
TSDataType.STRING,
TSDataType.FLOAT,
TSDataType.OBJECT);
List<ColumnCategory> columnTypeList =
new ArrayList<>(
Arrays.asList(
ColumnCategory.TAG,
ColumnCategory.TAG,
ColumnCategory.TAG,
ColumnCategory.FIELD,
ColumnCategory.FIELD));
Tablet tablet = new Tablet("tsfile_table", columnNameList, dataTypeList, columnTypeList, 1);
int rowIndex = tablet.getRowSize();
tablet.addTimestamp(rowIndex, 1);
tablet.addValue(rowIndex, 0, "1");
tablet.addValue(rowIndex, 1, "5");
tablet.addValue(rowIndex, 2, "3");
tablet.addValue(rowIndex, 3, 37.6F);
tablet.addValue(
rowIndex,
4,
true,
0,
Files.readAllBytes(
Paths.get(
"/Users/jackietien/Downloads/2_1746622362350_fa24aa15233f4e76bcda789a5771f43f")));
session.insert(tablet);
tablet.reset();

tablet = new Tablet("tsfile_table", columnNameList, dataTypeList, columnTypeList, 1);
rowIndex = tablet.getRowSize();
tablet.addTimestamp(rowIndex, 2);
tablet.addValue(rowIndex, 0, "1");
tablet.addValue(rowIndex, 1, "5");
tablet.addValue(rowIndex, 2, "3");
tablet.addValue(rowIndex, 3, 37.6F);
tablet.addValue(
rowIndex,
4,
true,
0,
Files.readAllBytes(
Paths.get(
"/Users/jackietien/Downloads/2_1746622367063_8fb5ac8e21724140874195b60b878664")));
session.insert(tablet);
tablet.reset();

tablet = new Tablet("tiff_table", columnNameList, dataTypeList, columnTypeList, 1);
rowIndex = tablet.getRowSize();
tablet.addTimestamp(rowIndex, 1);
tablet.addValue(rowIndex, 0, "1");
tablet.addValue(rowIndex, 1, "5");
tablet.addValue(rowIndex, 2, "3");
tablet.addValue(rowIndex, 3, 37.6F);
tablet.addValue(
rowIndex,
4,
true,
0,
Files.readAllBytes(Paths.get("/Users/jackietien/Downloads/1751891240130.tiff")));
session.insert(tablet);
tablet.reset();

tablet = new Tablet("tiff_table", columnNameList, dataTypeList, columnTypeList, 1);
rowIndex = tablet.getRowSize();
tablet.addTimestamp(rowIndex, 2);
tablet.addValue(rowIndex, 0, "1");
tablet.addValue(rowIndex, 1, "5");
tablet.addValue(rowIndex, 2, "4");
tablet.addValue(rowIndex, 3, 37.6F);
tablet.addValue(
rowIndex,
4,
true,
0,
Files.readAllBytes(Paths.get("/Users/jackietien/Downloads/1751891242743.tiff")));
session.insert(tablet);
tablet.reset();

} catch (IoTDBConnectionException e) {
e.printStackTrace();
} catch (StatementExecutionException e) {
e.printStackTrace();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
114 changes: 114 additions & 0 deletions example/session/src/main/java/org/apache/iotdb/ObjectReadExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* 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.iotdb;

import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.session.TableSessionBuilder;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.tsfile.utils.Binary;

import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;

public class ObjectReadExample {
private static final String LOCAL_URL = "127.0.0.1:6667";

public static void main(String[] args) {

// don't specify database in constructor
try (ITableSession session =
new TableSessionBuilder()
.nodeUrls(Collections.singletonList(LOCAL_URL))
.username("root")
.password("root")
.database("test1")
.thriftMaxFrameSize(256 * 1024 * 1024)
.build()) {
try (SessionDataSet dataSet =
session.executeQueryStatement(
"select READ_OBJECT(file) from tsfile_table where time = 1")) {
SessionDataSet.DataIterator iterator = dataSet.iterator();
while (iterator.next()) {
Binary binary = iterator.getBlob(1);
System.out.println(DigestUtils.md5Hex(binary.getValues()));
}
}

try (SessionDataSet dataSet =
session.executeQueryStatement(
"select READ_OBJECT(file) from tsfile_table where time = 2")) {
SessionDataSet.DataIterator iterator = dataSet.iterator();
while (iterator.next()) {
Binary binary = iterator.getBlob(1);
System.out.println(DigestUtils.md5Hex(binary.getValues()));
}
}

try (SessionDataSet dataSet =
session.executeQueryStatement("select READ_OBJECT(file) from tsfile_table")) {
SessionDataSet.DataIterator iterator = dataSet.iterator();
while (iterator.next()) {
Binary binary = iterator.getBlob(1);
System.out.println(DigestUtils.md5Hex(binary.getValues()));
}
}

try (SessionDataSet dataSet =
session.executeQueryStatement(
"select geo_penetrate(file, '0,3,7501,7504') from tsfile_table")) {
SessionDataSet.DataIterator iterator = dataSet.iterator();
while (iterator.next()) {
Binary binary = iterator.getBlob(1);
ByteBuffer byteBuffer = ByteBuffer.wrap(binary.getValues());
float[] res = new float[byteBuffer.limit() / Float.BYTES];
for (int i = 0; i < res.length; i++) {
res[i] = byteBuffer.getFloat();
}
System.out.println(Arrays.toString(res));
}
}

try (SessionDataSet dataSet =
session.executeQueryStatement(
"select geo_penetrate(file, '0,3,7501,7504', 'UNCOMPRESSED_TIFF') from tiff_table")) {
SessionDataSet.DataIterator iterator = dataSet.iterator();
while (iterator.next()) {
Binary binary = iterator.getBlob(1);
ByteBuffer byteBuffer = ByteBuffer.wrap(binary.getValues());
float[] res = new float[byteBuffer.limit() / Float.BYTES];
for (int i = 0; i < res.length; i++) {
res[i] = byteBuffer.getFloat();
}
System.out.println(Arrays.toString(res));
}
}

} catch (IoTDBConnectionException e) {
e.printStackTrace();
} catch (StatementExecutionException e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static void main(String[] args) {
int rowIndex = tablet.getRowSize();
tablet.addTimestamp(rowIndex, timestamp);
tablet.addValue("region_id", rowIndex, "1");
tablet.addValue("plant_id", rowIndex, "5");
tablet.addValue("plant_id", rowIndex, null);
tablet.addValue("device_id", rowIndex, "3");
tablet.addValue("model", rowIndex, "A");
tablet.addValue("temperature", rowIndex, 37.6F);
Expand All @@ -134,6 +134,26 @@ public static void main(String[] args) {
tablet.reset();
}

// query device leader
List<Boolean> isSetTag = Arrays.asList(true, true, false, true);
String correctURL =
session.getDeviceLeaderURL("test2", Arrays.asList("test1", "1", "3"), isSetTag, 66);
System.out.println("Correct device leader URL: " + correctURL);
String errorDbURL =
session.getDeviceLeaderURL("test3", Arrays.asList("test1", "1", "3"), isSetTag, 66);
System.out.println("Error dbName device leader URL: " + errorDbURL);
String errorDeviceURL =
session.getDeviceLeaderURL("test2", Arrays.asList("test1", "3", "1"), isSetTag, 66);
System.out.println("Error deviceId device leader URL: " + errorDeviceURL);
List<Boolean> falseTagList = Arrays.asList(false, true, true, true);
String errorTagURL =
session.getDeviceLeaderURL("test2", Arrays.asList("test1", "1", "3"), falseTagList, 66);
System.out.println("Error tag device leader URL: " + errorTagURL);
String errorTimeURL =
session.getDeviceLeaderURL(
"test2", Arrays.asList("test1", "1", "3"), isSetTag, 6666666666666666L);
System.out.println("Error time device leader URL: " + errorTimeURL);

// query table data
try (SessionDataSet dataSet =
session.executeQueryStatement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public enum Type {
BLOB((byte) 10),

/* STRING */
STRING((byte) 11);
STRING((byte) 11),

/* OBJECT */
OBJECT((byte) 12);

private final byte dataType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ public enum Type {
BLOB((byte) 10),

/* STRING */
STRING((byte) 11);
STRING((byte) 11),

/* OBJECT */
OBJECT((byte) 12);

private final byte dataType;

Type(byte type) {
Expand Down Expand Up @@ -92,6 +96,7 @@ public boolean checkObjectType(Object o) {
case DATE:
return o instanceof LocalDate;
case BLOB:
case OBJECT:
return o instanceof Binary;
case STRING:
case TEXT:
Expand All @@ -102,7 +107,8 @@ public boolean checkObjectType(Object o) {
}

public static List<Type> allTypes() {
return Arrays.asList(BOOLEAN, INT32, INT64, FLOAT, DOUBLE, TEXT, TIMESTAMP, DATE, BLOB, STRING);
return Arrays.asList(
BOOLEAN, INT32, INT64, FLOAT, DOUBLE, TEXT, TIMESTAMP, DATE, BLOB, STRING, OBJECT);
}

public static List<Type> numericTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ private static String getStringByColumnIndex(
case DOUBLE:
case TEXT:
case STRING:
case OBJECT:
return resultSet.getString(columnIndex);
case BLOB:
byte[] v = resultSet.getBytes(columnIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import org.apache.tsfile.write.record.Tablet;

import java.util.List;

/**
* This interface defines a session for interacting with IoTDB tables. It supports operations such
* as data insertion, executing queries, and closing the session. Implementations of this interface
Expand All @@ -46,6 +48,18 @@ public interface ITableSession extends AutoCloseable {
*/
void insert(Tablet tablet) throws StatementExecutionException, IoTDBConnectionException;

/**
* Retrieves the DataNode URL of the device leader for a given database and a deviceID.
*
* @param dbName the name of the database.
* @param deviceId a list of string for constructing the specified deviceID.
* @param isSetTag a true indicating the deviceID is set, false otherwise.
* @param time the time at which partition the device leader is queried.
* @return the DataNode URL <ip:port> of the device leader as a String.
*/
String getDeviceLeaderURL(String dbName, List<String> deviceId, List<Boolean> isSetTag, long time)
throws IoTDBConnectionException, StatementExecutionException;

/**
* Executes a non-query SQL statement, such as a DDL or DML command.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ private RowRecord constructRowRecordFromValueArray() throws StatementExecutionEx
case TEXT:
case BLOB:
case STRING:
case OBJECT:
field.setBinaryV(ioTDBRpcDataSet.getBinary(columnName));
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ public static ByteBuffer convertTsBlock(
case TEXT:
case STRING:
case BLOB:
case OBJECT:
tsBlockBuilder
.getColumnBuilder(j)
.writeBinary(
Expand Down
Loading
Loading