[
https://issues.apache.org/jira/browse/IOTDB-883?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17195913#comment-17195913
]
Jialin Qiao commented on IOTDB-883:
-----------------------------------
Hi, I give a rough design of this function:
(1) Introduce an AbstractRecordBuffer, which contains List<String>
cachedDeviceIds, List<Long> cachedTimes, List<List<String>> cachedMeasurements,
(2) Implement two buffers. StringRecordBuffer extends the abstract buffer with
a List<List<String>> values, ObjectRecordBuffer extends the abstract buffer
with List<List<TSDataType>> cachedTypes, List<List<Object>> cachedValues
(3) The Session maintains only one buffer (AbstractRecordBuffer).
(4) Users set the insertLatency and init one buffer in Session (the default is
0) by an interface initRecordBuffer(long latency, RecordBufferType type). When
setting this, the origin buffered data needs to be flushed (using
insertRecords) and a timed thread is scheduled every \{latency} elapsed.
(5) Add two methods insertStringRecordToBuffer(), insertObjectRecordToBuffer(),
the parameter is the same as the insertStringRecord and insertObjectRecord
Left questions:
(1) In this way, the flush thread and the client thread will contend the lock
of the buffer, the insertion will be blocked when flushing. So do we need to
introduce two buffers as primary-backup?
(2) The flush will be asynchronous, how to resolve the failed insertion needs
to be considered.
What do you think?
> Buffered insertion interface
> ----------------------------
>
> Key: IOTDB-883
> URL: https://issues.apache.org/jira/browse/IOTDB-883
> Project: Apache IoTDB
> Issue Type: Improvement
> Components: Client/Java
> Reporter: Jialin Qiao
> Assignee: Haimei Guo
> Priority: Minor
>
> InsertRecords is more efficient than insertRecord. If the user could bare
> some insertion latency, we could cache the records in the client-side and
> sent a batch of records periodically to the server.
> The interface may look like insertRecord(parameters, long latency)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)