问:
Angular2: Component declared in shared module not usable in App module
I have two shared modules Core and MasterData.

I am facing issue to use MasterData module's components in my applcation though i can use Core Module's Components. Following is my code.

Core Module (core.module.ts)

```<code>import { NgModule, ModuleWithProviders, ComponentFactoryResolver } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import {
    IgHierarchicalGridComponent,
    IgPivotGridComponent,
    IgGridComponent
} from 'igniteui-angular2';

import { CacheModule } from 'angular2-cache';
import { AUTH_PROVIDERS } from 'angular2-jwt';

import { CoreComponents, EntryCoreComponents } from './components';
import { CoreService } from './services';

import { ClientInfoServiceProvider } from './client-info';

import { AuthGuard } from './guards/auth.guard';

const IgniteuiComponents = [
    IgHierarchicalGridComponent,
    IgPivotGridComponent,
    IgGridComponent
];

@NgModule({
    declarations: [
        ...CoreComponents,
        ...IgniteuiComponents
    ],
    providers: [
        ...CoreService,
        AUTH_PROVIDERS,
        AuthGuard,
        ClientInfoServiceProvider
    ],
    imports: [
        CommonModule,
        FormsModule,
        RouterModule,
        HttpModule,
        CacheModule,
    ],
    entryComponents: [
        ...EntryCoreComponents
    ],
    exports: [
        HttpModule,
        CacheModule,
        RouterModule,
        FormsModule,
        ...CoreComponents,
        ...IgniteuiComponents
    ]
})
export class CoreModule {
    static forRoot(): ModuleWithProviders {
        return {
            ngModule: QmsCoreModule,
            providers: [
                ...CoreService,
                AUTH_PROVIDERS,
                AuthGuard,
                ClientInfoServiceProvider
            ]
        };
    }
}
</code>```

Master Data Module (which is inheriting Core because I use infragistics library in core and masterdata components) (masterdata.module.ts)

```<code>import { NgModule, ModuleWithProviders, ComponentFactoryResolver } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { QmsCoreModule } from 'qms/core/qms-core.module';

import { MasterdataComponents } from './components';
import { MasterdataServices } from './services';

@NgModule({
    imports: [
        CommonModule,
        FormsModule,
        RouterModule,
        HttpModule,
        QmsCoreModule.forRoot()
    ],
    declarations: [
        ...MasterdataComponents
    ],
    providers: [
        ...MasterdataServices
    ],
    exports: [
        FormsModule,
        RouterModule,
        HttpModule,
        QmsCoreModule,
        ...MasterdataComponents
    ]
})
export class QmsMasterdataModule {
    static forRoot(): ModuleWithProviders {
        return {
            ngModule: QmsMasterdataModule,
            providers: [
                ...MasterdataServices
            ]
        };
    }
}
</code>```

Master data Module has currently only one component name TeamGrid. (Component Selector is ‘team-grid’)

Main Application AppModule (app.module.ts)

```<code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Provider } from '@angular/core';
import { QmsMasterdataModule } from 'qms/masterdata/qms-masterdata.module';
import { SwacProxyInterface } from 'qms/core/swac';

import { AppRoutingModule } from './app-routing.module';
import { HomeModule } from './home/home.module';
import { ProjectModule } from './project/project.module';

import { AppComponent } from './app.component';

import { SharedServices } from './shared/services';

export const AppModule = (proxyInterface: SwacProxyInterface, provider: Provider[]) => {

  @NgModule({
    declarations: [
      AppComponent
    ],
    imports: [
      BrowserModule,
      AppRoutingModule,
      HomeModule,
      ProjectModule,
      QmsMasterdataModule.forRoot()
    ],
    providers: [
      SharedServices,
      ...provider
    ],
    bootstrap: [AppComponent]
  })

  class AppModule {
  }

  return AppModule;
};
</code>```

Error message is:

'team-grid' is not a known element:
  1. If 'team-grid' is an Angular component, then verify that it is part of this module.
  2. If 'team-grid' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
  ("

```<code>    [ERROR ->]<team-grid></team-grid>
</code>```

Can someone help me to find the correct solution for this?

答:
This might help you to find out root cause

shared.module.ts

```<code>import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';

import { HttpModule } from '@angular/http';

import { QmsMasterdataModule } from 'qms/masterdata/qms-masterdata.module';

@NgModule({
  declarations: [

  ],
  imports: [
    CoreModule,
    QmsMasterdataModule
  ],
  exports: [
    CoreModule,
    QmsMasterdataModule
  ]
})

export class SharedModule {
}
</code>```

App Module

```<code>import {SharedModule} from './modules/shared/shared.module';
export const AppModule = (proxyInterface: SwacProxyInterface, provider: Provider[]) => {

  @NgModule({
    declarations: [
      AppComponent
    ],
    imports: [
     SharedModule
    ],
    providers: [
    ],
    bootstrap: [AppComponent]
  })

  class AppModule {
  }

  return AppModule;
};
</code>```

Body:
I have two shared modules Core and MasterData.

I am facing issue to use MasterData module's components in my applcation though i can use Core Module's Components. Following is my code.

Core Module (core.module.ts)

import { NgModule, ModuleWithProviders, ComponentFactoryResolver } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import {
    IgHierarchicalGridComponent,
    IgPivotGridComponent,
    IgGridComponent
} from 'igniteui-angular2';

import { CacheModule } from 'angular2-cache';
import { AUTH_PROVIDERS } from 'angular2-jwt';

import { CoreComponents, EntryCoreComponents } from './components';
import { CoreService } from './services';

import { ClientInfoServiceProvider } from './client-info';

import { AuthGuard } from './guards/auth.guard';

const IgniteuiComponents = [
    IgHierarchicalGridComponent,
    IgPivotGridComponent,
    IgGridComponent
];

@NgModule({
    declarations: [
        ...CoreComponents,
        ...IgniteuiComponents
    ],
    providers: [
        ...CoreService,
        AUTH_PROVIDERS,
        AuthGuard,
        ClientInfoServiceProvider
    ],
    imports: [
        CommonModule,
        FormsModule,
        RouterModule,
        HttpModule,
        CacheModule,
    ],
    entryComponents: [
        ...EntryCoreComponents
    ],
    exports: [
        HttpModule,
        CacheModule,
        RouterModule,
        FormsModule,
        ...CoreComponents,
        ...IgniteuiComponents
    ]
})
export class CoreModule {
    static forRoot(): ModuleWithProviders {
        return {
            ngModule: QmsCoreModule,
            providers: [
                ...CoreService,
                AUTH_PROVIDERS,
                AuthGuard,
                ClientInfoServiceProvider
            ]
        };
    }
}

Master Data Module (which is inheriting Core because I use infragistics library in core and masterdata components) (masterdata.module.ts)

import { NgModule, ModuleWithProviders, ComponentFactoryResolver } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { QmsCoreModule } from 'qms/core/qms-core.module';

import { MasterdataComponents } from './components';
import { MasterdataServices } from './services';

@NgModule({
    imports: [
        CommonModule,
        FormsModule,
        RouterModule,
        HttpModule,
        QmsCoreModule.forRoot()
    ],
    declarations: [
        ...MasterdataComponents
    ],
    providers: [
        ...MasterdataServices
    ],
    exports: [
        FormsModule,
        RouterModule,
        HttpModule,
        QmsCoreModule,
        ...MasterdataComponents
    ]
})
export class QmsMasterdataModule {
    static forRoot(): ModuleWithProviders {
        return {
            ngModule: QmsMasterdataModule,
            providers: [
                ...MasterdataServices
            ]
        };
    }
}

Master data Module has currently only one component name TeamGrid. (Component Selector is ‘team-grid’)

Main Application AppModule (app.module.ts)

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Provider } from '@angular/core';
import { QmsMasterdataModule } from 'qms/masterdata/qms-masterdata.module';
import { SwacProxyInterface } from 'qms/core/swac';

import { AppRoutingModule } from './app-routing.module';
import { HomeModule } from './home/home.module';
import { ProjectModule } from './project/project.module';

import { AppComponent } from './app.component';

import { SharedServices } from './shared/services';

