Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -24,6 +24,8 @@

package oap.logstream;

import com.google.common.base.Preconditions;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import lombok.SneakyThrows;
import oap.io.Closeables;
import oap.logstream.LogStreamProtocol.ProtocolVersion;
Expand All @@ -48,7 +50,7 @@ public class MemoryLoggerBackend extends AbstractLoggerBackend {

@Override
public synchronized String log( ProtocolVersion version, String hostName, String filePreffix, Map<String, String> properties, String logType,
String[] headers, byte[][] types, byte[] buffer, int offset, int length ) {
String[] headers, byte[][] types, byte[] buffer, int offset, int length ) {
LogId logId = new LogId( filePreffix, logType, hostName, properties, headers, types );
outputs
.computeIfAbsent( logId, fn -> new ByteArrayOutputStream() )
Expand Down Expand Up @@ -133,19 +135,31 @@ public List<List<Object>> asRowBinary( Predicate<LogId> filter, String... header

for( LogId id : outputs.keySet() ) {
if( filter.test( id ) ) {
IntArrayList rows = new IntArrayList();
if( headers.length == 0 ) {
for( int i = 0; i < id.headers.length; i++ ) {
rows.add( i );
}
} else {
for( String header : headers ) {
int index = ArrayUtils.indexOf( id.headers, header );

Preconditions.checkArgument( index >= 0, "header " + header + " not found" );

rows.add( index );
}
}

ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( outputs.getOrDefault( id, new ByteArrayOutputStream() ).toByteArray() );
RowBinaryInputStream rowBinaryInputStream = new RowBinaryInputStream( byteArrayInputStream, id.headers, id.types );

List<Object> objects;
while( ( objects = rowBinaryInputStream.readRow() ) != null ) {
ArrayList<Object> filtered = new ArrayList<>();
for( int i = 0; i < id.headers.length; i++ ) {
if( headers.length == 0 || ArrayUtils.contains( headers, id.headers[i] ) ) {
filtered.add( objects.get( i ) );
}
for( int i : rows ) {
filtered.add( objects.get( i ) );
}


ret.add( filtered );
}
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</distributionManagement>

<properties>
<oap.project.version>25.4.7</oap.project.version>
<oap.project.version>25.4.8</oap.project.version>

<oap.deps.config.version>25.0.1</oap.deps.config.version>
<oap.deps.oap-teamcity.version>25.0.0</oap.deps.oap-teamcity.version>
Expand Down
Loading