Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Packed Producing Python Programs, #1008 #1067

Merged
merged 10 commits into from
Dec 22, 2024
54 changes: 54 additions & 0 deletions .github/workflows/Lucene-Net-Util-Packed-Python-Scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

name: 'Lucene.Net.Util.Packed Python Scripts'

# This will:
# checkout this repo
# run the python scripts in the src/Lucene.Net/Util/Packed folder
# check for any pending git changes

on:
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/Lucene-Net-Packed-Python-Scripts.yml'
- 'src/Lucene.Net/Util/Packed/*.py'
- 'src/Lucene.Net/Util/Packed/BulkOperation*.cs'
- 'src/Lucene.Net/Util/Packed/Direct*.cs'
- 'src/Lucene.Net/Util/Packed/Packed*.cs'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Lucene.Net source
uses: actions/checkout@v3

- name: Execute Python scripts
working-directory: src/Lucene.Net/Util/Packed
run: |
python3 ./gen_BulkOperation.py
python3 ./gen_Direct.py
python3 ./gen_Packed64SingleBlock.py
python3 ./gen_PackedThreeBlocks.py
shell: bash

- name: Check for changes
run: |
git diff --exit-code
shell: bash
16 changes: 12 additions & 4 deletions src/Lucene.Net/Util/Packed/BulkOperation.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
using Lucene.Net.Diagnostics;
using Lucene.Net.Diagnostics;
using System;

// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -121,7 +128,7 @@ internal abstract class BulkOperation : PackedInt32s.IDecoder, PackedInt32s.IEnc
new BulkOperationPacked(61),
new BulkOperationPacked(62),
new BulkOperationPacked(63),
new BulkOperationPacked(64)
new BulkOperationPacked(64),
};

// NOTE: this is sparse (some entries are null):
Expand Down Expand Up @@ -157,9 +164,10 @@ internal abstract class BulkOperation : PackedInt32s.IDecoder, PackedInt32s.IEnc
null,
null,
null,
new BulkOperationPackedSingleBlock(32)
new BulkOperationPackedSingleBlock(32),
};


public static BulkOperation Of(PackedInt32s.Format format, int bitsPerValue)
{
if (format == PackedInt32s.Format.PACKED)
Expand Down
16 changes: 11 additions & 5 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -45,7 +52,7 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
{
for (int j = 0; j < iterations; ++j)
{
var block = blocks[blocksOffset++];
byte block = blocks[blocksOffset++];
values[valuesOffset++] = (block >>> 7) & 1;
values[valuesOffset++] = (block >>> 6) & 1;
values[valuesOffset++] = (block >>> 5) & 1;
Expand All @@ -56,15 +63,14 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = block & 1;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
{
long block = blocks[blocksOffset++];
for (int shift = 63; shift >= 0; shift -= 1)
{
values[valuesOffset++] = ((block >>> shift)) & 1;
values[valuesOffset++] = (block >>> shift) & 1;
}
}
}
Expand All @@ -73,7 +79,7 @@ public override void Decode(byte[] blocks, int blocksOffset, long[] values, int
{
for (int j = 0; j < iterations; ++j)
{
var block = blocks[blocksOffset++];
byte block = blocks[blocksOffset++];
values[valuesOffset++] = (block >>> 7) & 1;
values[valuesOffset++] = (block >>> 6) & 1;
values[valuesOffset++] = (block >>> 5) & 1;
Expand Down
12 changes: 9 additions & 3 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked10.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -88,13 +95,12 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = ((byte3 & 3) << 8) | byte4;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
{
long block0 = blocks[blocksOffset++];
values[valuesOffset++] = (block0 >>> 54);
values[valuesOffset++] = block0 >>> 54;
values[valuesOffset++] = (block0 >>> 44) & 1023L;
values[valuesOffset++] = (block0 >>> 34) & 1023L;
values[valuesOffset++] = (block0 >>> 24) & 1023L;
Expand Down
10 changes: 8 additions & 2 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked11.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -136,7 +143,6 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = ((byte9 & 7) << 8) | byte10;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
Expand Down
10 changes: 8 additions & 2 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked12.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -66,7 +73,6 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = ((byte1 & 15) << 8) | byte2;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
Expand Down
10 changes: 8 additions & 2 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked13.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -140,7 +147,6 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = ((byte11 & 31) << 8) | byte12;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
Expand Down
10 changes: 8 additions & 2 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked14.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -92,7 +99,6 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = ((byte5 & 63) << 8) | byte6;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
Expand Down
10 changes: 8 additions & 2 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked15.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -144,7 +151,6 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = ((byte13 & 127) << 8) | byte14;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
Expand Down
10 changes: 8 additions & 2 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked16.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -48,7 +55,6 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = ((blocks[blocksOffset++] & 0xFF) << 8) | (blocks[blocksOffset++] & 0xFF);
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
Expand Down
10 changes: 8 additions & 2 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked17.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -148,7 +155,6 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = ((byte14 & 1) << 16) | (byte15 << 8) | byte16;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
Expand Down
10 changes: 8 additions & 2 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked18.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -96,7 +103,6 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = ((byte6 & 3) << 16) | (byte7 << 8) | byte8;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
Expand Down
10 changes: 8 additions & 2 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked19.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -152,7 +159,6 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
values[valuesOffset++] = ((byte16 & 7) << 16) | (byte17 << 8) | byte18;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
Expand Down
14 changes: 10 additions & 4 deletions src/Lucene.Net/Util/Packed/BulkOperationPacked2.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// this file has been automatically generated, DO NOT EDIT
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the gen_BulkOperation.py script.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Lucene.Net.Util.Packed
{
Expand Down Expand Up @@ -45,14 +52,13 @@ public override void Decode(byte[] blocks, int blocksOffset, int[] values, int v
{
for (int j = 0; j < iterations; ++j)
{
var block = blocks[blocksOffset++];
byte block = blocks[blocksOffset++];
values[valuesOffset++] = (block >>> 6) & 3;
values[valuesOffset++] = (block >>> 4) & 3;
values[valuesOffset++] = (block >>> 2) & 3;
values[valuesOffset++] = block & 3;
}
}

public override void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
{
for (int i = 0; i < iterations; ++i)
Expand All @@ -69,7 +75,7 @@ public override void Decode(byte[] blocks, int blocksOffset, long[] values, int
{
for (int j = 0; j < iterations; ++j)
{
var block = blocks[blocksOffset++];
byte block = blocks[blocksOffset++];
values[valuesOffset++] = (block >>> 6) & 3;
values[valuesOffset++] = (block >>> 4) & 3;
values[valuesOffset++] = (block >>> 2) & 3;
Expand Down
Loading
Loading