This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,158 additions
and
573 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package benchmark_test | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"testing" | ||
|
||
"github.com/segmentio/parquet" | ||
"github.com/segmentio/parquet/internal/benchmark" | ||
"github.com/stretchr/testify/require" | ||
"github.com/xitongsys/parquet-go-source/local" | ||
"github.com/xitongsys/parquet-go/reader" | ||
) | ||
|
||
func BenchmarkReflectReadRow(b *testing.B) { | ||
p := "../../examples/stage-small.parquet" | ||
planner := parquet.StructPlannerOf(new(benchmark.Trace)) | ||
builder := planner.Builder() | ||
plan := planner.Plan() | ||
|
||
b.ReportAllocs() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
f, err := os.Open(p) | ||
require.NoError(b, err) | ||
|
||
pf, err := parquet.OpenFile(f) | ||
require.NoError(b, err) | ||
rowReader := parquet.NewRowReaderWithPlan(plan, pf) | ||
|
||
for { | ||
target := &benchmark.Trace{} | ||
err := rowReader.Read(builder.To(target)) | ||
if err == parquet.EOF { | ||
break | ||
} | ||
require.NoError(b, err) | ||
} | ||
require.NoError(b, f.Close()) | ||
} | ||
} | ||
|
||
func BenchmarkReflectReadRowParquetGo(b *testing.B) { | ||
p := "../../examples/stage-small.parquet" | ||
b.ReportAllocs() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
fr, err := local.NewLocalFileReader(p) | ||
if err != nil { | ||
log.Println("Can't open file", err) | ||
return | ||
} | ||
pr, err := reader.NewParquetReader(fr, new(benchmark.Trace), 1) | ||
require.NoError(b, err) | ||
num := int(pr.GetNumRows()) | ||
target := make([]benchmark.Trace, 1, 1) | ||
for i := 0; i < num; i++ { | ||
err := pr.Read(&target) | ||
require.NoError(b, err) | ||
} | ||
pr.ReadStop() | ||
require.NoError(b, err, fr.Close()) | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package benchmark | ||
|
||
type Tag struct { | ||
Name string `parquet:"name=name, type=UTF8"` | ||
Value string `parquet:"name=value, type=UTF8"` | ||
} | ||
|
||
type Trace struct { | ||
kafkaTopic string //not exporting it to parquet | ||
KafkaPartition int64 `parquet:"name=kafka_partition, type=INT_64"` | ||
KafkaOffset int64 `parquet:"name=kafka_offset, type=INT_64"` | ||
TimestampMs int64 `parquet:"name=timestamp_ms, type=INT_64"` | ||
TraceID string `parquet:"name=trace_id, type=UTF8"` | ||
SpanID string `parquet:"name=span_id, type=UTF8"` | ||
ParentSpanID string `parquet:"name=parent_span_id, type=UTF8"` | ||
NextTraceID string `parquet:"name=next_trace_id, type=UTF8"` | ||
ParentTraceIDs []string `parquet:"name=parent_trace_ids, type=LIST, valuetype=UTF8"` | ||
Baggage []Tag `parquet:"name=baggage, type=LIST"` | ||
Tags []Tag `parquet:"name=tags, type=LIST"` | ||
|
||
// Extracted from the exchange payload. Will be nil if they are not | ||
// present in the payload or if the payload cannot be unmarshalled. | ||
MessageID string `parquet:"name=message_id, type=UTF8"` | ||
UserID string `parquet:"name=user_id, type=UTF8"` | ||
EventType string `parquet:"name=event_type, type=UTF8"` | ||
SourceID string `parquet:"name=source_id, type=UTF8"` | ||
DestinationID string `parquet:"name=destination_id, type=UTF8"` | ||
WorkspaceID string `parquet:"name=workspace_id, type=UTF8"` | ||
|
||
Name string `parquet:"name=name, type=UTF8"` | ||
SpanTime int64 `parquet:"name=span_time, type=INT_64"` // ms | ||
SpanDuration int64 `parquet:"name=span_duration, type=INT_64"` // ms | ||
|
||
ExchangeTime int64 `parquet:"name=exchange_time, type=INT_64"` // ms | ||
ExchangeDuration int32 `parquet:"name=exchange_duration, type=INT_32"` // ms | ||
|
||
ExchangeRequestMethod string `parquet:"name=exchange_request_method, type=UTF8"` | ||
ExchangeRequestURL string `parquet:"name=exchange_request_url, type=UTF8"` | ||
ExchangeRequestHeaders map[string]string `parquet:"name=exchange_request_headers, type=MAP, keytype=UTF8, valuetype=UTF8"` | ||
ExchangeRequestBody string `parquet:"name=exchange_request_body, type=UTF8"` | ||
|
||
ExchangeResponseStatusCode uint16 `parquet:"name=exchange_response_status_code, type=UINT_16"` | ||
ExchangeResponseStatusText string `parquet:"name=exchange_response_status_text, type=UTF8"` | ||
ExchangeResponseHeaders map[string]string `parquet:"name=exchange_response_headers, type=UTF8, keytype=UTF8, valuetype=UTF8"` | ||
ExchangeResponseBody string `parquet:"name=exchange_response_body, type=UTF8"` | ||
|
||
ExchangeErrorType string `parquet:"name=exchange_error_type, type=UTF8"` | ||
ExchangeErrorMessage string `parquet:"name=exchange_error_message, type=UTF8"` | ||
} |
This file contains 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
Oops, something went wrong.