Skip to content
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

CLP as a compressionCodec #12504

Merged
merged 39 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0e31639
Enricher interface
Nov 29, 2023
c9fd201
Support in realtime ingestion
Dec 18, 2023
0c7f840
Merge branch 'master' of github.com:apache/pinot into recordEnricher
Dec 18, 2023
d2b2328
Fix offline segment builder
Dec 18, 2023
262605a
Add enricher to mapper
Dec 21, 2023
fdcdbb7
Add columnsToExtract config
Dec 22, 2023
371877e
Merge branch 'master' of github.com:apache/pinot into recordEnricher
Jan 8, 2024
b4e2083
Complete enricher pipeline usage
Jan 8, 2024
f57eb3d
Add CLP as a compression type
Jan 10, 2024
c408cde
Finish the flow to add CLP index
Jan 11, 2024
9797791
Add reader
Jan 11, 2024
c80f6e0
Complete the reader
Jan 12, 2024
792c5a5
Lint fix
Jan 15, 2024
abb3f64
Avoid full file copy
Jan 15, 2024
acffbb7
Add mutable CLP index
Jan 15, 2024
ac69d83
Fix NPe
Jan 15, 2024
41a758d
Merge branch 'master' of github.com:apache/pinot into logDataType
Jan 15, 2024
9f3a4d6
Fix for null values
Jan 16, 2024
71457e9
Fix class name
Jan 16, 2024
345b57c
Merge branch 'master' of github.com:apache/pinot into logDataType
Jan 22, 2024
86823d3
Add context handlint
Jan 22, 2024
b87a5b1
Enrichment configs
Jan 9, 2024
e5471b6
Refactoring the upsert compaction related code (#12275)
Jan 22, 2024
94b404b
Merge branch 'master' of github.com:apache/pinot into logDataType
Jan 22, 2024
835559e
Merge branch 'master' of github.com:apache/pinot into logDataType
Feb 27, 2024
9683def
Merge branch 'master' of github.com:apache/pinot into logDataType
Mar 11, 2024
7c16c92
Add mutable index tests
Mar 11, 2024
8ca1650
Lint
Mar 12, 2024
0ad8a6d
Merge branch 'master' of github.com:apache/pinot into logDataType
Mar 12, 2024
965f7c2
Fix tests
Mar 12, 2024
e474bb2
Remove chunkCompressionType
Mar 13, 2024
951df7b
Add validations
Mar 13, 2024
fcfac6b
Add ITs
Mar 13, 2024
c81fa0d
Lint + misc
Mar 13, 2024
013ebc1
Lint
Mar 13, 2024
342ce5c
Fix context close
Mar 19, 2024
e2e5180
Add recordByteRanges support
Mar 19, 2024
78532fe
Review comments
Mar 21, 2024
0dd5e72
Merge branch 'master' of github.com:apache/pinot into logDataType
Mar 21, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/**
* 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.pinot.integration.tests;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.pinot.spi.config.table.FieldConfig;
import org.apache.pinot.spi.config.table.TableConfig;
import org.apache.pinot.spi.config.table.ingestion.IngestionConfig;
import org.apache.pinot.spi.config.table.ingestion.TransformConfig;
import org.apache.pinot.spi.data.Schema;
import org.apache.pinot.util.TestUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;


public class CLPEncodingRealtimeIntegrationTest extends BaseClusterIntegrationTestSet {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel an integration test is a little bit overkilling here since all we want to verify is reading from the forward index. Suggest removing this one and using unit test to cover it

private List<File> _avroFiles;

@BeforeClass
public void setUp()
throws Exception {
TestUtils.ensureDirectoriesExistAndEmpty(_tempDir, _segmentDir, _tarDir);
_avroFiles = unpackAvroData(_tempDir);

// Start the Pinot cluster
startZk();
// Start a customized controller with more frequent realtime segment validation
startController();
startBroker();
startServers(1);

startKafka();
pushAvroIntoKafka(_avroFiles);

Schema schema = createSchema();
addSchema(schema);
TableConfig tableConfig = createRealtimeTableConfig(_avroFiles.get(0));
addTableConfig(tableConfig);

waitForAllDocsLoaded(600_000L);
}

@Nullable
@Override
protected List<String> getInvertedIndexColumns() {
return null;
}

@Nullable
@Override
protected List<String> getRangeIndexColumns() {
return null;
}

@Nullable
@Override
protected List<String> getBloomFilterColumns() {
return null;
}

@Nullable
@Override
protected String getSortedColumn() {
return null;
}

@Override
protected List<String> getNoDictionaryColumns() {
return Collections.singletonList("logLine");
}

@Test
public void testValues()
throws Exception {
Assert.assertEquals(getPinotConnection().execute(
"SELECT count(*) FROM " + getTableName() + " WHERE REGEXP_LIKE(logLine, '.*executor.*')").getResultSet(0)
.getLong(0), 53);
}

protected int getRealtimeSegmentFlushSize() {
return 30;
}

@Override
protected long getCountStarResult() {
return 100;
}

@Override
protected String getTableName() {
return "clpEncodingIT";
}

@Override
protected String getAvroTarFileName() {
return "clpEncodingITData.tar.gz";
}

@Override
protected String getSchemaFileName() {
return "clpEncodingRealtimeIntegrationTestSchema.schema";
}

@Override
protected String getTimeColumnName() {
return "timestampInEpoch";
}

@Override
protected List<FieldConfig> getFieldConfigs() {
List<FieldConfig> fieldConfigs = new ArrayList<>();
fieldConfigs.add(
new FieldConfig("logLine", FieldConfig.EncodingType.RAW, null, null, FieldConfig.CompressionCodec.CLP, null,
null, null, null));

return fieldConfigs;
}

@Override
protected IngestionConfig getIngestionConfig() {
List<TransformConfig> transforms = new ArrayList<>();
transforms.add(new TransformConfig("timestampInEpoch", "now()"));

IngestionConfig ingestionConfig = new IngestionConfig();
ingestionConfig.setTransformConfigs(transforms);

return ingestionConfig;
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"schemaName": "clpEncodingIT",
"dimensionFieldSpecs": [
{
"name": "logLine",
"dataType": "STRING"
}
],
"dateTimeFieldSpecs": [
{
"name": "timestampInEpoch",
"dataType": "LONG",
"notNull": false,
"format": "1:MILLISECONDS:EPOCH",
"granularity": "1:MILLISECONDS"
}
]
}
4 changes: 4 additions & 0 deletions pinot-segment-local/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,9 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.yscope.clp</groupId>
<artifactId>clp-ffi</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.pinot.segment.local.io.util;

import java.util.List;
import org.apache.pinot.segment.spi.index.reader.ForwardIndexReader;
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;

import static java.nio.charset.StandardCharsets.UTF_8;
Expand Down Expand Up @@ -101,6 +103,15 @@ public String getUnpaddedString(int index, int numBytesPerValue, byte[] buffer)
return new String(buffer, 0, length, UTF_8);
}

public void recordOffsetRanges(int index, long baseOffset, List<ForwardIndexReader.ByteRange> rangeList) {
int offsetPosition = _dataSectionStartOffSet + Integer.BYTES * index;
int startOffset = _dataBuffer.getInt(offsetPosition);
int endOffset = _dataBuffer.getInt(offsetPosition + Integer.BYTES);
rangeList.add(new ForwardIndexReader.ByteRange(offsetPosition + baseOffset, 2 * Integer.BYTES));
int length = endOffset - startOffset;
rangeList.add(new ForwardIndexReader.ByteRange(startOffset + baseOffset, length));
}

@Override
public String getPaddedString(int index, int numBytesPerValue, byte[] buffer) {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class FixedBitMVForwardIndexWriter implements Closeable {
private int _nextDocId = 0;

public FixedBitMVForwardIndexWriter(File file, int numDocs, int totalNumValues, int numBitsPerValue)
throws Exception {
throws IOException {
float averageValuesPerDoc = totalNumValues / numDocs;
_docsPerChunk = (int) (Math.ceil(PREFERRED_NUM_VALUES_PER_CHUNK / averageValuesPerDoc));
_numChunks = (numDocs + _docsPerChunk - 1) / _docsPerChunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class FixedBitSVForwardIndexWriter implements Closeable {
private int _nextDocId = 0;

public FixedBitSVForwardIndexWriter(File file, int numDocs, int numBitsPerValue)
throws Exception {
throws IOException {
// Convert to long in order to avoid int overflow
long length = ((long) numDocs * numBitsPerValue + Byte.SIZE - 1) / Byte.SIZE;
// Backward-compatible: index file is always big-endian
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.google.common.base.Preconditions;
import java.util.Map;
import java.util.Set;
import org.apache.pinot.segment.local.realtime.impl.forward.CLPMutableForwardIndex;
import org.apache.pinot.segment.local.segment.creator.impl.stats.CLPStatsProvider;
import org.apache.pinot.segment.spi.creator.ColumnStatistics;
import org.apache.pinot.segment.spi.datasource.DataSource;
import org.apache.pinot.segment.spi.datasource.DataSourceMetadata;
Expand All @@ -30,7 +32,7 @@
import static org.apache.pinot.segment.spi.Constants.UNKNOWN_CARDINALITY;


public class MutableNoDictionaryColStatistics implements ColumnStatistics {
public class MutableNoDictionaryColStatistics implements ColumnStatistics, CLPStatsProvider {
private final DataSourceMetadata _dataSourceMetadata;
private final MutableForwardIndex _forwardIndex;

Expand Down Expand Up @@ -111,4 +113,13 @@ public Map<String, String> getPartitionFunctionConfig() {
public Set<Integer> getPartitions() {
return _dataSourceMetadata.getPartitions();
}

@Override
public CLPStats getCLPStats() {
if (_forwardIndex instanceof CLPMutableForwardIndex) {
return ((CLPMutableForwardIndex) _forwardIndex).getCLPStats();
}
throw new IllegalStateException(
"CLP stats not available for column: " + _dataSourceMetadata.getFieldSpec().getName());
}
}
Loading
Loading