export const AppModule = (proxyInterface: SwacProxyInterface, provider: Provider[]) => {

  @NgModule({
    declarations: [
      AppComponent
    ],
    imports: [
      BrowserModule,
      AppRoutingModule,
      HomeModule,
      ProjectModule,
      QmsMasterdataModule.forRoot()
    ],
    providers: [
      SharedServices,
      ...provider
    ],
    bootstrap: [AppComponent]
  })

  class AppModule {
  }

  return AppModule;
};

Error message is:

'team-grid' is not a known element:
  1. If 'team-grid' is an Angular component, then verify that it is part of this module.
  2. If 'team-grid' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
  ("

    [ERROR ->]<team-grid></team-grid>

Can someone help me to find the correct solution for this?

Body:
This might help you to find out root cause

shared.module.ts

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';

import { HttpModule } from '@angular/http';

import { QmsMasterdataModule } from 'qms/masterdata/qms-masterdata.module';

@NgModule({
  declarations: [

  ],
  imports: [
    CoreModule,
    QmsMasterdataModule
  ],
  exports: [
    CoreModule,
    QmsMasterdataModule
  ]
})

export class SharedModule {
}

App Module

import {SharedModule} from './modules/shared/shared.module';
export const AppModule = (proxyInterface: SwacProxyInterface, provider: Provider[]) => {

  @NgModule({
    declarations: [
      AppComponent
    ],
    imports: [
     SharedModule
    ],
    providers: [
    ],
    bootstrap: [AppComponent]
  })

  class AppModule {
  }

  return AppModule;
};


来源: stackexchange

问:
How to copy only the commit messages of Android Studio from log of Version Control

When i block and copy those logs, it will copy the hash, committer, and time too.
For example:

```<code>7e15726 hendrawd on 11/13/16 at 10:18 PM Merge remote-tracking branch 'origin/master'
a464db8 hendrawd on 11/13/16 at 10:16 PM fix ignored files
094ef35 Hendra Wijaya Djiono on 11/10/16 at 4:59 PM Swipe refresh will refresh notification count too
4759306 Hendra Wijaya Djiono on 11/10/16 at 12:51 PM Restructure
33ad61b Hendra Wijaya Djiono on 11/10/16 at 12:46 PM Fix force closed when crop picture on create group
8763667 Hendra Wijaya Djiono on 11/9/16 at 7:02 PM Fix duplicate notification
</code>```

I don't remember when it was implemented, maybe in Android Studio 2.2. It used to be just copy commit messages.

So how i can get only commit messages? Because i just need that instead of the full detail and it is very inconvenience to edit the lines one by one to just get the commit messages.

My Android Studio version is:

```<code>Android Studio 2.3
Build #AI-162.3764568, built on February 24, 2017
JRE: 1.8.0_112-release-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
</code>```

答:
I don't know what version of idea you use. According to my test on my latest IDEA and WebStorm. I select in log tab of Version Control and copy and paste in Atom, I will get the commit message + name + time.

such as:

```<code>test message Xin Meng 31/03/17 11:10
Merge branch 'feature' into develop Xin Meng 31/03/17 10:19
kotlinc Xin Meng 31/03/17 10:19
</code>```

if the output is above, you can use Atom(or other editor support Regex) to filter the other part.

Such as on Atom:

Ctrl+F and click .* in the Finding panel to enable Regex. And then put Xin Meng.* in the Finding input and replace with blank. Then click the Replace All.

Then all commit messages will be kept and the other things will be replaced with the blank.

ContentLicense: CC BY-SA 3.0

Body:
When i block and copy those logs, it will copy the hash, committer, and time too.
For example:

7e15726 hendrawd on 11/13/16 at 10:18 PM Merge remote-tracking branch 'origin/master'
a464db8 hendrawd on 11/13/16 at 10:16 PM fix ignored files
094ef35 Hendra Wijaya Djiono on 11/10/16 at 4:59 PM Swipe refresh will refresh notification count too
4759306 Hendra Wijaya Djiono on 11/10/16 at 12:51 PM Restructure
33ad61b Hendra Wijaya Djiono on 11/10/16 at 12:46 PM Fix force closed when crop picture on create group
8763667 Hendra Wijaya Djiono on 11/9/16 at 7:02 PM Fix duplicate notification

I don't remember when it was implemented, maybe in Android Studio 2.2. It used to be just copy commit messages.

So how i can get only commit messages? Because i just need that instead of the full detail and it is very inconvenience to edit the lines one by one to just get the commit messages.

My Android Studio version is:

Android Studio 2.3
Build #AI-162.3764568, built on February 24, 2017
JRE: 1.8.0_112-release-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Body:
I don't know what version of idea you use. According to my test on my latest IDEA and WebStorm. I select in log tab of Version Control and copy and paste in Atom, I will get the commit message + name + time.

such as:

test message Xin Meng 31/03/17 11:10
Merge branch 'feature' into develop Xin Meng 31/03/17 10:19
kotlinc Xin Meng 31/03/17 10:19

if the output is above, you can use Atom(or other editor support Regex) to filter the other part.

Such as on Atom:

Ctrl+F and click .* in the Finding panel to enable Regex. And then put Xin Meng.* in the Finding input and replace with blank. Then click the Replace All.

Then all commit messages will be kept and the other things will be replaced with the blank.


问:
How to identify Background steps on Specflow?
I know is possible to get steps information from specflow by using  ScenarioStepContext.Current.StepInfo but this doesn't return if the step is inside the Background block or not.

Is there a way to find out if the Step inside the Background or the Scenario/Scenario Outline?

Thanks!

答:
Currently there is no way to get this information in the StepInfo.

But there is a possible (but little hacky) way to get this information. You have to look at the StackTrace and search there for an method named FeatureBackground(). This is the method in the generated code, that comes from the background.

This code will do the job:

```<code>var stackTrace = new System.Diagnostics.StackTrace();
var stackFrames = stackTrace.GetFrames();
bool isBackground = stackFrames.Where(x => x.GetMethod().Name == "FeatureBackground").Any();
</code>```

Body:
Currently there is no way to get this information in the StepInfo.

But there is a possible (but little hacky) way to get this information. You have to look at the StackTrace and search there for an method named FeatureBackground(). This is the method in the generated code, that comes from the background.

This code will do the job:

var stackTrace = new System.Diagnostics.StackTrace();
var stackFrames = stackTrace.GetFrames();
bool isBackground = stackFrames.Where(x => x.GetMethod().Name == "FeatureBackground").Any();


问:
Flash Builder 4 How to create a add button to add instance of textbox and combobox?
I have tried to work on a simple form with Flash Builder 4, but was stuck in creating the dynamic addition of the instance for a textbox and combobox within a Hbox.

I have created an HBox component with a textbox and a combo box. I then create a button Add new Row, to add a new row of Hbox on the runtime.

May I know how can I create the add to make it able to add new hbox component on clicking of the button, such that when i click the hbox 3 times, I should have 3 rows of the component instance and the button is still at the bottom of these components?

Thanks.

答:
Take a look on the code:

```<code><mx:Script>
    <![CDATA[
        protected function button1_clickHandler(event:MouseEvent):void{
            var textInput:TextInput = newTextInput();
            vbox.addChildAt(textInput,0);
        }
    ]]>
</mx:Script>
<mx:VBox id="vbox">
    <mx:Button click="button1_clickHandler(event)" label="Click"/>
</mx:VBox>
</code>```

I'm creating a simple text field, and not a custom component as in your case, however I think you can get the idea. I also recommend isolating your mxml component (hbox+childrens) in a different file, for better clarity.

ContentLicense: CC BY-SA 2.5

Body:
Take a look on the code:

<mx:Script>
    <![CDATA[
        protected function button1_clickHandler(event:MouseEvent):void{
            var textInput:TextInput = newTextInput();
            vbox.addChildAt(textInput,0);
        }
    ]]>
</mx:Script>
<mx:VBox id="vbox">
    <mx:Button click="button1_clickHandler(event)" label="Click"/>
</mx:VBox>

I'm creating a simple text field, and not a custom component as in your case, however I think you can get the idea. I also recommend isolating your mxml component (hbox+childrens) in a different file, for better clarity.


问:
deleting information in my table
Hello I've got my code I just want to delete an specific row but it will delete all when I run my program..?</p>

```<code> <html>
 <body>
 <?php
 $servername = "localhost";
 $username = "root";
 $password = "";
 $dbname = "csedb";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

// sql to delete a record
$sql = "DELETE FROM addform WHERE id_stu=$id_stu";

if (mysqli_query($conn, $sql)) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error($conn);
}
if($sql)
{
header('location:student.php');
}
mysqli_close($conn);
?>
</body>
</html>
</code>```

答:
give the value to where clause like

```<code>$sql = "DELETE FROM addform WHERE id_stu=<id_or_value>";
</code>```

hope it helps

Title: deleting information in my table

Body:
Hello I've got my code I just want to delete an specific row but it will delete all when I run my program..?

 <?php
 $servername = "localhost";
 $username = "root";
 $password = "";
 $dbname = "csedb";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

// sql to delete a record
$sql = "DELETE FROM addform WHERE id_stu=$id_stu";

if (mysqli_query($conn, $sql)) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error($conn);
}
if($sql)
{
header('location:student.php');
}
mysqli_close($conn);
?>

