text stringlengths 0 234 |
|---|
for Some_Message'Scalar_Storage_Order use System.High_Order_First; |
Message : Some_Message := (A => 55, B => 40002, C => 13); |
begin |
Kafka.Produce(Topic, |
Kafka.RD_KAFKA_PARTITION_UA, |
Kafka.RD_KAFKA_MSG_F_COPY, |
Message'Address, |
13, |
System.Null_Address, -- key is optional |
0, |
System.Null_Address); |
Function Definition: procedure Simple_Consumer is |
Function Body: use type System.Address; |
use type Interfaces.C.size_t; |
Config : Kafka.Config_Type; |
Handle : Kafka.Handle_Type; |
Handler : Signal.Handler; -- basic Signal handler to stop on CTRL + C |
package KafkaTopic is new GetCommandArgument ("-t:", "--topic:", "Topic name to use"); |
begin |
-- Create configuration |
Config := Kafka.Config.Create; |
-- Configure |
-- see librdkafka documentation on how to configure your Kafka consumer |
-- Kafka-Ada does not add any configuration entries of its own |
Kafka.Config.Set(Config, "group.id", GNAT.Sockets.Host_name); |
Kafka.Config.Set(Config, "bootstrap.servers", "localhost:9092"); |
Kafka.Config.Set(Config, "auto.offset.reset", "earliest"); |
Handle := Kafka.Create_Handle(Kafka.RD_KAFKA_CONSUMER, Config); |
Kafka.Consumer.Poll_Set_Consumer(Handle); |
declare |
Partition_List : Kafka.Partition_List_Type; |
begin |
Partition_List := Kafka.Topic.Partition.Create_List(1); |
Kafka.Topic.Partition.List_Add(Partition_List, |
KafkaTopic.Parse_Command_Line("test_topic"), Kafka.RD_KAFKA_PARTITION_UA); |
Kafka.Subscribe(Handle, Partition_List); |
Kafka.Topic.Partition.Destroy_List(Partition_List); |
Function Definition: procedure Stemwords is |
Function Body: use Stemmer.Factory; |
function Get_Language (Name : in String) return Language_Type; |
function Is_Space (C : in Character) return Boolean; |
function Is_Space (C : in Character) return Boolean is |
begin |
return C = ' ' or C = ASCII.HT; |
end Is_Space; |
function Get_Language (Name : in String) return Language_Type is |
begin |
return Language_Type'Value ("L_" & Name); |
exception |
when Constraint_Error => |
Ada.Text_IO.Put_Line ("Unsupported language: " & Ada.Command_Line.Argument (1)); |
return L_ENGLISH; |
end Get_Language; |
Count : constant Natural := Ada.Command_Line.Argument_Count; |
begin |
if Count <= 1 then |
Ada.Text_IO.Put_Line ("Usage: stemwords language file"); |
return; |
end if; |
declare |
Lang : constant Language_Type := Get_Language (Ada.Command_Line.Argument (1)); |
Path : constant String := Ada.Command_Line.Argument (2); |
File : Ada.Text_IO.File_Type; |
begin |
Ada.Text_IO.Open (File, Ada.Text_IO.In_File, Path); |
while not Ada.Text_IO.End_Of_File (File) loop |
declare |
Line : constant String := Ada.Text_IO.Get_Line (File); |
Pos : Positive := Line'First; |
Last_Pos : Positive; |
Start_Pos : Positive; |
begin |
while Pos <= Line'Last loop |
Last_Pos := Pos; |
while Pos <= Line'Last and then Is_Space (Line (Pos)) loop |
Pos := Pos + 1; |
end loop; |
if Last_Pos < Pos then |
Ada.Text_IO.Put (Line (Last_Pos .. Pos - 1)); |
end if; |
exit when Pos > Line'Last; |
Start_Pos := Pos; |
while Pos <= Line'Last and then not Is_Space (Line (Pos)) loop |
Pos := Pos + 1; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.