docstring_tokens stringlengths 0 76.5k | code_tokens stringlengths 75 1.81M | label_window listlengths 4 2.12k | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|---|
err = decodeResultRuleToken(dec, ent)
if err != nil {
if err != io.EOF && !errors.Is(err, ErrEndOfToken) {
log.Debug("decodeResultRules err: %s", err) | <mask> } else {
<mask> return
<mask> }
<mask>
<mask> i := 0
<mask> for {
<mask> var keyToken json.Token
<mask> keyToken, err = dec.Token()
<mask> if err != nil {
<mask> if err != io.EOF {
<mask> log.Debug("decodeResultRules err: %s", err)
<mask> }
<mask>
<mask> retur... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
return
}
}
} | <mask>
<mask> return
<mask> }
<mask>
<mask> if d, ok := keyToken.(json.Delim); ok {
<mask> switch d {
<mask> case '}':
<mask> i++
<mask> case ']':
<mask> return
<mask> default:
<mask> // Go on.
<mask> }
<mask>
<mask> continue
<mask> }
<mask>
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
// decodeResultRuleToken decodes the tokens of "Rules" type to the logEntry ent.
func decodeResultRuleToken(dec *json.Decoder, ent *logEntry) (err error) {
i := 0
for {
var keyToken json.Token
keyToken, err = dec.Token()
if err != nil {
// Don't wrap the error, because it's informative enough as is.
retur... | <mask>
<mask> continue
<mask> }
<mask>
<mask> key, ok := keyToken.(string)
<mask> if !ok {
<mask> log.Debug("decodeResultRules: keyToken is %T (%[1]v) and not string", keyToken)
<mask>
<mask> return
<mask> }
<mask>
<mask> decodeResultRuleKey(key, i, dec, ent)
</s> Pull reques... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
if d, ok := keyToken.(json.Delim); ok {
switch d {
case '}':
i++
case ']':
return ErrEndOfToken
default:
// Go on. | <mask> key, ok := keyToken.(string)
<mask> if !ok {
<mask> log.Debug("decodeResultRules: keyToken is %T (%[1]v) and not string", keyToken)
<mask>
<mask> return
<mask> }
<mask>
<mask> decodeResultRuleKey(key, i, dec, ent)
<mask> }
<mask> }
</s> Pull request: querylog imp code
Merge i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
continue
}
key, ok := keyToken.(string)
if !ok {
return fmt.Errorf("keyToken is %T (%[1]v) and not string", keyToken) | <mask>
<mask> return
<mask> }
<mask>
<mask> decodeResultRuleKey(key, i, dec, ent)
<mask> }
<mask> }
<mask> }
<mask>
<mask> // decodeResultReverseHosts parses the dec's tokens into ent interpreting it as
</s> Pull request: querylog imp code
Merge in DNS/adguard-home from querylog-imp-code to ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
decodeResultRuleKey(key, i, dec, ent) | <mask> if !ok {
<mask> return fmt.Errorf("keyToken is %T (%[1]v) and not string", keyToken)
<mask> }
<mask> }
<mask> }
<mask>
<mask> // decodeResultReverseHosts parses the dec's tokens into ent interpreting it as
<mask> // the result of hosts container's $dnsrewrite rule. It assumes there are no
<mas... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
// decodeResultIPList parses the dec's tokens into logEntry ent interpreting it
// as the result IP addresses list. | <mask> }
<mask>
<mask> func decodeResultIPList(dec *json.Decoder, ent *logEntry) {
<mask> for {
<mask> itemToken, err := dec.Token()
<mask> if err != nil {
</s> Pull request: querylog imp code
Merge in DNS/adguard-home from querylog-imp-code to master
Squashed commit of the following:
commit a58ad36508a... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
// decodeResultDNSRewriteResultKey decodes the token of "DNSRewriteResult" type
// to the logEntry struct. | <mask> }
<mask>
<mask> func decodeResultDNSRewriteResultKey(key string, dec *json.Decoder, ent *logEntry) {
<mask> var err error
<mask>
<mask> switch key {
</s> Pull request: querylog imp code
Merge in DNS/adguard-home from querylog-imp-code to master
Squashed commit of the following:
commit a58ad36508a23... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
ent.parseDNSRewriteResultIPs() | <mask> if err != nil {
<mask> log.Debug("decodeResultDNSRewriteResultKey response err: %s", err)
<mask> }
<mask>
<mask> for rrType, rrValues := range ent.Result.DNSRewriteResult.Response {
<mask> switch rrType {
<mask> case
<mask> dns.TypeA,
<mask> dns.TypeAAAA:
<mask> for i, v := ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
// decodeResultDNSRewriteResult parses the dec's tokens into logEntry ent
// interpreting it as the result DNSRewriteResult. | <mask> // Go on.
<mask> }
<mask> }
<mask>
<mask> func decodeResultDNSRewriteResult(dec *json.Decoder, ent *logEntry) {
<mask> for {
<mask> key, err := parseKeyToken(dec)
<mask> if err != nil {
<mask> if err != io.EOF && !errors.Is(err, ErrEndOfToken) {
</s> Pull request: querylog imp code
Merge i... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
key, err := parseKeyToken(dec) | <mask> }
<mask>
<mask> func decodeResultDNSRewriteResult(dec *json.Decoder, ent *logEntry) {
<mask> for {
<mask> keyToken, err := dec.Token()
<mask> if err != nil {
<mask> if err != io.EOF {
<mask> log.Debug("decodeResultDNSRewriteResult err: %s", err)
<mask> }
<mask>
</s> Pull request: quer... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
if err != io.EOF && !errors.Is(err, ErrEndOfToken) {
log.Debug("decodeResultDNSRewriteResult: %s", err) | <mask> func decodeResultDNSRewriteResult(dec *json.Decoder, ent *logEntry) {
<mask> for {
<mask> keyToken, err := dec.Token()
<mask> if err != nil {
<mask> if err != io.EOF {
<mask> log.Debug("decodeResultDNSRewriteResult err: %s", err)
<mask> }
<mask>
<mask> return
<mask> }
<mask>
</s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
if key == "" { | <mask>
<mask> return
<mask> }
<mask>
<mask> if d, ok := keyToken.(json.Delim); ok {
<mask> if d == '}' {
<mask> return
<mask> }
<mask>
<mask> continue
<mask> }
<mask>
<mask> key, ok := keyToken.(string)
<mask> if !ok {
</s> Pull request: querylog imp code
Merge in DNS/adgua... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
<mask>
<mask> continue
<mask> }
<mask>
<mask> key, ok := keyToken.(string)
<mask> if !ok {
<mask> log.Debug("decodeResultDNSRewriteResult: keyToken is %T (%[1]v) and not string", keyToken)
<mask>
<mask> return
<mask> }
<mask>
<mask> decodeResultDNSRewriteResultKey(key, dec, ent)
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go | |
key, err := parseKeyToken(dec) | <mask> func decodeResult(dec *json.Decoder, ent *logEntry) {
<mask> defer translateResult(ent)
<mask>
<mask> for {
<mask> keyToken, err := dec.Token()
<mask> if err != nil {
<mask> if err != io.EOF {
<mask> log.Debug("decodeResult err: %s", err)
<mask> }
<mask>
</s> Pull request: querylog i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
if err != io.EOF && !errors.Is(err, ErrEndOfToken) {
log.Debug("decodeResult: %s", err) | <mask>
<mask> for {
<mask> keyToken, err := dec.Token()
<mask> if err != nil {
<mask> if err != io.EOF {
<mask> log.Debug("decodeResult err: %s", err)
<mask> }
<mask>
<mask> return
<mask> }
<mask>
</s> Pull request: querylog imp code
Merge in DNS/adguard-home from querylog-imp-code t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
if key == "" { | <mask>
<mask> return
<mask> }
<mask>
<mask> if d, ok := keyToken.(json.Delim); ok {
<mask> if d == '}' {
<mask> return
<mask> }
<mask>
<mask> continue
<mask> }
<mask>
<mask> key, ok := keyToken.(string)
<mask> if !ok {
</s> Pull request: querylog imp code
Merge in DNS/adgua... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
<mask>
<mask> continue
<mask> }
<mask>
<mask> key, ok := keyToken.(string)
<mask> if !ok {
<mask> log.Debug("decodeResult: keyToken is %T (%[1]v) and not string", keyToken)
<mask>
<mask> return
<mask> }
<mask>
<mask> decHandler, ok := resultDecHandlers[key]
<mask> if ok {
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go | |
// resultHandlers is the map of log entry decode handlers for various keys. | <mask> }
<mask> }
<mask>
<mask> var resultHandlers = map[string]logEntryHandler{
<mask> "IsFiltered": func(t json.Token, ent *logEntry) error {
<mask> v, ok := t.(bool)
<mask> if !ok {
<mask> return nil
</s> Pull request: querylog imp code
Merge in DNS/adguard-home from querylog-imp-code to master
... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
// resultDecHandlers is the map of decode handlers for various keys. | <mask> }
<mask>
<mask> var resultDecHandlers = map[string]func(dec *json.Decoder, ent *logEntry){
<mask> "ReverseHosts": decodeResultReverseHosts,
<mask> "IPList": decodeResultIPList,
<mask> "Rules": decodeResultRules,
<mask> "DNSRewriteResult": decodeResultDNSRewriteResult,
</s> P... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
// decodeLogEntry decodes string str to logEntry ent. | <mask> "Rules": decodeResultRules,
<mask> "DNSRewriteResult": decodeResultDNSRewriteResult,
<mask> }
<mask>
<mask> func decodeLogEntry(ent *logEntry, str string) {
<mask> dec := json.NewDecoder(strings.NewReader(str))
<mask> dec.UseNumber()
<mask>
<mask> for {
</s> Pull request: querylog imp... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/decode.go |
// queryLogFileName is a name of the log file. ".gz" extension is added later
// during compression.
const queryLogFileName = "querylog.json" | <mask> "github.com/AdguardTeam/golibs/timeutil"
<mask> "github.com/miekg/dns"
<mask> )
<mask>
<mask> const (
<mask> queryLogFileName = "querylog.json" // .gz added during compression
<mask> )
<mask>
<mask> // queryLog is a structure that writes and reads the DNS query log
<mask> type queryLog struct {
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlog.go |
// queryLog is a structure that writes and reads the DNS query log. | <mask> const (
<mask> queryLogFileName = "querylog.json" // .gz added during compression
<mask> )
<mask>
<mask> // queryLog is a structure that writes and reads the DNS query log
<mask> type queryLog struct {
<mask> findClient func(ids []string) (c *Client, err error)
<mask>
<mask> // confMu protects conf... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlog.go |
<mask> )
<mask>
<mask> // queryLog is a structure that writes and reads the DNS query log
<mask> type queryLog struct {
<mask> findClient func(ids []string) (c *Client, err error)
<mask>
<mask> // confMu protects conf.
<mask> confMu *sync.RWMutex
<mask> conf *Config
<mask>
<mask> // logFile is the ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlog.go | |
conf *Config
anonymizer *aghnet.IPMut
findClient func(ids []string) (c *Client, err error) | <mask> findClient func(ids []string) (c *Client, err error)
<mask>
<mask> // confMu protects conf.
<mask> confMu *sync.RWMutex
<mask> conf *Config
<mask>
<mask> // logFile is the path to the log file.
<mask> logFile string
<mask>
<mask> // bufferLock protects buffer.
</s> Pull request: querylog i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlog.go |
<mask>
<mask> // logFile is the path to the log file.
<mask> logFile string
<mask>
<mask> // bufferLock protects buffer.
<mask> bufferLock sync.RWMutex
<mask> // buffer contains recent log entries. The entries in this buffer must not
<mask> // be modified.
<mask> buffer []*logEntry
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlog.go | |
// bufferLock protects buffer.
bufferLock sync.RWMutex
// fileFlushLock synchronizes a file-flushing goroutine and main thread.
fileFlushLock sync.Mutex | <mask> // buffer contains recent log entries. The entries in this buffer must not
<mask> // be modified.
<mask> buffer []*logEntry
<mask>
<mask> fileFlushLock sync.Mutex // synchronize a file-flushing goroutine and main thread
<mask> flushPending bool // don't start another goroutine while the previ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlog.go |
flushPending bool | <mask> fileFlushLock sync.Mutex // synchronize a file-flushing goroutine and main thread
<mask> flushPending bool // don't start another goroutine while the previous one is still running
<mask> fileWriteLock sync.Mutex
<mask>
<mask> anonymizer *aghnet.IPMut
<mask> }
<mask>
<mask> // ClientProto val... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlog.go |
// newLogEntry creates an instance of logEntry from parameters.
func newLogEntry(params *AddParams) (entry *logEntry) { | <mask>
<mask> log.Debug("querylog: cleared")
<mask> }
<mask>
<mask> func (l *queryLog) Add(params *AddParams) {
<mask> var isEnabled, fileIsEnabled bool
<mask> var memSize uint32
<mask> func() {
<mask> l.confMu.RLock()
<mask> defer l.confMu.RUnlock()
<mask>
<mask> isEnabled, fileIsEnabled = l.c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlog.go |
entry = &logEntry{
// TODO(d.kolyshev): Export this timestamp to func params.
Time: time.Now(), | <mask> }
<mask>
<mask> now := time.Now()
<mask> q := params.Question.Question[0]
<mask> entry := &logEntry{
<mask> Time: now,
<mask>
<mask> QHost: strings.ToLower(q.Name[:len(q.Name)-1]),
<mask> QType: dns.Type(q.Qtype).String(),
<mask> QClass: dns.Class(q.Qclass).String(),
<mask>
</s> Pull... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlog.go |
host string
answer net.IP
client net.IP
num int | <mask> addEntry(l, "test.example.org", net.IPv4(1, 1, 1, 3), net.IPv4(2, 2, 2, 3))
<mask> addEntry(l, "example.com", net.IPv4(1, 1, 1, 4), net.IPv4(2, 2, 2, 4))
<mask>
<mask> type tcAssertion struct {
<mask> num int
<mask> host string
<mask> answer, client net.IP
<mask> }
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlog_test.go |
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> // Timestamp not found errors.
<mask> const (
<mask> ErrTSNotFound errors.Error = "ts not found"
<mask> ErrTSTooLate errors.Error = "ts too late"
<mask> ErrTSTooEarly errors.Error = "ts too ea... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go | |
// Timestamp not found errors.
errTSNotFound errors.Error = "ts not found"
errTSTooLate errors.Error = "ts too late"
errTSTooEarly errors.Error = "ts too early"
// maxEntrySize is a maximum size of the entry.
//
// TODO: Find a way to grow buffer instead of relying on this value when
// reading strings.
maxE... | <mask> )
<mask>
<mask> // Timestamp not found errors.
<mask> const (
<mask> ErrTSNotFound errors.Error = "ts not found"
<mask> ErrTSTooLate errors.Error = "ts too late"
<mask> ErrTSTooEarly errors.Error = "ts too early"
<mask> )
<mask>
<mask> // TODO: Find a way to grow buffer instead of relying on this... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// qLogFile represents a single query log file. It allows reading from the
// file in the reverse order.
//
// Please note, that this is a stateful object. Internally, it contains a
// pointer to a specific position in the file, and it reads lines in reverse
// order starting from that position.
type qLogFile struct ... | <mask> ErrTSTooLate errors.Error = "ts too late"
<mask> ErrTSTooEarly errors.Error = "ts too early"
<mask> )
<mask>
<mask> // TODO: Find a way to grow buffer instead of relying on this value when reading strings
<mask> const maxEntrySize = 16 * 1024
<mask>
<mask> // buffer should be enough for at least thi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// buffer that we've read from the file.
buffer []byte | <mask>
<mask> // TODO: Find a way to grow buffer instead of relying on this value when reading strings
<mask> const maxEntrySize = 16 * 1024
<mask>
<mask> // buffer should be enough for at least this number of entries
<mask> const bufferSize = 100 * maxEntrySize
<mask>
<mask> // QLogFile represents a single ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// lock is a mutex to make it thread-safe.
lock sync.Mutex
// position is the position in the file.
position int64
// bufferStart is the start of the buffer (in the file).
bufferStart int64
// bufferLen is the length of the buffer.
bufferLen int | <mask>
<mask> // buffer should be enough for at least this number of entries
<mask> const bufferSize = 100 * maxEntrySize
<mask>
<mask> // QLogFile represents a single query log file
<mask> // It allows reading from the file in the reverse order
<mask> //
<mask> // Please note that this is a stateful object.
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// newQLogFile initializes a new instance of the qLogFile.
func newQLogFile(path string) (qf *qLogFile, err error) { | <mask>
<mask> lock sync.Mutex // We use mutex to make it thread-safe
<mask> }
<mask>
<mask> // NewQLogFile initializes a new instance of the QLogFile
<mask> func NewQLogFile(path string) (*QLogFile, error) {
<mask> f, err := os.OpenFile(path, os.O_RDONLY, 0o644)
<mask> if err != nil {
<mask> return nil,... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
return &qLogFile{file: f}, nil
}
// validateQLogLineIdx returns error if the line index is not valid to continue
// search.
func (q *qLogFile) validateQLogLineIdx(lineIdx, lastProbeLineIdx, ts, fSize int64) (err error) {
if lineIdx == lastProbeLineIdx {
if lineIdx == 0 {
return errTSTooEarly
}
// If we're ... | <mask> if err != nil {
<mask> return nil, err
<mask> }
<mask>
<mask> return &QLogFile{
<mask> file: f,
<mask> }, nil
<mask> }
<mask>
<mask> // seekTS performs binary search in the query log file looking for a record
<mask> // with the specified timestamp. Once the record is found, it sets
<mask> /... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// with the specified timestamp. Once the record is found, it sets "position"
// so that the next ReadNext call returned that record. | <mask> }, nil
<mask> }
<mask>
<mask> // seekTS performs binary search in the query log file looking for a record
<mask> // with the specified timestamp. Once the record is found, it sets
<mask> // "position" so that the next ReadNext call returned that record.
<mask> //
<mask> // The algorithm is rather simpl... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// 1. It starts with the position in the middle of a file.
// 2. Shifts back to the beginning of the line.
// 3. Checks the log record timestamp.
// 4. If it is lower than the timestamp we are looking for, it shifts seek
// position to 3/4 of the file. Otherwise, to 1/4 of the file.
// 5. It performs the searc... | <mask> // with the specified timestamp. Once the record is found, it sets
<mask> // "position" so that the next ReadNext call returned that record.
<mask> //
<mask> // The algorithm is rather simple:
<mask> // 1. It starts with the position in the middle of a file
<mask> // 2. Shifts back to the beginning of the ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// - It returns the position of the line with the timestamp we were looking
// for so that when we call "ReadNext" this line was returned.
// - Depth of the search (how many times we compared timestamps).
// - If we could not find it, it returns one of the errors described above.
func (q *qLogFile) seekTS(tim... | <mask> // it shifts seek position to 3/4 of the file. Otherwise, to 1/4 of the file.
<mask> // 5. It performs the search again, every time the search scope is narrowed twice.
<mask> //
<mask> // Returns:
<mask> // * It returns the position of the the line with the timestamp we were looking for
<mask> // so that w... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Empty the buffer. | <mask> func (q *QLogFile) seekTS(timestamp int64) (int64, int, error) {
<mask> q.lock.Lock()
<mask> defer q.lock.Unlock()
<mask>
<mask> // Empty the buffer
<mask> q.buffer = nil
<mask>
<mask> // First of all, check the file size
<mask> fileInfo, err := q.file.Stat()
<mask> if err != nil {
</s> Pull ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// First of all, check the file size. | <mask>
<mask> // Empty the buffer
<mask> q.buffer = nil
<mask>
<mask> // First of all, check the file size
<mask> fileInfo, err := q.file.Stat()
<mask> if err != nil {
<mask> return 0, 0, err
<mask> }
<mask>
</s> Pull request: querylog imp code
Merge in DNS/adguard-home from querylog-imp-code to ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Define the search scope.
// Start of the search interval (position in the file).
start := int64(0)
// End of the search interval (position in the file).
end := fileInfo.Size()
// Probe is the approximate index of the line we'll try to check.
probe := (end - start) / 2
| <mask> if err != nil {
<mask> return 0, 0, err
<mask> }
<mask>
<mask> // Define the search scope
<mask> start := int64(0) // start of the search interval (position in the file)
<mask> end := fileInfo.Size() // end of the search interval (position in the file)
<mask> probe := (end - start) ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Index of the probe line in the file.
var lineIdx int64 | <mask> start := int64(0) // start of the search interval (position in the file)
<mask> end := fileInfo.Size() // end of the search interval (position in the file)
<mask> probe := (end - start) / 2 // probe -- approximate index of the line we'll try to check
<mask> var line string
<mask> var lineI... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Index of the last probe line.
var lastProbeLineIdx int64 | <mask> probe := (end - start) / 2 // probe -- approximate index of the line we'll try to check
<mask> var line string
<mask> var lineIdx int64 // index of the probe line in the file
<mask> var lineEndIdx int64
<mask> var lastProbeLineIdx int64 // index of the last probe line
<mask> lastProbeLineIdx = -1
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Count seek depth in order to detect mistakes. If depth is too large,
// we should stop the search. | <mask> var lineEndIdx int64
<mask> var lastProbeLineIdx int64 // index of the last probe line
<mask> lastProbeLineIdx = -1
<mask>
<mask> // Count seek depth in order to detect mistakes
<mask> // If depth is too large, we should stop the search
<mask> depth := 0
<mask>
<mask> for {
<mask> // Get the... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Get the line at the specified position. | <mask> // If depth is too large, we should stop the search
<mask> depth := 0
<mask>
<mask> for {
<mask> // Get the line at the specified position
<mask> line, lineIdx, lineEndIdx, err = q.readProbeLine(probe)
<mask> if err != nil {
<mask> return 0, depth, err
<mask> }
<mask>
</s> Pull request... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Check if the line index if invalid.
err = q.validateQLogLineIdx(lineIdx, lastProbeLineIdx, timestamp, fileInfo.Size())
if err != nil {
return 0, depth, err | <mask> if err != nil {
<mask> return 0, depth, err
<mask> }
<mask>
<mask> if lineIdx == lastProbeLineIdx {
<mask> if lineIdx == 0 {
<mask> return 0, depth, ErrTSTooEarly
<mask> }
<mask>
<mask> // If we're testing the same line twice then most likely
<mask> // the scope is too narro... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Save the last found idx. | <mask> } else if lineIdx == fileInfo.Size() {
<mask> return 0, depth, ErrTSTooLate
<mask> }
<mask>
<mask> // Save the last found idx
<mask> lastProbeLineIdx = lineIdx
<mask>
<mask> // Get the timestamp from the query log record
<mask> ts := readQLogTimestamp(line)
<mask> if ts == 0 {
</s> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Get the timestamp from the query log record. | <mask>
<mask> // Save the last found idx
<mask> lastProbeLineIdx = lineIdx
<mask>
<mask> // Get the timestamp from the query log record
<mask> ts := readQLogTimestamp(line)
<mask> if ts == 0 {
<mask> return 0, depth, fmt.Errorf("looking up timestamp %d in %q: record %q has empty timestamp", times... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
return 0, depth, fmt.Errorf(
"looking up timestamp %d in %q: record %q has empty timestamp",
timestamp,
q.file.Name(),
line,
) | <mask>
<mask> // Get the timestamp from the query log record
<mask> ts := readQLogTimestamp(line)
<mask> if ts == 0 {
<mask> return 0, depth, fmt.Errorf("looking up timestamp %d in %q: record %q has empty timestamp", timestamp, q.file.Name(), line)
<mask> }
<mask>
<mask> if ts == timestamp {
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Hurray, returning the result. | <mask> return 0, depth, fmt.Errorf("looking up timestamp %d in %q: record %q has empty timestamp", timestamp, q.file.Name(), line)
<mask> }
<mask>
<mask> if ts == timestamp {
<mask> // Hurray, returning the result
<mask> break
<mask> }
<mask>
<mask> // Narrow the scope and repeat the search
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Narrow the scope and repeat the search. | <mask> // Hurray, returning the result
<mask> break
<mask> }
<mask>
<mask> // Narrow the scope and repeat the search
<mask> if ts > timestamp {
<mask> // If the timestamp we're looking for is OLDER than what we found
<mask> // Then the line is somewhere on the LEFT side from the current probe... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// If the timestamp we're looking for is OLDER than what we found,
// then the line is somewhere on the LEFT side from the current
// probe position. | <mask> }
<mask>
<mask> // Narrow the scope and repeat the search
<mask> if ts > timestamp {
<mask> // If the timestamp we're looking for is OLDER than what we found
<mask> // Then the line is somewhere on the LEFT side from the current probe position
<mask> end = lineIdx
<mask> } else {
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// If the timestamp we're looking for is NEWER than what we found,
// then the line is somewhere on the RIGHT side from the current
// probe position. | <mask> // If the timestamp we're looking for is OLDER than what we found
<mask> // Then the line is somewhere on the LEFT side from the current probe position
<mask> end = lineIdx
<mask> } else {
<mask> // If the timestamp we're looking for is NEWER than what we found
<mask> // Then the line is s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
return 0, depth, fmt.Errorf(
"looking up timestamp %d in %q: depth %d too high: %w",
timestamp,
q.file.Name(),
depth,
errTSNotFound,
) | <mask> probe = start + (end-start)/2
<mask>
<mask> depth++
<mask> if depth >= 100 {
<mask> return 0, depth, fmt.Errorf("looking up timestamp %d in %q: depth %d too high: %w", timestamp, q.file.Name(), depth, ErrTSNotFound)
<mask> }
<mask> }
<mask>
<mask> q.position = lineIdx + int64(len(line))
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// SeekStart changes the current position to the end of the file. Please note,
// that we're reading query log in the reverse order and that's why log start
// is actually the end of file. | <mask> q.position = lineIdx + int64(len(line))
<mask> return q.position, depth, nil
<mask> }
<mask>
<mask> // SeekStart changes the current position to the end of the file
<mask> // Please note that we're reading query log in the reverse order
<mask> // and that's why log start is actually the end of file
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Returns nil if we were able to change the current position. Returns error
// in any other case.
func (q *qLogFile) SeekStart() (int64, error) { | <mask> // SeekStart changes the current position to the end of the file
<mask> // Please note that we're reading query log in the reverse order
<mask> // and that's why log start is actually the end of file
<mask> //
<mask> // Returns nil if we were able to change the current position.
<mask> // Returns error in ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Empty the buffer. | <mask> func (q *QLogFile) SeekStart() (int64, error) {
<mask> q.lock.Lock()
<mask> defer q.lock.Unlock()
<mask>
<mask> // Empty the buffer
<mask> q.buffer = nil
<mask>
<mask> // First of all, check the file size
<mask> fileInfo, err := q.file.Stat()
<mask> if err != nil {
</s> Pull request: querylog... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// First of all, check the file size. | <mask>
<mask> // Empty the buffer
<mask> q.buffer = nil
<mask>
<mask> // First of all, check the file size
<mask> fileInfo, err := q.file.Stat()
<mask> if err != nil {
<mask> return 0, err
<mask> }
<mask>
</s> Pull request: querylog imp code
Merge in DNS/adguard-home from querylog-imp-code to mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Place the position to the very end of file. | <mask> if err != nil {
<mask> return 0, err
<mask> }
<mask>
<mask> // Place the position to the very end of file
<mask> q.position = fileInfo.Size() - 1
<mask> if q.position < 0 {
<mask> q.position = 0
<mask> }
<mask> return q.position, nil
</s> Pull request: querylog imp code
Merge in DNS/adgua... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// ReadNext reads the next line (in the reverse order) from the file and shifts
// the current position left to the next (actually prev) line.
//
// Returns io.EOF if there's nothing more to read.
func (q *qLogFile) ReadNext() (string, error) { | <mask> }
<mask> return q.position, nil
<mask> }
<mask>
<mask> // ReadNext reads the next line (in the reverse order) from the file
<mask> // and shifts the current position left to the next (actually prev) line.
<mask> // returns io.EOF if there's nothing to read more
<mask> func (q *QLogFile) ReadNext() (st... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Shift position. | <mask> if err != nil {
<mask> return "", err
<mask> }
<mask>
<mask> // Shift position
<mask> if lineIdx == 0 {
<mask> q.position = 0
<mask> } else {
<mask> // there's usually a line break before the line
<mask> // so we should shift one more char left from the line
</s> Pull request: querylog i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// There's usually a line break before the line, so we should shift one
// more char left from the line "\nline". | <mask> // Shift position
<mask> if lineIdx == 0 {
<mask> q.position = 0
<mask> } else {
<mask> // there's usually a line break before the line
<mask> // so we should shift one more char left from the line
<mask> // line\nline
<mask> q.position = lineIdx - 1
<mask> }
<mask> return line, err
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Close frees the underlying resources.
func (q *qLogFile) Close() error { | <mask> }
<mask> return line, err
<mask> }
<mask>
<mask> // Close frees the underlying resources
<mask> func (q *QLogFile) Close() error {
<mask> return q.file.Close()
<mask> }
<mask>
<mask> // readNextLine reads the next line from the specified position
<mask> // this line actually have to END on that p... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// readNextLine reads the next line from the specified position. This line
// actually have to END on that position. | <mask> func (q *QLogFile) Close() error {
<mask> return q.file.Close()
<mask> }
<mask>
<mask> // readNextLine reads the next line from the specified position
<mask> // this line actually have to END on that position.
<mask> //
<mask> // the algorithm is:
<mask> // 1. check if we have the buffer initialized
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// The algorithm is:
// 1. Check if we have the buffer initialized.
// 2. If it is so, scan it and look for the line there.
// 3. If we cannot find the line there, read the prev chunk into the buffer.
// 4. Read the line from the buffer.
func (q *qLogFile) readNextLine(position int64) (string, int64, error) { | <mask>
<mask> // readNextLine reads the next line from the specified position
<mask> // this line actually have to END on that position.
<mask> //
<mask> // the algorithm is:
<mask> // 1. check if we have the buffer initialized
<mask> // 2. if it is, scan it and look for the line there
<mask> // 3. if we canno... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Time to re-init the buffer. | <mask> // 4. read the line from the buffer
<mask> func (q *QLogFile) readNextLine(position int64) (string, int64, error) {
<mask> relativePos := position - q.bufferStart
<mask> if q.buffer == nil || (relativePos < maxEntrySize && q.bufferStart != 0) {
<mask> // Time to re-init the buffer
<mask> err := q.ini... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Look for the end of the prev line, this is where we'll read from. | <mask> }
<mask> relativePos = position - q.bufferStart
<mask> }
<mask>
<mask> // Look for the end of the prev line
<mask> // This is where we'll read from
<mask> startLine := int64(0)
<mask> for i := relativePos - 1; i >= 0; i-- {
<mask> if q.buffer[i] == '\n' {
<mask> startLine = i + 1
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// initBuffer initializes the qLogFile buffer. The goal is to read a chunk of
// file that includes the line with the specified position.
func (q *qLogFile) initBuffer(position int64) error { | <mask> lineIdx := q.bufferStart + startLine
<mask> return line, lineIdx, nil
<mask> }
<mask>
<mask> // initBuffer initializes the QLogFile buffer.
<mask> // the goal is to read a chunk of file that includes the line with the specified position.
<mask> func (q *QLogFile) initBuffer(position int64) error {
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Seek to this position. | <mask> if position > bufferSize {
<mask> q.bufferStart = position - bufferSize
<mask> }
<mask>
<mask> // Seek to this position
<mask> _, err := q.file.Seek(q.bufferStart, io.SeekStart)
<mask> if err != nil {
<mask> return err
<mask> }
<mask>
</s> Pull request: querylog imp code
Merge in DNS/adgu... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// readProbeLine reads a line that includes the specified position. This
// method is supposed to be used when we use binary search in the Seek method.
// In the case of consecutive reads, use readNext, cause it uses better buffer.
func (q *qLogFile) readProbeLine(position int64) (string, int64, int64, error) {
// Fi... | <mask>
<mask> return err
<mask> }
<mask>
<mask> // readProbeLine reads a line that includes the specified position
<mask> // this method is supposed to be used when we use binary search in the Seek method
<mask> // in the case of consecutive reads, use readNext (it uses a better buffer)
<mask> func (q *QLogF... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Position relative to the buffer we're going to read.
relativePos := position | <mask> func (q *QLogFile) readProbeLine(position int64) (string, int64, int64, error) {
<mask> // First of all, we should read a buffer that will include the query log line
<mask> // In order to do this, we'll define the boundaries
<mask> seekPosition := int64(0)
<mask> relativePos := position // position rela... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Seek to this position. | <mask> seekPosition = position - maxEntrySize
<mask> relativePos = maxEntrySize
<mask> }
<mask>
<mask> // Seek to this position
<mask> _, err := q.file.Seek(seekPosition, io.SeekStart)
<mask> if err != nil {
<mask> return "", 0, 0, err
<mask> }
<mask>
</s> Pull request: querylog imp code
Merge ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// The buffer size is 2*maxEntrySize. | <mask> if err != nil {
<mask> return "", 0, 0, err
<mask> }
<mask>
<mask> // The buffer size is 2*maxEntrySize
<mask> buffer := make([]byte, maxEntrySize*2)
<mask> bufferLen, err := q.file.Read(buffer)
<mask> if err != nil {
<mask> return "", 0, 0, err
<mask> }
</s> Pull request: querylog imp cod... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Now start looking for the new line character starting from the
// relativePos and going left. | <mask> if err != nil {
<mask> return "", 0, 0, err
<mask> }
<mask>
<mask> // Now start looking for the new line character starting
<mask> // from the relativePos and going left
<mask> startLine := int64(0)
<mask> for i := relativePos - 1; i >= 0; i-- {
<mask> if buffer[i] == '\n' {
<mask> startL... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Looking for the end of line now. | <mask> startLine = i + 1
<mask> break
<mask> }
<mask> }
<mask> // Looking for the end of line now
<mask> endLine := int64(bufferLen)
<mask> lineEndIdx := endLine + seekPosition
<mask> for i := relativePos; i < int64(bufferLen); i++ {
<mask> if buffer[i] == '\n' {
<mask> endLine = i
</s> Pul... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// Finally we can return the string we were looking for. | <mask> break
<mask> }
<mask> }
<mask>
<mask> // Finally we can return the string we were looking for
<mask> lineIdx := startLine + seekPosition
<mask> return string(buffer[startLine:endLine]), lineIdx, lineEndIdx, nil
<mask> }
<mask>
<mask> // readJSONvalue reads a JSON string in form of '"key":"va... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// readJSONValue reads a JSON string in form of '"key":"value"'. prefix must
// be of the form '"key":"' to generate less garbage. | <mask> lineIdx := startLine + seekPosition
<mask> return string(buffer[startLine:endLine]), lineIdx, lineEndIdx, nil
<mask> }
<mask>
<mask> // readJSONvalue reads a JSON string in form of '"key":"value"'. prefix must be
<mask> // of the form '"key":"' to generate less garbage.
<mask> func readJSONValue(s, pr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// readQLogTimestamp reads the timestamp field from the query log line. | <mask> end := start + i
<mask> return s[start:end]
<mask> }
<mask>
<mask> // readQLogTimestamp reads the timestamp field from the query log line
<mask> func readQLogTimestamp(str string) int64 {
<mask> val := readJSONValue(str, `"T":"`)
<mask> if len(val) == 0 {
<mask> val = readJSONValue(str, `"Time":"... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile.go |
// newTestQLogFile creates new *qLogFile for tests and registers the required | <mask>
<mask> return files
<mask> }
<mask>
<mask> // newTestQLogFile creates new *QLogFile for tests and registers the required
<mask> // cleanup functions.
<mask> func newTestQLogFile(t *testing.T, linesNum int) (file *QLogFile) {
<mask> t.Helper()
<mask>
<mask> testFile := prepareTestFiles(t, 1, lines... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
func newTestQLogFile(t *testing.T, linesNum int) (file *qLogFile) { | <mask> }
<mask>
<mask> // newTestQLogFile creates new *QLogFile for tests and registers the required
<mask> // cleanup functions.
<mask> func newTestQLogFile(t *testing.T, linesNum int) (file *QLogFile) {
<mask> t.Helper()
<mask>
<mask> testFile := prepareTestFiles(t, 1, linesNum)[0]
<mask>
<mask> // Cr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
// Create the new qLogFile instance.
file, err := newQLogFile(testFile) | <mask> t.Helper()
<mask>
<mask> testFile := prepareTestFiles(t, 1, linesNum)[0]
<mask>
<mask> // Create the new QLogFile instance.
<mask> file, err := NewQLogFile(testFile)
<mask> require.NoError(t, err)
<mask>
<mask> assert.NotNil(t, file)
<mask> testutil.CleanupAndRequireSuccess(t, file.Close)
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
func getQLogFileLine(q *qLogFile, lineNumber int) (line string, err error) { | <mask> }
<mask> }
<mask> }
<mask>
<mask> func getQLogFileLine(q *QLogFile, lineNumber int) (line string, err error) {
<mask> if _, err = q.SeekStart(); err != nil {
<mask> return line, err
<mask> }
<mask>
<mask> for i := 1; i < lineNumber; i++ {
</s> Pull request: querylog imp code
Merge in DNS/ad... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
// Create the new qLogFile instance. | <mask> }
<mask>
<mask> // Check adding and loading (with filtering) entries from disk and memory.
<mask> func TestQLogFile(t *testing.T) {
<mask> // Create the new QLogFile instance.
<mask> q := newTestQLogFile(t, 2)
<mask>
<mask> // Seek to the start.
<mask> pos, err := q.SeekStart()
<mask> require.No... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
func newTestQLogFileData(t *testing.T, data string) (file *qLogFile) { | <mask> require.Equal(t, io.EOF, err)
<mask> assert.Empty(t, line)
<mask> }
<mask>
<mask> func NewTestQLogFileData(t *testing.T, data string) (file *QLogFile) {
<mask> f, err := os.CreateTemp(t.TempDir(), "*.txt")
<mask> require.NoError(t, err)
<mask> testutil.CleanupAndRequireSuccess(t, f.Close)
<mask>
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
file, err = newQLogFile(f.Name()) | <mask>
<mask> _, err = f.WriteString(data)
<mask> require.NoError(t, err)
<mask>
<mask> file, err = NewQLogFile(f.Name())
<mask> require.NoError(t, err)
<mask> testutil.CleanupAndRequireSuccess(t, file.Close)
<mask>
<mask> return file
<mask> }
</s> Pull request: querylog imp code
Merge in DNS/adgua... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
wantErr error | <mask> timestamp, _ := time.Parse(time.RFC3339Nano, "2020-08-31T18:44:25.376690873+03:00")
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> delta int
<mask> wantDepth int
<mask> }{{
<mask> name: "ok",
</s> Pull request: querylog imp code
Merge in DNS/adguard-home from ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> delta int
<mask> wantErr error
<mask> wantDepth int
<mask> }{{
<mask> name: "ok",
<mask> delta: 0,
<mask> wantErr: nil,
</s> Pull request: querylog imp code
Merge in DNS/adguard-home from querylog-imp-code... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go | |
wantErr: errTSTooLate, | <mask> wantDepth: 2,
<mask> }, {
<mask> name: "too_late",
<mask> delta: 2,
<mask> wantErr: ErrTSTooLate,
<mask> wantDepth: 2,
<mask> }, {
<mask> name: "too_early",
<mask> delta: -2,
<mask> wantErr: ErrTSTooEarly,
</s> Pull request: querylog imp code
Merge in DNS/adgua... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
wantErr: errTSTooEarly, | <mask> wantDepth: 2,
<mask> }, {
<mask> name: "too_early",
<mask> delta: -2,
<mask> wantErr: ErrTSTooEarly,
<mask> wantDepth: 1,
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
</s> Pull request: querylog imp code
Merge in DNS/adgu... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
q := newTestQLogFileData(t, data) | <mask> timestamp.Format(time.RFC3339Nano),
<mask> timestamp.Add(time.Second).Format(time.RFC3339Nano),
<mask> )
<mask>
<mask> q := NewTestQLogFileData(t, data)
<mask>
<mask> _, depth, err := q.seekTS(timestamp.Add(time.Second * time.Duration(tc.delta)).UnixNano())
<mask> require.Truef(t, e... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogfile_test.go |
// qLogReader allows reading from multiple query log files in the reverse
// order. | <mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> // QLogReader allows reading from multiple query log files in the reverse order.
<mask> //
<mask> // Please note that this is a stateful object.
<mask> // Internally, it contains a pointer to a par... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogreader.go |
// Please note that this is a stateful object. Internally, it contains a
// pointer to a particular query log file, and to a specific position in this
// file, and it reads lines in reverse order starting from that position.
type qLogReader struct {
// qFiles is an array with the query log files. The order is from o... | <mask> )
<mask>
<mask> // QLogReader allows reading from multiple query log files in the reverse order.
<mask> //
<mask> // Please note that this is a stateful object.
<mask> // Internally, it contains a pointer to a particular query log file, and
<mask> // to a specific position in this file, and it reads line... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogreader.go |
// newQLogReader initializes a qLogReader instance with the specified files.
func newQLogReader(files []string) (*qLogReader, error) {
qFiles := make([]*qLogFile, 0) | <mask>
<mask> currentFile int // Index of the current file
<mask> }
<mask>
<mask> // NewQLogReader initializes a QLogReader instance
<mask> // with the specified files
<mask> func NewQLogReader(files []string) (*QLogReader, error) {
<mask> qFiles := make([]*QLogFile, 0)
<mask>
<mask> for _, f := range f... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogreader.go |
q, err := newQLogFile(f) | <mask> func NewQLogReader(files []string) (*QLogReader, error) {
<mask> qFiles := make([]*QLogFile, 0)
<mask>
<mask> for _, f := range files {
<mask> q, err := NewQLogFile(f)
<mask> if err != nil {
<mask> if errors.Is(err, os.ErrNotExist) {
<mask> continue
<mask> }
<mask>
</s> Pull request:... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogreader.go |
cErr := closeQFiles(qFiles)
if cErr != nil {
log.Debug("querylog: closing files: %s", cErr) | <mask> continue
<mask> }
<mask>
<mask> // Close what we've already opened.
<mask> cerr := closeQFiles(qFiles)
<mask> if cerr != nil {
<mask> log.Debug("querylog: closing files: %s", cerr)
<mask> }
<mask>
<mask> return nil, err
<mask> }
<mask>
</s> Pull request: querylog imp c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogreader.go |
return &qLogReader{qFiles: qFiles, currentFile: len(qFiles) - 1}, nil | <mask>
<mask> qFiles = append(qFiles, q)
<mask> }
<mask>
<mask> return &QLogReader{
<mask> qFiles: qFiles,
<mask> currentFile: (len(qFiles) - 1),
<mask> }, nil
<mask> }
<mask>
<mask> // seekTS performs binary search of a query log record with the specified
<mask> // timestamp. If the recor... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogreader.go |
// timestamp. If the record is found, it sets qLogReader's position to point
// to that line, so that the next ReadNext call returned this line.
func (r *qLogReader) seekTS(timestamp int64) (err error) { | <mask> }, nil
<mask> }
<mask>
<mask> // seekTS performs binary search of a query log record with the specified
<mask> // timestamp. If the record is found, it sets QLogReader's position to point to
<mask> // that line, so that the next ReadNext call returned this line.
<mask> func (r *QLogReader) seekTS(times... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/cbc7985e756e40ec6ee290c003ff343f825a89b2 | internal/querylog/qlogreader.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.