Body:
give the value to where clause like

$sql = "DELETE FROM addform WHERE id_stu=<id_or_value>";

hope it helps


问:
How do I save a bitmap as a 16-color grayscale GIF or PNG in ASP.NET?
In ASP.NET C# I'm trying to save a bitmap image as an 16-color non-transparent grayscale image as either a PNG or GIF. I assume I have to create a palette and then somehow attach the palette to the image but not sure how to go about doing this.

The source image is a 24-bit color Bitmap.

答:
This is actually not hard at all, once you got the toolsets, and I built up quite a few of those. The things you need are:

A 16-color grayscale palette.

A function to match image data to the nearest color (to get paletted data)

A function to convert these matches to 4-bit data (half a byte per value)

A way to write that data into a new 4-bit image object.

The palette is easy. Gray values are colors with the same value for red, green and blue, and for equal brightness steps between colours on 16 colour, that value is just the range from 0x00, 0x11, 0x22 etc up to 0xFF. Shouldn't be hard to make.

The next step is matching the image colours to the palette colours, and making a byte array of these values. There are several methods for getting the closest match available on stackoverflow already. This question has a bunch of them:

How to compare Color object and get closest Color in an Color[]?

Next comes the tricky part: converting the actual image data to 4-bit.

One thing to keep in mind is that images are saved per line, and such a line (called a "scanline") isn't necessarily the same width as the image. For example, in 4 bits per pixel, you can fit 2 pixels in each byte, so logically, the stride is width divided by 2. However, if the width is an uneven number, each line will have a byte at the end that is only half-filled. The systems do not put the first pixel of the next line in there; instead it's simply left blank. And for 8-bit or even 16-bit images I know the stride often aligns the scanlines to multiple of 4 bytes. So never assume the width is the same as the scanline length.

For the function I put further down in this reply I use the minimum needed scanline length. Since this is just the width times times the bits length divided by eight, plus one if there was a remainder in that division, it can easily be calculated as ((bpp * width) + 7) / 8.

Now, if you generated your greyscale palette, and then made a byte array containing the nearest palette value for each pixel on the image, you have all values to feed to the actual 8-bit to 4-bit conversion function.

I wrote a function to convert 8-bit data to any given bits length. So this would need bitsLength=4 for your 4-bit image.

The BigEndian parameter will determine whether the values inside one byte are switched or not. I'm not sure about .Net images here, but I know a lot of 1BPP formats use big-endian bits, while I've encountered 4BPP formats that started with the lowest nibble instead.

```<code>    /// <summary>
    /// Converts given raw image data for a paletted 8-bit image to lower amount of bits per pixel.
    /// </summary>
    /// <param name="data8bit">The eight bit per pixel image data</param>
    /// <param name="width">The width of the image</param>
    /// <param name="height">The height of the image</param>
    /// <param name="newBpp">The new amount of bits per pixel</param>
    /// <param name="stride">Stride used in the original image data. Will be adjusted to the new stride value.</param>
    /// <param name="bigEndian">Values inside a single byte are read from the largest to the smallest bit.</param>
    /// <returns>The image data converted to the requested amount of bits per pixel.</returns>
private static Byte[] ConvertFrom8Bit(Byte[] data8bit, Int32 width, Int32 height, Int32 bitsLength, Boolean bigEndian)
    {
        if (newBpp > 8)
            throw new ArgumentException("Cannot convert to bit format greater than 8!", "newBpp");
        if (stride < width)
            throw new ArgumentException("Stride is too small for the given width!", "stride");
        if (data8bit.Length < stride * height)
            throw new ArgumentException("Data given data is too small to contain an 8-bit image of the given dimensions", "data8bit");
    Int32 parts = 8 / bitsLength;
    // Amount of bytes to write per width
    Int32 stride = ((bpp * width) + 7) / 8;
    // Bit mask for reducing original data to actual bits maximum.
    // Should not be needed if data is correct, but eh.
    Int32 bitmask = (1 << bitsLength) - 1;
    Byte[] dataXbit = new Byte[stride * height];
    // Actual conversion porcess.
    for (Int32 y = 0; y < height; y++)
    {
        for (Int32 x = 0; x < width; x++)
        {
            // This will hit the same byte multiple times
            Int32 indexXbit = y * stride + x / parts;
            // This will always get a new index
            Int32 index8bit = y * width + x;
            // Amount of bits to shift the data to get to the current pixel data
            Int32 shift = (x % parts) * bitsLength;
            // Reversed for big-endian
            if (bigEndian)
                shift = 8 - shift - bitsLength;
            // Get data, reduce to bit rate, shift it and store it.
            dataXbit[indexXbit] |= (Byte)((data8bit[index8bit] & bitmask) << shift);
        }
    }
    return dataXbit;
}
</code>```

The next step is to make an image of the correct dimensions and pixel format, open its backing array in memory, and dump your data into it. The pixel format for a 16 colour image is PixelFormat.Format4bppIndexed.

```<code>    /// <summary>
    /// Creates a bitmap based on data, width, height, stride and pixel format.
    /// </summary>
    /// <param name="sourceData">Byte array of raw source data.</param>
    /// <param name="width">Width of the image.</param>
    /// <param name="height">Height of the image.</param>
    /// <param name="stride">Scanline length inside the data.</param>
    /// <param name="pixelFormat">Pixel format.</param>
    /// <param name="palette">Color palette.</param>
    /// <param name="defaultColor">Default color to fill in on the palette if the given colors don't fully fill it.</param>
    /// <returns>The new image.</returns>
    public static Bitmap BuildImage(Byte[] sourceData, Int32 width, Int32 height, Int32 stride, PixelFormat pixelFormat, Color[] palette, Color? defaultColor)
    {
        Bitmap newImage = new Bitmap(width, height, pixelFormat);
        BitmapData targetData = newImage.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, newImage.PixelFormat);
        Int32 newDataWidth = ((Image.GetPixelFormatSize(pixelFormat) * width) + 7) / 8;
        Int32 targetStride = targetData.Stride;
        Int64 scan0 = targetData.Scan0.ToInt64();
        for (Int32 y = 0; y < height; ++y)
            Marshal.Copy(sourceData, y * stride, new IntPtr(scan0 + y * targetStride), newDataWidth);
        newImage.UnlockBits(targetData);
        // For indexed images, set the palette.
        if ((pixelFormat & PixelFormat.Indexed) != 0 && (palette != null || defaultColor.HasValue))
        {
            if (palette == null)
                palette = new Color[0];
            ColorPalette pal = newImage.Palette;
            Int32 palLen = pal.Entries.Length;
            Int32 paletteLength = palette.Length;
            for (Int32 i = 0; i < palLen; ++i)
            {
                if (i < paletteLength)
                    pal.Entries[i] = palette[i];
                else if (defaultColor.HasValue)
                    pal.Entries[i] = defaultColor.Value;
                else
                    break;
            }
            // Palette property getter creates a copy, so the newly filled in palette
            // is not actually referenced in the image until you set it again explicitly.
            newImage.Palette = pal;
        }
        return newImage;
    }
</code>```

Body:
This is actually not hard at all, once you got the toolsets, and I built up quite a few of those. The things you need are:

A 16-color grayscale palette.

A function to match image data to the nearest color (to get paletted data)

A function to convert these matches to 4-bit data (half a byte per value)

A way to write that data into a new 4-bit image object.

