- 
                Notifications
    You must be signed in to change notification settings 
- Fork 82
Implement tree-model interface and table-model tagfilter #568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            761417898
  wants to merge
  81
  commits into
  apache:new_java_interfaces
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
761417898:new_java_interfaces
  
      
      
   
  
    
  
  
  
 
  
      
    base: new_java_interfaces
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 5 commits
      Commits
    
    
            Show all changes
          
          
            81 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      8d89f4d
              
                Check blank column name or table name (#471)
              
              
                shuwenwei 4b75866
              
                Optimizations regarding chunk metadata sort & timeseries metadata ser…
              
              
                jt2594838 b385b4f
              
                Remove redundant conversion in TableResultSet (#473)
              
              
                jt2594838 73ac55f
              
                Fix CPP TsFile query with time filter error (#474)
              
              
                HTHou c731ba0
              
                add switch to disable native lz4 (#480)
              
              
                jt2594838 4145395
              
                Fix float RLBE encoding loss of precision (#484)
              
              
                HTHou 217cc3c
              
                Add flush method for tsfile python writer (#487)
              
              
                ycycse d2119c1
              
                add table/column schema check. (#488)
              
              
                ColinLeeo e795637
              
                delete parameter encrypt_flag (#491)
              
              
                zhujt20 6f08fb1
              
                Colin fix config (#493)
              
              
                ColinLeeo 14cefc9
              
                fix data lossing when page num exceed 1. (#495)
              
              
                ColinLeeo cc8f363
              
                Colin fix config (#472)
              
              
                ColinLeeo dd603b4
              
                Bump setuptools from 70.0.0 to 78.1.1 in /python (#497)
              
              
                dependabot[bot] 3a688ee
              
                Add TsFileLastReader for retrieving last points in a TsFile (#498)
              
              
                jt2594838 1856572
              
                Update release information of TsFile v2.0.3 (#505)
              
              
                HTHou a5424d3
              
                Same name (case insensitive) in tablet / table. (#490)
              
              
                ColinLeeo 6672d2d
              
                Fix (#508)
              
              
                Caideyipi a71b8d4
              
                fix minus encode and decode. (#511)
              
              
                ColinLeeo 7859080
              
                Zjt/encrypt key from environment (#512)
              
              
                zhujt20 2995362
              
                Fix npe when closing a last reader that have not been used (#513)
              
              
                jt2594838 6df6112
              
                The TsFile-CPP query interface now validates column names before quer…
              
              
                761417898 c501bf4
              
                Resolved case sensitivity issue when reading column names. (#517)
              
              
                761417898 af2a7ee
              
                Fix tag empty error and disorder timestamp. (#489)
              
              
                ColinLeeo caa77ac
              
                [Java/C++/C] Resolved case sensitivity issue when reading column name…
              
              
                761417898 58fa12f
              
                fix read from iotdb data. (#520)
              
              
                ColinLeeo 04eb621
              
                Fix bloom filter error.
              
              
                ColinLeeo 09015fa
              
                [CPP]Fix/multi fileds column (#522)
              
              
                761417898 de166a7
              
                Support set default compression by data type (#523)
              
              
                jt2594838 d2a906e
              
                Fixes the issue where data with only timestamps could not be inserted…
              
              
                ColinLeeo ed5b5dc
              
                The column names in the addValue interface are case-insensitive (#526)
              
              
                761417898 af0ec13
              
                Use spotless to format CPP code (#528)
              
              
                HTHou e7bdcad
              
                fix some warning while compiling. (#527)
              
              
                ColinLeeo 6554a18
              
                Correct the memroy calculation of BinaryColumnBuilder
              
              
                JackieTien97 a2da0c9
              
                [maven-release-plugin] prepare release v2.1.0
              
              
                ColinLeeo efdba35
              
                Revert "[maven-release-plugin] prepare release v2.1.0" (#533)
              
              
                ColinLeeo 7510d94
              
                Fetch max tsblock line number each time from TSFileConfig
              
              
                JackieTien97 c32e893
              
                AbstractAlignedTimeSeriesMetadata.typeMatch always return true (#538)
              
              
                shuwenwei 4909442
              
                Implement datatype TIMESTAMP BLOB TEXT DATE (#532)
              
              
                761417898 a8e48ad
              
                Ignore the null value passed in the Tablet.addValue method (#540)
              
              
                shuwenwei 110a5a2
              
                Bump org.apache.commons:commons-lang3 from 3.15.0 to 3.18.0 in /java …
              
              
                dependabot[bot] 490d521
              
                Update version info for tsfile v2.1.0 (#544)
              
              
                ColinLeeo 838d290
              
                Implement extract time filters
              
              
                Wei-hao-Li 956d598
              
                implement RLE DICTIONART ZIGZAG codec (#542)
              
              
                761417898 d3eb61a
              
                Init all series writer for AlignedChunkGroupWriter
              
              
                shuwenwei 04bbc0a
              
                Check max tsfile version
              
              
                shuwenwei 898f1a6
              
                include common in tsfile with shade (#510)
              
              
                Inky19 ae3e8c8
              
                Implement extract value filters
              
              
                Wei-hao-Li ee647cb
              
                fix wrong Private-Package declaration (#556)
              
              
                Inky19 f1dad36
              
                Feature/cpp codec sprintz (#553)
              
              
                761417898 965f487
              
                Avoid repeated calculation of shallow size of map
              
              
                shuwenwei f3345b9
              
                Refactor UnknownType to extend AbstractType
              
              
                FearfulTomcat27 9ef4709
              
                Add Tablet.append (#562)
              
              
                jt2594838 f54f8b6
              
                Provides complete implementation of all TagFilter operations
              
              
                761417898 1dff37b
              
                Add methods for RamUsageEstimator
              
              
                shuwenwei b970e1f
              
                implement new java writing interface for tree model
              
              
                761417898 38a847d
              
                generate main key (#519)
              
              
                zhujt20 949a7a5
              
                reduce zero-fill overhead on BitMap creation (#572)
              
              
                luoluoyuyu 858239f
              
                Update release information after v2.1.1 released (#574)
              
              
                HTHou 95dbf6a
              
                Feature/codec/camel (#560)
              
              
                761417898 616e844
              
                implement v4 tree-model read interface
              
              
                761417898 c9838b0
              
                Adjusted the sequence of measurements
              
              
                761417898 94d5e06
              
                Add licenses
              
              
                761417898 550c482
              
                Add support for alter column datatype (#567)
              
              
                zerolbsony a426db2
              
                Add v4 interface example
              
              
                761417898 988beea
              
                Add v4 PerformanceTest
              
              
                761417898 01be82e
              
                feat: add markRange / unmarkRange / merge for high-performance bit ma…
              
              
                luoluoyuyu 674a65c
              
                perf: Optimize aligned object memory size calculation (#577)
              
              
                luoluoyuyu a5fee93
              
                [CPP/C] implement default encoding/compression configuration interfac…
              
              
                761417898 dcdbcf8
              
                Bump actions/first-interaction from 1.3.0 to 3.0.0 (#586)
              
              
                dependabot[bot] fd1adb8
              
                Bump actions/setup-java from 4 to 5 (#584)
              
              
                dependabot[bot] 5132d99
              
                Alter column other type to string type (#588)
              
              
                zerolbsony 1dce1b0
              
                Bump actions/checkout from 4 to 5 (#583)
              
              
                dependabot[bot] 39e55a3
              
                Fix camel encoding error message and add check for each datatypes of …
              
              
                HTHou 83250e3
              
                Modify the TsFileSequenceReaderTimeseriesMetadataIterator next functi…
              
              
                luoluoyuyu c2a2937
              
                add encrypt param for all the write/read struct initialization (#601)
              
              
                zhujt20 1e5e7ef
              
                Merge branch 'develop' into new_java_interfaces
              
              
                761417898 84444eb
              
                fix TableResultSet.Iterator unittest
              
              
                761417898 12b4ce9
              
                add license
              
              
                761417898 a6d5696
              
                spotless:apply
              
              
                761417898 e1d0734
              
                fix MeasurementSchemaBuilder getCompressor()
              
              
                761417898 8ff0900
              
                removed unused IDeviceID.toString()
              
              
                761417898 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -20,21 +20,37 @@ | |
| package org.apache.tsfile.read.query.dataset; | ||
|  | ||
| import org.apache.tsfile.annotations.TsFileApi; | ||
| import org.apache.tsfile.file.metadata.StringArrayDeviceID; | ||
| import org.apache.tsfile.read.common.Field; | ||
| import org.apache.tsfile.read.common.Path; | ||
| import org.apache.tsfile.write.record.TSRecord; | ||
|  | ||
| import java.io.IOException; | ||
| import java.util.Iterator; | ||
| import java.util.LinkedList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.NoSuchElementException; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.IntStream; | ||
|  | ||
| public class TreeResultSet extends AbstractResultSet { | ||
| private QueryDataSet queryDataSet; | ||
| private List<String> deviceList; | ||
| private List<String> measurementList; | ||
| private Map<Path, Integer> pathIndexMap; | ||
|  | ||
| public TreeResultSet(QueryDataSet queryDataSet) { | ||
| public TreeResultSet( | ||
| QueryDataSet queryDataSet, List<String> deviceIds, List<String> measurementNames) { | ||
| super( | ||
| queryDataSet.getPaths().stream().map(Path::toString).collect(Collectors.toList()), | ||
| queryDataSet.getDataTypes()); | ||
| this.queryDataSet = queryDataSet; | ||
| this.deviceList = deviceIds; | ||
| this.measurementList = measurementNames; | ||
| List<Path> paths = queryDataSet.getPaths(); | ||
| this.pathIndexMap = | ||
| IntStream.range(0, paths.size()).boxed().collect(Collectors.toMap(paths::get, i -> i)); | ||
| } | ||
|  | ||
| @TsFileApi | ||
|  | @@ -56,6 +72,92 @@ public void close() { | |
|  | ||
| @Override | ||
| public Iterator<TSRecord> recordIterator() { | ||
| return null; | ||
| return new TreeResultSet.RecordIterator(); | ||
| } | ||
|  | ||
| private class RecordIterator implements Iterator<TSRecord> { | ||
| private final LinkedList<TSRecord> recordBuffer = new LinkedList<>(); | ||
| private boolean exhausted = false; | ||
|  | ||
| @Override | ||
| public boolean hasNext() { | ||
| if (!recordBuffer.isEmpty()) { | ||
| return true; | ||
| } | ||
| if (exhausted) { | ||
| return false; | ||
| } | ||
|  | ||
| try { | ||
| return fetchRecords(); | ||
| } catch (IOException e) { | ||
| throw new NoSuchElementException(e.toString()); | ||
| } | ||
| } | ||
|  | ||
| private boolean fetchRecords() throws IOException { | ||
| boolean hasNewRecords = false; | ||
| while (TreeResultSet.this.next()) { | ||
| for (String device : deviceList) { | ||
| TSRecord record = new TSRecord(device, getLong("Time")); | ||
| record.addPoint("id", device); | ||
|  | ||
| for (String measurement : measurementList) { | ||
| Integer pathIdx = | ||
| pathIndexMap.get(new Path(new StringArrayDeviceID(device), measurement, false)); | ||
|          | ||
| if (pathIdx != null) { | ||
| Field field = currentRow.getField(pathIdx); | ||
| switch (field.getDataType()) { | ||
| case INT32: | ||
| case DATE: | ||
| record.addPoint(measurement, field.getIntV()); | ||
| break; | ||
| case INT64: | ||
| case TIMESTAMP: | ||
| record.addPoint(measurement, field.getLongV()); | ||
| break; | ||
| case FLOAT: | ||
| record.addPoint(measurement, field.getFloatV()); | ||
| break; | ||
| case DOUBLE: | ||
| record.addPoint(measurement, field.getDoubleV()); | ||
| break; | ||
| case STRING: | ||
| case TEXT: | ||
| record.addPoint(measurement, field.getStringValue()); | ||
| break; | ||
| case BLOB: | ||
| record.addPoint(measurement, field.getBinaryV().getValues()); | ||
| break; | ||
| case BOOLEAN: | ||
| record.addPoint(measurement, field.getBoolV()); | ||
| break; | ||
| case VECTOR: | ||
| case UNKNOWN: | ||
| default: | ||
| break; | ||
| } | ||
| } else { | ||
| record.dataPointList.add(null); | ||
| } | ||
| } | ||
| recordBuffer.add(record); | ||
| hasNewRecords = true; | ||
| } | ||
| } | ||
| if (!hasNewRecords) { | ||
| exhausted = true; | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|  | ||
| @Override | ||
| public TSRecord next() { | ||
| if (!hasNext()) { | ||
| throw new NoSuchElementException(); | ||
| } | ||
| return recordBuffer.poll(); | ||
| } | ||
| } | ||
| } | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May just use toString().