[Bug] Custom Pipe Processor Plugin can not get the all insert data values
Search before asking
- [x] I searched in the issues and found nothing similar.
Version
the version is 2.0.5
Describe the bug and provide the minimal reproduce step
my table is: create database testdb2; CREATE TABLE gwy6l(time TIMESTAMP TIME,measurementname STRING TAG,type STRING ATTRIBUTE,value STRING FIELD,status INT64 FIELD,source_time INT64 FIELD,server_time INT64 FIELD);
the custom pipe processor plugin is:
show pipeplugins is:
my pipe create cmd is: CREATE PIPE task2742_outer_98785855 WITH SOURCE ('source'='iotdb-source','source.inclusion' = 'data.insert,data.delete', 'source.history.enable' = 'false', 'source.mode.streaming' = 'true') WITH PROCESSOR ('processor' = 'SYNC_IOTDB_IOTDBTABLE_11') WITH SINK ('sink' = 'do-nothing-sink')
insert into data and find in /logs/log_datanode_all.log is:
i can get the insert data , but the data is not complete.
logger.info("tablet schemas:{}",tablet.getSchemas()); logger.info("tablet columnsTypes:{}",tablet.getColumnTypes());
the print log
:[[measurementname,STRING,PLAIN,,LZ4], [server_time,INT64,TS_2DIFF,,LZ4], [source_time,INT64,TS_2DIFF,,LZ4], [status,INT64,TS_2DIFF,,LZ4], [value,STRING,PLAIN,,LZ4]]
not contains the type field ,the type field columnCategory is attribute ,
What did you expect to see?
i want to get the field value(the field is attribute ) from custom pipe processor ,
What did you see instead?
the pipe task should config ? i can get the field value . the field columnCategory is attribute .
Anything else?
No response
Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
in the custom pipe processor ,i can not get the type field value , the type field category is attribute
Well, the method in the PIPE processor only captures data from the DataRegion BY DESIGN.
The attribute is defined as part of the metadata instead of the data. It will not even go into the DataRegion, let alone be captured by the PIPE.
It is recommended to query the attribute from the attribute cache with the DeviceId (table name + tags).
The simplest query logic may be using:
LocalExecutionPlanner.getInstance()
.metadata
.indexScan(
new QualifiedObjectName(<database>, <table>),
Collections.emptyList(),
Arrays.asList(<yourAttributes>),
new MPPQueryContext(new QueryId("Processor query")));
And it will return Map<String, List
new QueryId("Processor query") What parameters should I pass, or is it a fixed value(Processor query), time,or tags field value?
QueryId can be and arbitary value, or even just QueryId.MOCK_QUERY_ID. Of course you can also use Coordinator.createQueryId() here
Since the queryId may occur in the log when the attribute query fails, you can also use a self-defined querId for debugging purposes.
Can you give an example? my table data is:
table desc
in pipe processor :
Map<String, List
new QueryId("device_016_0") ?
I would suggest appending the name of your processor to the front ("SYNC_IOTDB_IOTDBTABLE_11_<database>_<table>"), so that you may know easily from the log if something went wrong.
i does not understand what you mean , LocalExecutionPlanner.getInstance().metadata.indexScan(new QualifiedObjectName("testdb","gwy6l" ), Collections.emptyList(), Arrays.asList("type"), new MPPQueryContext(new QueryId("Processor query"))); What environment does this code snippet need to run in?
run it ,the printstack is
What I want is to get the attribute info in the pipe processor?
if use SYNC_IOTDB_IOTDBTABLE_11_ the error message id :
CustomProcessorToFile customize error :Invalid id SYNC_IOTDB_IOTDBTABLE_11_testdb2_gwy6l
i have got it
get it by using it this way: SessionInfo sessionInfo = new SessionInfo(
9999L, // sessionId:随便给一个唯一 long 即可(Pipe内部用)
userName, // userName:默认超级管理员 root
ZoneId.systemDefault(), // 时区:必须传,用系统默认就行
dbName,
IClientSession.SqlDialect.TABLE // 重点:你用的是表模型,必须是 TABLE 模式!
);
TEndPoint localDataBlockEndpoint = new TEndPoint("127.0.0.1", port);
TEndPoint localInternalEndpoint = new TEndPoint("127.0.0.1", 10730);
MPPQueryContext queryContext = new MPPQueryContext(
"pipe query", // 随便写一个SQL
QueryId.MOCK_QUERY_ID,
sessionInfo,
localDataBlockEndpoint,
localInternalEndpoint
); queryContext.setSession(sessionInfo); Map<String, List for (String key : stringListMap.keySet()) {
List }
Congratulations. Since
I get the data in the customize method and put it into the cache map for the first time.
the cache map expired 5min. when cache expired . then load the attribute data to cache .
This has a small issue, but it's acceptable.
Binary[] attributeColumnValues = entry.getAttributeColumnValues();
StringBuilder s = new StringBuilder();
for(Binary binary : attributeColumnValues) {
s.append(",").append(binary.toString());
}
attributeKeyCache.put(deviceId,s.substring(1));
}
customize is only called during the initialization of Pipe, if the attribute is changed during runtime, you may put the above logic in process instead.
However, it may introduce a higher cost because the query is performed with every insertion.