The palette is easy. Gray values are colors with the same value for red, green and blue, and for equal brightness steps between colours on 16 colour, that value is just the range from 0x00, 0x11, 0x22 etc up to 0xFF. Shouldn't be hard to make.

The next step is matching the image colours to the palette colours, and making a byte array of these values. There are several methods for getting the closest match available on stackoverflow already. This question has a bunch of them:

How to compare Color object and get closest Color in an Color[]?

Next comes the tricky part: converting the actual image data to 4-bit.

One thing to keep in mind is that images are saved per line, and such a line (called a "scanline") isn't necessarily the same width as the image. For example, in 4 bits per pixel, you can fit 2 pixels in each byte, so logically, the stride is width divided by 2. However, if the width is an uneven number, each line will have a byte at the end that is only half-filled. The systems do not put the first pixel of the next line in there; instead it's simply left blank. And for 8-bit or even 16-bit images I know the stride often aligns the scanlines to multiple of 4 bytes. So never assume the width is the same as the scanline length.

For the function I put further down in this reply I use the minimum needed scanline length. Since this is just the width times times the bits length divided by eight, plus one if there was a remainder in that division, it can easily be calculated as ((bpp * width) + 7) / 8.

Now, if you generated your greyscale palette, and then made a byte array containing the nearest palette value for each pixel on the image, you have all values to feed to the actual 8-bit to 4-bit conversion function.

I wrote a function to convert 8-bit data to any given bits length. So this would need bitsLength=4 for your 4-bit image.

The BigEndian parameter will determine whether the values inside one byte are switched or not. I'm not sure about .Net images here, but I know a lot of 1BPP formats use big-endian bits, while I've encountered 4BPP formats that started with the lowest nibble instead.

    /// <summary>
    /// Converts given raw image data for a paletted 8-bit image to lower amount of bits per pixel.
    /// </summary>
    /// <param name="data8bit">The eight bit per pixel image data</param>
    /// <param name="width">The width of the image</param>
    /// <param name="height">The height of the image</param>
    /// <param name="newBpp">The new amount of bits per pixel</param>
    /// <param name="stride">Stride used in the original image data. Will be adjusted to the new stride value.</param>
    /// <param name="bigEndian">Values inside a single byte are read from the largest to the smallest bit.</param>
    /// <returns>The image data converted to the requested amount of bits per pixel.</returns>
private static Byte[] ConvertFrom8Bit(Byte[] data8bit, Int32 width, Int32 height, Int32 bitsLength, Boolean bigEndian)
    {
        if (newBpp > 8)
            throw new ArgumentException("Cannot convert to bit format greater than 8!", "newBpp");
        if (stride < width)
            throw new ArgumentException("Stride is too small for the given width!", "stride");
        if (data8bit.Length < stride * height)
            throw new ArgumentException("Data given data is too small to contain an 8-bit image of the given dimensions", "data8bit");
    Int32 parts = 8 / bitsLength;
    // Amount of bytes to write per width
    Int32 stride = ((bpp * width) + 7) / 8;
    // Bit mask for reducing original data to actual bits maximum.
    // Should not be needed if data is correct, but eh.
    Int32 bitmask = (1 << bitsLength) - 1;
    Byte[] dataXbit = new Byte[stride * height];
    // Actual conversion porcess.
    for (Int32 y = 0; y < height; y++)
    {
        for (Int32 x = 0; x < width; x++)
        {
            // This will hit the same byte multiple times
            Int32 indexXbit = y * stride + x / parts;
            // This will always get a new index
            Int32 index8bit = y * width + x;
            // Amount of bits to shift the data to get to the current pixel data
            Int32 shift = (x % parts) * bitsLength;
            // Reversed for big-endian
            if (bigEndian)
                shift = 8 - shift - bitsLength;
            // Get data, reduce to bit rate, shift it and store it.
            dataXbit[indexXbit] |= (Byte)((data8bit[index8bit] & bitmask) << shift);
        }
    }
    return dataXbit;
}

The next step is to make an image of the correct dimensions and pixel format, open its backing array in memory, and dump your data into it. The pixel format for a 16 colour image is PixelFormat.Format4bppIndexed.

    /// <summary>
    /// Creates a bitmap based on data, width, height, stride and pixel format.
    /// </summary>
    /// <param name="sourceData">Byte array of raw source data.</param>
    /// <param name="width">Width of the image.</param>
    /// <param name="height">Height of the image.</param>
    /// <param name="stride">Scanline length inside the data.</param>
    /// <param name="pixelFormat">Pixel format.</param>
    /// <param name="palette">Color palette.</param>
    /// <param name="defaultColor">Default color to fill in on the palette if the given colors don't fully fill it.</param>
    /// <returns>The new image.</returns>
    public static Bitmap BuildImage(Byte[] sourceData, Int32 width, Int32 height, Int32 stride, PixelFormat pixelFormat, Color[] palette, Color? defaultColor)
    {
        Bitmap newImage = new Bitmap(width, height, pixelFormat);
        BitmapData targetData = newImage.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, newImage.PixelFormat);
        Int32 newDataWidth = ((Image.GetPixelFormatSize(pixelFormat) * width) + 7) / 8;
        Int32 targetStride = targetData.Stride;
        Int64 scan0 = targetData.Scan0.ToInt64();
        for (Int32 y = 0; y < height; ++y)
            Marshal.Copy(sourceData, y * stride, new IntPtr(scan0 + y * targetStride), newDataWidth);
        newImage.UnlockBits(targetData);
        // For indexed images, set the palette.
        if ((pixelFormat & PixelFormat.Indexed) != 0 && (palette != null || defaultColor.HasValue))
        {
            if (palette == null)
                palette = new Color[0];
            ColorPalette pal = newImage.Palette;
            Int32 palLen = pal.Entries.Length;
            Int32 paletteLength = palette.Length;
            for (Int32 i = 0; i < palLen; ++i)
            {
                if (i < paletteLength)
                    pal.Entries[i] = palette[i];
                else if (defaultColor.HasValue)
                    pal.Entries[i] = defaultColor.Value;
                else
                    break;
            }
            // Palette property getter creates a copy, so the newly filled in palette
            // is not actually referenced in the image until you set it again explicitly.
            newImage.Palette = pal;
        }
        return newImage;
    }

ContentLicense: CC BY-SA 4.0


问:
Insert a row after a specific text - VBA
I want to insert a row in a excel spreadsheet after a specific text is found is a column. The text appears N times and the new row need to be inserted after the last time the text appears.

An example of what I have

```<code>ColumnA
TextA
TextA
TextA
TextA
TextB
TextB
TextB
TextB
TextC
TextC
TextC
TextC
</code>```

I need to insert a new row after the last time TextA, TextB and TextC appear, each time I execute the macro.

Is there a way to find the maximum number of times a given text appears in a column? In that way it will be possible to do what I want.

EDIT:

I have tried to count the number of times each text appears and assign this value to a variable:

```<code>Sub count()
Dim A As Integer
A = Application.WorksheetFunction.CountIf(Range("B:B"), "TextA")

Dim B As Integer
B = Application.WorksheetFunction.CountIf(Range("B:B"), "TextB")

Dim C As Integer
C = Application.WorksheetFunction.CountIf(Range("B:B"), "TextC")
End Sub
</code>```

After that I tried to insert a new row

```<code>Sub insert_row ()
    Rows("4+A:4+A").Select 'The number 4 is the first row `TextA` appears. So 4+A where I need to insert my new row.
    Selection.Insert Shift:=xlDown
End Sub
</code>```

With this code I have to problems

1 - A have much more than just TextA, TextB and TextC texts to find. Actually I have 30 different texts in the column.

2 - Sub insert_row () does not work.

答:
This loops through the cells and adds a row each time a cell is not equal to the cell below it and the cell is not blank. </p>

```<code> Sub Insert()
  Dim LastRow As Long
  Dim Cell As Range

Application.ScreenUpdating = False

    LastRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(-4162).Row

    For Each Cell In Sheets("Sheet1").Range("A1:A" & LastRow)
        If Cell.Value <> Cell.Offset(1, 0) Then
            If Cell.Value <> "" Then
                Sheets("Sheet1").Rows(Cell.Row + 1).Insert
            End If
        End If
    Next Cell

Application.ScreenUpdating = True

End Sub
</code>```

Body:
I want to insert a row in a excel spreadsheet after a specific text is found is a column. The text appears N times and the new row need to be inserted after the last time the text appears.

