-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ruihang Xia <[email protected]>
- Loading branch information
Showing
17 changed files
with
336 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,54 @@ | ||
# read line from log-1000.txt and POST it to http://localhost:4000/v1/influxdb/write?db=public&precision=ms | ||
# POST data format: "many_logs,host=1 log=<FILE CONTENT> <INCREMENT ID>" | ||
|
||
import requests | ||
from tqdm import tqdm | ||
from concurrent.futures import ThreadPoolExecutor | ||
|
||
batch_size = 3000 | ||
worker = 8 | ||
|
||
# Define the URL | ||
url = "http://localhost:4000/v1/influxdb/write?db=public&precision=ms" | ||
|
||
|
||
def send_data(start, data): | ||
# Send the POST request | ||
response = requests.post(url, data=data) | ||
# Check the response | ||
if response.status_code >= 300: | ||
print( | ||
f"Failed to send log line {start}: {response.status_code} {response.text}" | ||
) | ||
|
||
|
||
# Open the file | ||
with open("target/log-1000.txt", "r") as file: | ||
lines = file.readlines() | ||
|
||
# Create a progress bar | ||
with tqdm( | ||
total=len(lines), | ||
desc="Processing lines", | ||
bar_format="{l_bar}{bar}| {n_fmt}/{total_fmt}", | ||
) as pbar: | ||
data = "" | ||
with ThreadPoolExecutor(max_workers=worker) as executor: | ||
for i, line in enumerate(lines): | ||
# Prepare the POST data | ||
content = line.strip() | ||
content = content.replace('"', " ") | ||
content = content.replace("'", " ") | ||
content = content.replace("=", " ") | ||
content = content.replace(".", " ") | ||
|
||
data = data + f'many_logs,host=1 log="{content}" {i}\n' | ||
|
||
if i % batch_size == 0: | ||
executor.submit(send_data, i, data) | ||
data = "" | ||
# Update the progress bar | ||
pbar.update(batch_size) | ||
|
||
# close the executor | ||
executor.shutdown(wait=True) |
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,61 @@ | ||
// Copyright 2024 Greptime Team | ||
// | ||
// Licensed 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. | ||
|
||
use std::fmt; | ||
use std::fmt::Display; | ||
use std::sync::Arc; | ||
|
||
use common_query::error::Result; | ||
use common_query::prelude::{Signature, Volatility}; | ||
use datatypes::prelude::ConcreteDataType; | ||
use datatypes::vectors::{BooleanVector, VectorRef}; | ||
|
||
use crate::function::{Function, FunctionContext}; | ||
|
||
const NAME: &str = "matches"; | ||
|
||
/// The function to find remainders | ||
#[derive(Clone, Debug, Default)] | ||
pub struct MatchesFunction; | ||
|
||
impl Display for MatchesFunction { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{}", NAME.to_ascii_uppercase()) | ||
} | ||
} | ||
|
||
impl Function for MatchesFunction { | ||
fn name(&self) -> &str { | ||
NAME | ||
} | ||
|
||
fn return_type(&self, _input_types: &[ConcreteDataType]) -> Result<ConcreteDataType> { | ||
Ok(ConcreteDataType::boolean_datatype()) | ||
} | ||
|
||
fn signature(&self) -> Signature { | ||
Signature::exact( | ||
vec![ | ||
ConcreteDataType::string_datatype(), | ||
ConcreteDataType::string_datatype(), | ||
], | ||
Volatility::Immutable, | ||
) | ||
} | ||
|
||
fn eval(&self, _func_ctx: FunctionContext, columns: &[VectorRef]) -> Result<VectorRef> { | ||
let num_rows = columns[1].len(); | ||
Ok(Arc::new(BooleanVector::from(vec![true; num_rows]))) | ||
} | ||
} |
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
Oops, something went wrong.