An example of what I have

ColumnA
TextA
TextA
TextA
TextA
TextB
TextB
TextB
TextB
TextC
TextC
TextC
TextC

I need to insert a new row after the last time TextA, TextB and TextC appear, each time I execute the macro.

Is there a way to find the maximum number of times a given text appears in a column? In that way it will be possible to do what I want.

EDIT:

I have tried to count the number of times each text appears and assign this value to a variable:

Sub count()
Dim A As Integer
A = Application.WorksheetFunction.CountIf(Range("B:B"), "TextA")

Dim B As Integer
B = Application.WorksheetFunction.CountIf(Range("B:B"), "TextB")

Dim C As Integer
C = Application.WorksheetFunction.CountIf(Range("B:B"), "TextC")
End Sub

After that I tried to insert a new row

Sub insert_row ()
    Rows("4+A:4+A").Select 'The number 4 is the first row `TextA` appears. So 4+A where I need to insert my new row.
    Selection.Insert Shift:=xlDown
End Sub

With this code I have to problems

1 - A have much more than just TextA, TextB and TextC texts to find. Actually I have 30 different texts in the column.

2 - Sub insert_row () does not work.

Body:
This loops through the cells and adds a row each time a cell is not equal to the cell below it and the cell is not blank.

 Sub Insert()
  Dim LastRow As Long
  Dim Cell As Range

Application.ScreenUpdating = False

    LastRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(-4162).Row

    For Each Cell In Sheets("Sheet1").Range("A1:A" & LastRow)
        If Cell.Value <> Cell.Offset(1, 0) Then
            If Cell.Value <> "" Then
                Sheets("Sheet1").Rows(Cell.Row + 1).Insert
            End If
        End If
    Next Cell

Application.ScreenUpdating = True

End Sub


问:
Equivalent of 'in' for comparing two Numpy arrays
In pure, unvectorised, Python I can use,

```<code>>>> a = 9
>>> b = [5, 7, 12]
>>> a in b
False
</code>```

I would like to do something similar for arrays in Numpy i.e.

```<code>>>> a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
>>> b = np.array([5, 7, 12])
>>> a in b
np.array([False, False, False, False, True, False, True, False, False, False])</code>```

... although this does not work.

Is there a function or method that achieves this? If not what is the easiest way to do this?

答:
You are looking for in1d:</p>

```<code>>>> import numpy as np
>>> a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
>>> b = np.array([5, 7, 12])
>>> np.in1d( a, b)
array([False, False, False, False,  True, False,  True, False, False, False], dtype=bool)
</code>```

Body:
In pure, unvectorised, Python I can use,

>>> a = 9
>>> b = [5, 7, 12]
>>> a in b
False

I would like to do something similar for arrays in Numpy i.e.

>>> a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
>>> b = np.array([5, 7, 12])
>>> a in b
np.array([False, False, False, False, True, False, True, False, False, False])

... although this does not work.

Is there a function or method that achieves this? If not what is the easiest way to do this?

Body:
You are looking for in1d:

>>> import numpy as np
>>> a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
>>> b = np.array([5, 7, 12])
>>> np.in1d( a, b)
array([False, False, False, False,  True, False,  True, False, False, False], dtype=bool)


问:
Bootstrap - changing the width of a form
I have the following code in an ember application for a .hbs template file (basically it's just a chat box for a user to enter text, with "Back" and "Send" buttons either side):

```<code><div class="row">
   <div class="chat-form text-left">
      <button class="btn btn-default" {{action "back"}}>Back</button>
      <form class="form-inline" {{action "handleMessage" on="submit"}}>
         <div class="form-group">
            <label class="sr-only">Chat Message</label>
            {{input value=chatMessage class="form-control"}}
         </div>
         <button type="submit" class="btn btn-default">Send</button>
      </form>
   </div>
</div>
</code>```

Currently the text box is too narrow and I want to make it a few times wider, I'm aware of columns and spans in bootstrap but as a complete beginner I'm not sure how to do it properly in this case.

答:
You need to utilize bootstrap grid system. I'm providing one example here.

Example Snippet

#inpt {
width: 100%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container-fluid">
    <div class="row">
       <div class="chat-form text-left col-xs-12">
<div class="col-xs-2">
          <button class="btn btn-default">Back</button>
</div>
<div class="col-xs-10">
          <form class="form-inline">
             <div class="form-group col-xs-9">
                <label class="sr-only">Chat Message</label>

                <input id="inpt" value=chatMessage class="form-control">

             </div>
<div class="col-xs-3">
             <button type="submit" class="btn btn-default">Send</button>
</div>
          </form>
</div>
       </div>
    </div>
    </div></code>```

Body:
I have the following code in an ember application for a .hbs template file (basically it's just a chat box for a user to enter text, with "Back" and "Send" buttons either side):

      <button class="btn btn-default" {{action "back"}}>Back</button>
      <form class="form-inline" {{action "handleMessage" on="submit"}}>

            Chat Message
            {{input value=chatMessage class="form-control"}}

         <button type="submit" class="btn btn-default">Send</button>
      </form>

Currently the text box is too narrow and I want to make it a few times wider, I'm aware of columns and spans in bootstrap but as a complete beginner I'm not sure how to do it properly in this case.

Body:
You need to utilize bootstrap grid system. I'm providing one example here.

Example Snippet

#inpt {
width: 100%;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container-fluid">
    <div class="row">
       <div class="chat-form text-left col-xs-12">
<div class="col-xs-2">
          <button class="btn btn-default">Back</button>
</div>
<div class="col-xs-10">
          <form class="form-inline">
             <div class="form-group col-xs-9">
                <label class="sr-only">Chat Message</label>

                <input id="inpt" value=chatMessage class="form-control">

             </div>
<div class="col-xs-3">
             <button type="submit" class="btn btn-default">Send</button>
</div>
          </form>
</div>
       </div>
    </div>
    </div>


答:
You need to provide a value for id_stu
DELETE FROM addform WHERE id_stu = your number</p>

Title: deleting information in my table


答:
You have to give a value:</p>

```<code>$sql = "DELETE FROM addform WHERE id_stu = 1";
</code>```

Title: deleting information in my table

Body:
You have to give a value:

$sql = "DELETE FROM addform WHERE id_stu = 1";


问:
Is it possible to vectorize this nested for with SSE?
I've never written assembly code for SSE optimization, so sorry if this is a noob question. In this aritcle is explained how to vectorize a for with a conditional statement. However, my code (taken from here ) is of the form:

```<code>   for (int j=-halfHeight; j<=halfHeight; ++j)
   {
      for(int i=-halfWidth; i<=halfWidth; ++i)
      {
         const float rx = ofsx + j * a12;
         const float ry = ofsy + j * a22;
         float wx = rx + i * a11;
         float wy = ry + i * a21;
         const int x = (int) floor(wx);
         const int y = (int) floor(wy);
         if (x >= 0 && y >= 0 && x < width && y < height)
         {
            // compute weights
            wx -= x; wy -= y;
            // bilinear interpolation
            *out++ =
               (1.0f - wy) * ((1.0f - wx) * im.at<float>(y,x)   + wx * im.at<float>(y,x+1)) +
               (       wy) * ((1.0f - wx) * im.at<float>(y+1,x) + wx * im.at<float>(y+1,x+1));
         } else {
            *out++ = 0;
         }
      }
   }
</code>```

So, from my understanding, there are several differences with the linked article:

Here we have a nested for: I've always seen one level for in vectroization, never seen a nested loop

The if condition is based on scalar values (x and y) and not on the array: how can I adapt the linked example to this?

The out index isn't based on i or j (so it's not out[i] or out[j]): how can I fill out in this way?

In particular I'm confused because for indexes are always used as array indexes, while here are used to compute variables while the vector is incremented cycle by cycle

I'm using icpc with -O3 -xCORE-AVX2 -qopt-report=5 and a bunch of others optimization flags. According to Intel Advisor, this is not vectorized, and using #pragma omp simd generates warning #15552: loop was not vectorized with "simd"

答:
Bilinear interpolation is a rather tricky operation to vectorize, and I wouldn't try it for your first SSE trick. The problem is that the values you need to fetch are not nicely ordered. They're sometimes repeated, sometimes skipped.  The good news is, interpolating images is a common operation, and you can likely find a pre-written library to do that, like OpenCV

remap() is always a good choice.  Just build two arrays of wx and wy which represent the fractional source locations of each pixel, and let remap() do the interpolation.

However, in this case, it looks like an affine transform.  That is, the fractional source pixel is related to the source pixel by a 2x3 matrix multiplication.  That's the offset and a11/a12/a21/a22 variables.  OpenCV has such a transform.  Read about it here: http://docs.opencv.org/3.1.0/d4/d61/tutorial_warp_affine.html

All you'll have to do is map your input variables into matrix form and call the affine transform.

Body:
I've never written assembly code for SSE optimization, so sorry if this is a noob question. In this aritcle is explained how to vectorize a for with a conditional statement. However, my code (taken from here ) is of the form:

   for (int j=-halfHeight; j<=halfHeight; ++j)
   {
      for(int i=-halfWidth; i<=halfWidth; ++i)
      {
         const float rx = ofsx + j * a12;
         const float ry = ofsy + j * a22;
         float wx = rx + i * a11;
         float wy = ry + i * a21;
         const int x = (int) floor(wx);
         const int y = (int) floor(wy);
         if (x >= 0 && y >= 0 && x < width && y < height)
         {
            // compute weights
            wx -= x; wy -= y;
            // bilinear interpolation
            *out++ =
               (1.0f - wy) * ((1.0f - wx) * im.at<float>(y,x)   + wx * im.at<float>(y,x+1)) +
               (       wy) * ((1.0f - wx) * im.at<float>(y+1,x) + wx * im.at<float>(y+1,x+1));
         } else {
            *out++ = 0;
         }
      }
   }

So, from my understanding, there are several differences with the linked article:

Here we have a nested for: I've always seen one level for in vectroization, never seen a nested loop

The if condition is based on scalar values (x and y) and not on the array: how can I adapt the linked example to this?

The out index isn't based on i or j (so it's not out[i] or out[j]): how can I fill out in this way?

In particular I'm confused because for indexes are always used as array indexes, while here are used to compute variables while the vector is incremented cycle by cycle

I'm using icpc with -O3 -xCORE-AVX2 -qopt-report=5 and a bunch of others optimization flags. According to Intel Advisor, this is not vectorized, and using #pragma omp simd generates warning #15552: loop was not vectorized with "simd"


问:
how do i debug PHP Image with print?
i want to debug an php generated image algorithm with print.
The problem is that it doesn't output the text i put in print.
How can i output variables, so that i can debug?
Thanks,
Furtano</p>

```<code> public function drawPicture()
    {
        $im = imagecolorallocate ($this->picture, 255, 0, 255);
        imagettftext($this->picture, $this->fontSize , 0, 100, 100,$im , "cooperm.TTF", $this->name);

        # int ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h )
        //imagecopy($this->picture, $this->pika, $this->wappen['pika']['dst_x'], $this->wappen['pika']['dst_y'], 0, 0, $this->pika_size[0], $this->pika_size[1]);

        $zufall = rand(1,99999999);

        #header("Content-Type: image/jpeg");
        imagepng($this->picture);

        $this->checkFontSize();

        imagedestroy($this->picture);

        print "WHY_DOESNT_PRINT?";

    }
</code>```

答:
To debug using rorrorlog the point that the script that you want to see.
The written files can be easily viewable.

Es:

```<code>error_log("\r\n debug " . implode("; ", $hc), 3, "errors.log"); // in case array
error_log("\r\n print " . $im, 3, "errors.log");
</code>```

Title: how do i debug PHP Image with print?

Body:
i want to debug an php generated image algorithm with print.
The problem is that it doesn't output the text i put in print.
How can i output variables, so that i can debug?
Thanks,
Furtano

 public function drawPicture()
    {
        $im = imagecolorallocate ($this->picture, 255, 0, 255);
        imagettftext($this->picture, $this->fontSize , 0, 100, 100,$im , "cooperm.TTF", $this->name);

        # int ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h )
        //imagecopy($this->picture, $this->pika, $this->wappen['pika']['dst_x'], $this->wappen['pika']['dst_y'], 0, 0, $this->pika_size[0], $this->pika_size[1]);

        $zufall = rand(1,99999999);

        #header("Content-Type: image/jpeg");
        imagepng($this->picture);

        $this->checkFontSize();

        imagedestroy($this->picture);

        print "WHY_DOESNT_PRINT?";

    }

Body:
To debug using rorrorlog the point that the script that you want to see.
The written files can be easily viewable.

Es:

error_log("\r\n debug " . implode("; ", $hc), 3, "errors.log"); // in case array
error_log("\r\n print " . $im, 3, "errors.log");


问:
Magento code in gitignore and need to update version
We are working on Magento2 project, versioning is done through GIT, where all vendor/lib files are put in gitignore.

As per our deployment structure, we have multiple env such as - DEV/SIT/UAT/PROD, all managed through git branches.

Now, project needs to update Magento2 version, which will involve update of native code files in vendor/lib etc.

How can this be managed so that we can push in GIT, and propagate these changes on other enviornments.

答:
You will need to use composer to manage your Magento project version if you are not committing the vendor directory to git. The devdocs go into detail on how to update Magento 2.

You won't be able to manage this solely through git if you are not committing the vendor or lib directory. You'll have to run the composer commands as part of your deployment process to the environments.

From the documentation:

To pull in the new version:

composer require magento/product-community-edition <version-number> --no-update

composer update

And run the update scripts:
php bin/magento setup:upgrade

You'll have to clear the cache and generated directories as well.


问:
Unfinished verification, Missing method call for verify(mock) while writing a JUnit test case
I am facing

```<code>org.mockito.exceptions.misusing.UnfinishedVerificationException:
Missing method call for verify(mock) here:
-> at systemservice.test1.SysParamsBuilderTest.testBuildProcessingInfoIf3(SysParamsBuilderTest.java:241)
</code>```

I have checked for all the parameters and the object as well that is being passed to verify, But not able to figure out what is causing the above exception

The condition I am trying to test,

```<code>if( request.getProcessType() == IPRequest.IPREQUEST_TYPE_DE )
{

     LookInfoIf rdr = new MCLLookInfoReader();

    String origAnatomy = accessor.getValue(AttributeRepNames.ANATOMY_INFO.getTagName());
    String origView = accessor.getValue(AttributeRepNames.VIEW_INFO.getTagName());
    String origPatSize = accessor.getValue(AttributeRepNames.PATIENT_SIZE.getTagName());
    String mclPatSize = getMclPatientSize(origPatSize);
    String boneLook = rdr.getDefaultLook(origAnatomy,origView,core.MCLConstants.IMAGETYPEBONETAG,mclPatSize);
    String tissueLook = rdr.getDefaultLook(origAnatomy,origView,core.MCLConstants.IMAGETYPESOFTTISSUETAG,mclPatSize);

    params.setProcessingLookBone(boneLook);
    params.setProcessingLookTissue(tissueLook);
        params.setAnatomy(origAnatomy);
        params.setView(origView);
        params.setPatientSize(origPatSize);

}
</code>```

Test case

```<code>@Test
    public void testBuildProcessingInfoIf3() throws Exception
    {
        IPRequest req=new IPRequest(1);//value of IPRequest.IPREQUEST_TYPE_DE

        IPSysParams iPSysParams = Mockito.mock(IPSysParams.class);
        PowerMockito.whenNew(IPSysParams.class).withNoArguments().thenReturn(iPSysParams);

        TagAccessor accessor=Mockito.mock(TagAccessor.class);

        MCLLookInfoReader rdr=Mockito.mock(MCLLookInfoReader.class);
        PowerMockito.whenNew(MCLLookInfoReader.class).withNoArguments().thenReturn(rdr);

        Mockito.when(accessor.getValue(AttributeRepNames.ANATOMY_INFO.getTagName())).thenReturn("ANATOMY_INFO");
        Mockito.when(accessor.getValue(AttributeRepNames.VIEW_INFO.getTagName())).thenReturn("VIEW_INFO");
        Mockito.when(accessor.getValue(AttributeRepNames.PATIENT_SIZE.getTagName())).thenReturn("PATIENT_SIZE");
        Mockito.when(rdr.getDefaultLook("ANATOMY_INFO","VIEW_INFO",core.MCLConstants.IMAGETYPEBONETAG,"All")).thenReturn("boneLook");
        Mockito.when(rdr.getDefaultLook("ANATOMY_INFO","VIEW_INFO",core.MCLConstants.IMAGETYPESOFTTISSUETAG,"All")).thenReturn("tissueLook");

        sysParamsBuilder.buildProcessingInfo(req, info);

        String origAnatomy=accessor.getValue(AttributeRepNames.ANATOMY_INFO.getTagName());
        assertEquals("ANATOMY_INFO",origAnatomy);

        String origView=accessor.getValue(AttributeRepNames.VIEW_INFO.getTagName());
        assertEquals("VIEW_INFO",origView);

        String origPatSize=accessor.getValue(AttributeRepNames.PATIENT_SIZE.getTagName());
        assertEquals("PATIENT_SIZE",origPatSize);

        PowerMockito.verifyPrivate(sysParamsBuilder).invoke("getMclPatientSize",origPatSize);//line 241

        String boneLook=rdr.getDefaultLook("ANATOMY_INFO","VIEW_INFO",core.MCLConstants.IMAGETYPEBONETAG,"All");
        assertEquals("boneLook",boneLook);

        String tissueLook=rdr.getDefaultLook("ANATOMY_INFO","VIEW_INFO",core.MCLConstants.IMAGETYPESOFTTISSUETAG,"All");
        assertEquals("tissueLook",tissueLook);

        Mockito.verify(iPSysParams).setProcessingLookBone(boneLook);//line 244
        Mockito.verify(iPSysParams).setProcessingLookTissue(tissueLook);

        // fill the Anatomy View accrodingly
        Mockito.verify(iPSysParams,Mockito.times(1)).setAnatomy(origAnatomy);
        Mockito.verify(iPSysParams).setView(origView);
        Mockito.verify(iPSysParams).setPatientSize(origPatSize);

    }
</code>```

stack trace

```<code>org.mockito.exceptions.misusing.UnfinishedVerificationException:
Missing method call for verify(mock) here:
-> at systemservice.test1.SysParamsBuilderTest.testBuildProcessingInfoIf3(SysParamsBuilderTest.java:241)

Example of correct verification:
    verify(mock).doSomething()

Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.

    at systemservice.test1.SysParamsBuilderTest.testBuildProcessingInfoIf3(SysParamsBuilderTest.java:244)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:66)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:86)
    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:94)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
    at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:104)
    at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
    at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:53)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
</code>```

I have done other test cases in the same way and it has worked but I don't know why its not working here, also all the methods are public. please help me figure It out, Thanks in advance

答:
from your error message:

error might show up because you verify either of: final/private/equals()/hashCode() methods.
  Those methods cannot be stubbed/verified.

So check if any of this methods

```<code>    Mockito.verify(iPSysParams).setProcessingLookBone(boneLook);
    Mockito.verify(iPSysParams).setProcessingLookTissue(tissueLook);
    Mockito.verify(iPSysParams,Mockito.times(1)).setAnatomy(origAnatomy);
    Mockito.verify(iPSysParams).setView(origView);
    Mockito.verify(iPSysParams).setPatientSize(origPatSize);
</code>```

is final.

Body:
I am facing

org.mockito.exceptions.misusing.UnfinishedVerificationException:
Missing method call for verify(mock) here:
-> at systemservice.test1.SysParamsBuilderTest.testBuildProcessingInfoIf3(SysParamsBuilderTest.java:241)

I have checked for all the parameters and the object as well that is being passed to verify, But not able to figure out what is causing the above exception

The condition I am trying to test,

if( request.getProcessType() == IPRequest.IPREQUEST_TYPE_DE )
{

     LookInfoIf rdr = new MCLLookInfoReader();

    String origAnatomy = accessor.getValue(AttributeRepNames.ANATOMY_INFO.getTagName());
    String origView = accessor.getValue(AttributeRepNames.VIEW_INFO.getTagName());
    String origPatSize = accessor.getValue(AttributeRepNames.PATIENT_SIZE.getTagName());
    String mclPatSize = getMclPatientSize(origPatSize);
    String boneLook = rdr.getDefaultLook(origAnatomy,origView,core.MCLConstants.IMAGETYPEBONETAG,mclPatSize);
    String tissueLook = rdr.getDefaultLook(origAnatomy,origView,core.MCLConstants.IMAGETYPESOFTTISSUETAG,mclPatSize);

    params.setProcessingLookBone(boneLook);
    params.setProcessingLookTissue(tissueLook);
        params.setAnatomy(origAnatomy);
        params.setView(origView);
        params.setPatientSize(origPatSize);

}

Test case

@Test
    public void testBuildProcessingInfoIf3() throws Exception
    {
        IPRequest req=new IPRequest(1);//value of IPRequest.IPREQUEST_TYPE_DE

        IPSysParams iPSysParams = Mockito.mock(IPSysParams.class);
        PowerMockito.whenNew(IPSysParams.class).withNoArguments().thenReturn(iPSysParams);

        TagAccessor accessor=Mockito.mock(TagAccessor.class);

        MCLLookInfoReader rdr=Mockito.mock(MCLLookInfoReader.class);
        PowerMockito.whenNew(MCLLookInfoReader.class).withNoArguments().thenReturn(rdr);

        Mockito.when(accessor.getValue(AttributeRepNames.ANATOMY_INFO.getTagName())).thenReturn("ANATOMY_INFO");
        Mockito.when(accessor.getValue(AttributeRepNames.VIEW_INFO.getTagName())).thenReturn("VIEW_INFO");
        Mockito.when(accessor.getValue(AttributeRepNames.PATIENT_SIZE.getTagName())).thenReturn("PATIENT_SIZE");
        Mockito.when(rdr.getDefaultLook("ANATOMY_INFO","VIEW_INFO",core.MCLConstants.IMAGETYPEBONETAG,"All")).thenReturn("boneLook");
        Mockito.when(rdr.getDefaultLook("ANATOMY_INFO","VIEW_INFO",core.MCLConstants.IMAGETYPESOFTTISSUETAG,"All")).thenReturn("tissueLook");

        sysParamsBuilder.buildProcessingInfo(req, info);

        String origAnatomy=accessor.getValue(AttributeRepNames.ANATOMY_INFO.getTagName());
        assertEquals("ANATOMY_INFO",origAnatomy);

        String origView=accessor.getValue(AttributeRepNames.VIEW_INFO.getTagName());
        assertEquals("VIEW_INFO",origView);

        String origPatSize=accessor.getValue(AttributeRepNames.PATIENT_SIZE.getTagName());
        assertEquals("PATIENT_SIZE",origPatSize);

        PowerMockito.verifyPrivate(sysParamsBuilder).invoke("getMclPatientSize",origPatSize);//line 241

        String boneLook=rdr.getDefaultLook("ANATOMY_INFO","VIEW_INFO",core.MCLConstants.IMAGETYPEBONETAG,"All");
        assertEquals("boneLook",boneLook);

        String tissueLook=rdr.getDefaultLook("ANATOMY_INFO","VIEW_INFO",core.MCLConstants.IMAGETYPESOFTTISSUETAG,"All");
        assertEquals("tissueLook",tissueLook);

        Mockito.verify(iPSysParams).setProcessingLookBone(boneLook);//line 244
        Mockito.verify(iPSysParams).setProcessingLookTissue(tissueLook);

        // fill the Anatomy View accrodingly
        Mockito.verify(iPSysParams,Mockito.times(1)).setAnatomy(origAnatomy);
        Mockito.verify(iPSysParams).setView(origView);
        Mockito.verify(iPSysParams).setPatientSize(origPatSize);

    }

stack trace

org.mockito.exceptions.misusing.UnfinishedVerificationException:
Missing method call for verify(mock) here:
-> at systemservice.test1.SysParamsBuilderTest.testBuildProcessingInfoIf3(SysParamsBuilderTest.java:241)

Example of correct verification:
    verify(mock).doSomething()

Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.

    at systemservice.test1.SysParamsBuilderTest.testBuildProcessingInfoIf3(SysParamsBuilderTest.java:244)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:66)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:86)
    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:94)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
    at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:104)
    at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
    at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:53)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

I have done other test cases in the same way and it has worked but I don't know why its not working here, also all the methods are public. please help me figure It out, Thanks in advance

Body:
from your error message:

error might show up because you verify either of: final/private/equals()/hashCode() methods.
  Those methods cannot be stubbed/verified.

So check if any of this methods

    Mockito.verify(iPSysParams).setProcessingLookBone(boneLook);
    Mockito.verify(iPSysParams).setProcessingLookTissue(tissueLook);
    Mockito.verify(iPSysParams,Mockito.times(1)).setAnatomy(origAnatomy);
    Mockito.verify(iPSysParams).setView(origView);
    Mockito.verify(iPSysParams).setPatientSize(origPatSize);

is final.


问:
ArangoDb Web Graph visualization - Select node attributes
I'm using ArangoDb Graph web interface.
I have created a graph with nodes from different collections.
As each node collection has its own attribute set, is there any way to choose different labels to be shown?

答:
there currently is no way to select the label attribute per vertex collection.

You may want to open a feature request via github, or take a look at https://github.com/arangodb/arangodb/blob/devel/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer.js#L693 - However, the used Sigma.js library has to support it in first place.


问:
Convert number to string in php
In the following I tried $code = (string)$code; with no success, how can I convert number to string in PHP?

```<code>$code = 087326487326;
$strlen = strlen($code);
print $strlen."<br/>";
for ($i = $strlen; $i >= 0; $i--) {
  print substr($code, 0, $i)."<br/>";
}
</code>```

Output:

```<code>1
0
</code>```

and

```<code>$code = '087326487326';
$strlen = strlen($code);
print $strlen."<br/>";
for ($i = $strlen; $i >= 0; $i--) {
  print substr($code, 0, $i)."<br/>";
}
</code>```

Output:

```<code>12
087326487326
08732648732
0873264873
087326487
08732648
0873264
087326
08732
0873
087
08
0
</code>```

答:
may you could be use type cast like this

```<code> $code = (string)58963245874;
</code>```

for check it you print its type like below

```<code> echo gettype($code);
</code>```

Title: Convert number to string in php

Body:
In the following I tried $code = (string)$code; with no success, how can I convert number to string in PHP?

$code = 087326487326;
$strlen = strlen($code);
print $strlen."
";
for ($i = $strlen; $i >= 0; $i--) {
  print substr($code, 0, $i)."
";
}

Output:

1
0

and

$code = '087326487326';
$strlen = strlen($code);
print $strlen."
";
for ($i = $strlen; $i >= 0; $i--) {
  print substr($code, 0, $i)."
";
}

Output:

12
087326487326
08732648732
0873264873
087326487
08732648
0873264
087326
08732
0873
087
08
0

Body:
may you could be use type cast like this

 $code = (string)58963245874;

for check it you print its type like below

 echo gettype($code);


问:
Android NDK - referencing JNIEnv to call Java from C++
I'm very new to C++ and I'm working with the Superpowered FrequencyDomain example here:
https://github.com/superpoweredSDK/Low-Latency-Android-Audio-iOS-Audio-Engine/blob/master/Examples_Android/FrequencyDomain/app/src/main/jni/FrequencyDomain.cpp

I want to continuously update a TextView with the loudest frequency being received from inside this while loop:

```<code>static bool audioProcessing(void * __unused clientdata, short int *audioInputOutput, int numberOfSamples, int __unused samplerate) {
SuperpoweredShortIntToFloat(audioInputOutput, inputBufferFloat, (unsigned int)numberOfSamples); // Converting the 16-bit integer samples to 32-bit floating point.
frequencyDomain->addInput(inputBufferFloat, numberOfSamples); // Input goes to the frequency domain.

// In the frequency domain we are working with 1024 magnitudes and phases for every channel (left, right), if the fft size is 2048.
while (frequencyDomain->timeDomainToFrequencyDomain(magnitudeLeft, magnitudeRight, phaseLeft, phaseRight)) {
</code>```

I think I need to do something like this:

```<code>jclass classs = env->FindClass("com/superpowered/frequencydomain/MainActivity");
jmethodID method = env->GetMethodID(classs, "updateTextViewFromJNI","(I)V");
env->CallVoidMethod(thiz, method, myJavaInt);
</code>```

but those are the only lines in a example C++ function which already has access to env and thiz:

```<code>void callJavaMethod(JNIEnv* env,jobject thiz) {...previous 3 lines...}
</code>```

Calling a Java function like this:

```<code>public void updateTextViewFromJNI(int i) {
    txtLoudestFreq.setText(Integer.toString(i));
}
</code>```

I've been trying different ways to getting to JNIEnv and jobject, but I haven't succeeded yet. I see they're unused here:

```<code>extern "C" JNIEXPORT void Java_com_superpowered_frequencydomain_MainActivity_FrequencyDomain(JNIEnv * __unused javaEnvironment, jobject __unused obj, jint samplerate, jint buffersize)
</code>```

but I'm not sure how to get access to them in:

```<code>audioProcessing
</code>```

I've tried making them global. From what I've read, I'm trying to get a reference to them, but missing how to do it. What steps do I need to do in order to be able to call something like this:

```<code>env->CallVoidMethod(thiz, method, myJavaInt);
</code>```

from inside audioProcessing? Thank you very much!

答:
Calling Java is not recommended from an audio processing thread, as it involves multiple blocking calls.

Env and thiz are thread specific, different from thread to thread. Getting them for the audio processing thread is a big no-no.

It's better to think the other way around:

Update an array in the audio processing callback with the results you'd like
to display.

Create a JNI function to return with the values of the array to Java.

Periodically call that JNI function from a Runnable (in Java).

Body:
I'm very new to C++ and I'm working with the Superpowered FrequencyDomain example here:
https://github.com/superpoweredSDK/Low-Latency-Android-Audio-iOS-Audio-Engine/blob/master/Examples_Android/FrequencyDomain/app/src/main/jni/FrequencyDomain.cpp

I want to continuously update a TextView with the loudest frequency being received from inside this while loop:

static bool audioProcessing(void * __unused clientdata, short int *audioInputOutput, int numberOfSamples, int __unused samplerate) {
SuperpoweredShortIntToFloat(audioInputOutput, inputBufferFloat, (unsigned int)numberOfSamples); // Converting the 16-bit integer samples to 32-bit floating point.
frequencyDomain->addInput(inputBufferFloat, numberOfSamples); // Input goes to the frequency domain.

// In the frequency domain we are working with 1024 magnitudes and phases for every channel (left, right), if the fft size is 2048.
while (frequencyDomain->timeDomainToFrequencyDomain(magnitudeLeft, magnitudeRight, phaseLeft, phaseRight)) {

I think I need to do something like this:

jclass classs = env->FindClass("com/superpowered/frequencydomain/MainActivity");
jmethodID method = env->GetMethodID(classs, "updateTextViewFromJNI","(I)V");
env->CallVoidMethod(thiz, method, myJavaInt);

but those are the only lines in a example C++ function which already has access to env and thiz:

void callJavaMethod(JNIEnv* env,jobject thiz) {...previous 3 lines...}

Calling a Java function like this:

public void updateTextViewFromJNI(int i) {
    txtLoudestFreq.setText(Integer.toString(i));
}

I've been trying different ways to getting to JNIEnv and jobject, but I haven't succeeded yet. I see they're unused here:

extern "C" JNIEXPORT void Java_com_superpowered_frequencydomain_MainActivity_FrequencyDomain(JNIEnv * __unused javaEnvironment, jobject __unused obj, jint samplerate, jint buffersize)

but I'm not sure how to get access to them in:

audioProcessing

I've tried making them global. From what I've read, I'm trying to get a reference to them, but missing how to do it. What steps do I need to do in order to be able to call something like this:

env->CallVoidMethod(thiz, method, myJavaInt);

from inside audioProcessing? Thank you very much!


问:
searching huge text file
I have a text file consisting of ~40 million of lines in the form of a key/value, I want to retrieve the values given the key within seconds (2-3) max, I don't have enough memory to store all of them in JVM memory as a hashmap, can I use system storage + some indexing to achieve that ?
i've been reading about lucene, but not sure if it's what am looking for.</p>

答: I think Hadoop it's a better tool for this task: just split the original file between the slaves. The map function is performing a search on each part of the original file, and the reduce is the combination of all findings. If the keys are unique, only one slave will provide the answer.</p>

Title: searching huge text file