如何通过合并提交找到从另一个分支合并的提交?下图中绿色的分支是master,我有commit号1的SHA但是没有注入的分支名,需要找到commits 2,3,4
J Mas's questions
当您工作的分支在远程存储库中走得很远并且在推送时,执行合并而不是 rebase 时,如何在服务器存储库一侧禁止推送使用 git merge 而不是 rebase默认。无需强制开发人员更改 git config rebase.pull true。
不幸的是只有两个EnumType
STRING
和ORDINAL
。使用时ORDINAL
,在大型项目中存在更改或删除值的危险,因此一切都会中断。我想要第三种类型NUMBER
,我们将在其中创建Enum
s 并传递应该用于数据库中记录值的数字。例如
public enum AnyType {
TREE(0), // ну или TREE(0, значения которые нужны для конструктора
CAR(1);
private final int number;
private final int age;
AnyType(int number, int age) {
this.number = number;
this.age = age;
}
并JPA
用作getNumber
将用作的值,ORDINAL
但在更改时可能会破坏的可能性较小Enum
。在获取和写入数据时如何实现或如何使用它@Enumerated(EnumType.STRING)
来提高性能?
Oracle 12c 有一个选项可以将旧数据归档在同一个表中,而无需创建新表 -在数据库归档中。它很容易使用,但我对性能和索引有疑问。
索引如何工作,尤其是唯一索引?
是否可以将这样的值添加到应该是唯一的列中?
例如,归档具有唯一1
列值的记录。col NUMBER
如果添加带有 的记录会发生什么情况,是否col = 1
会考虑归档数据?如果是,那么归档对提高性能没有多大帮助,如果不是,那么当从所有数据中进行选择时 ( visibility = all
),就会违反字段的唯一性。
它是怎么运行的?
有一个项目,其中所有内容都是用英语编写的,但有时会在 sql liquabase 和 java 代码中遇到俄语字母。在 IDEA 或 Maven 或其他工具中是否有任何方法可以找到此类非英文字母并因编译错误而失败。
如何在 git 中找出提交注释中包含某个单词的提交次数。例如,我想知道在评论中使用“STACK”一词进行了多少次提交。
- 怎样
IDENTITY_FINISH
才能加快采集器的工作?据我了解,这将节省对堆栈的几次调用(在这种情况下finisher
它返回相同的supplier
),并且考虑到收集器可以根据流的大小工作多长时间,这根本不算什么。 - 它
CONCURRENT
可以用来做什么,因为combiner
无论如何在使用时都会调用它parallelStream()
,而不管收集器是否是使用参数创建的CONCURRENT
。 - 它如何
CONCURRENT
影响正常的流()? UNORDERED
如果在任何情况下使用parallelStream()
所有内容时都不会对其进行排序,并且在使用 stream() 时,所有内容都将按照传递时的相同顺序进行处理,为什么需要它。还是我误会了?
电梯模拟器的任务,任务解决了,一切正常,但被我需要收紧算法的话拒绝了。这是什么意思,还有什么办法可以解决这个问题?
/**
* Написать программу «симулятор лифта».
* Программа запускается из коммандной строки, в качестве параметров задается:
* кол-во этажей в подъезде - N (от 5 до 20);
* высота одного этажа;
* скорость лифта при движении в метрах в секунду (ускорением пренебрегаем, считаем, что когда лифт едет - он сразу едет с определенной скоростью);
* время между открытием и закрытием дверей.
*
* После запуска программа должна постоянно ожидать ввода от пользователя и выводить действия лифта в реальном времени.
* События, которые нужно выводить:
* лифт проезжает некоторый этаж;
* лифт открыл двери;
* лифт закрыл двери.
*
* Возможный ввод пользователя:
* вызов лифта на этаж из подъезда;
* нажать на кнопку этажа внутри лифта.
*
* Считаем, что пользователь не может помешать лифту закрыть двери.
* Все данные, которых не хватает в задаче можно выбрать на свое усмотрение.
* В результате должен получиться компилируемый код (в случае с java предлагается писать код в одном файле).
*/
public class Test {
public static void main(String[] args) throws InterruptedException {
Elevator elevator = new Elevator(20, 3, 2, 2);
elevator.init();
}
private static class Elevator {
private static final long MILLISECONDS = 100; //1000
private final int doorTime;
private final int floors;
private final long floorSpeedSeconds;
private int currentFloor = 1;
private Elevator(int floors, int height, int speed, int doorTime) {
this.doorTime = doorTime;
this.floors = floors;
floorSpeedSeconds = height / speed * MILLISECONDS;
}
private void init() throws InterruptedException {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
Command command = new Command(scanner.nextLine());
if (command.targetFloor > floors) {
System.out.println("Target floor should be less than " + floors);
continue;
}
if (command.targetFloor > currentFloor) {
moveUp(command);
} else if (command.targetFloor < currentFloor) {
moveDown(command);
}
currentFloor = command.targetFloor;
openAndCloseDoor(doorTime);
}
}
private void printCurrentFloor(int i) {
System.out.println("Current floor is " + i);
}
private void openAndCloseDoor(int doorTime) throws InterruptedException {
System.out.println("Open door");
Thread.sleep(doorTime * MILLISECONDS);
System.out.println("Close door");
}
private void moveDown(Command command) throws InterruptedException {
for (int i = currentFloor; i >= command.targetFloor; i--) {
Thread.sleep(floorSpeedSeconds);
printCurrentFloor(i);
}
}
private void moveUp(Command command) throws InterruptedException {
for (int i = currentFloor; i <= command.targetFloor; i++) {
Thread.sleep(floorSpeedSeconds);
printCurrentFloor(i);
}
}
}
private static class Command {
private final PressType type;
private final int targetFloor;
private Command(String type) {
String[] commands = type.split(" ");
this.type = PressType.type(commands[0]);
this.targetFloor = parseInt(commands[1]);
}
}
private enum PressType {
IN("in"),
OUT("out");
private final String type;
PressType(String type) {
this.type = type;
}
private static PressType type(String s) {
return valueOf(s);
}
}
}
我对 Kotlin 中的访问修饰符有疑问internal
- 为什么决定删除访问修饰符
package
?毕竟,它也很有用,尤其是当应用程序体系结构不是按层而是按功能划分时。 - 是否有可能在
internal
默认情况下以某种方式制作修饰符,但是public
如果有任何插件,你会写吗? - 为什么
public
默认?其实public
在 Java 中它比 package 更常用,但是如果 Kotline 有internal
,在模块化项目甚至在微服务中会更常用internal
(前提是开发者注意尽量减少访问)
有一个包含多个模块的单体应用程序,您需要选择放置 API 接口和数据结构的位置。有两个选项假设有两个模块module1和module2
- 将 module1 的 API 包与接口放在 module1 中,并且将其暴露在外部以供其他模块使用,实现将在 module1/server.xml 中。
- 将 module1 的 API 包与接口放在将使用这些接口的 module2 模块中,实现将在 module1/serer 中。
有什么优点和缺点,哪个更好用?
我在 JetBrains Help 网站上看到,Build 阶段的 Intellij Idea 并没有重用 maven 制作的编译结果,而是从头开始构建所有内容。
在使用 Maven 输出目录下它说
如果未选中此复选框,将在常规 IntelliJ IDEA 的输出目录 USER_HOME\IdeaProjects<project>\classes\Production 中创建构建。如果选中此复选框,则在 Maven 的输出目录中生成构建,并重用 IntelliJ IDEA 的编译结果。但是,IntelliJ IDEA 本身并没有重用 Maven 构建结果,而是从头开始编译。
有一个 Car 表包含另一个 Door 表,您需要找到具有特定门的合适汽车,我制作了门的 flatMap 并根据门的条件对其进行过滤。
List<Car> list = new ArrayList<>();
list.stream()
.map(Car::doors)
.flatMap(Collection::stream)
.filter(c -> c.getCode().equals(codeParam))
.filter(c -> c.getCode().equals(codeParam))// Другие условия
.filter(c -> c.getCode().equals(codeParam))// Другие условия
.max(this::compareDoors)
.orElse(null);//вот здесь хотелось бы вернуть Car, но вернуть можно только Door
您可以添加另一个流,它已经被 Car.doors 中的 Door 元素的内容过滤,或者不使用 map 和 flatmap,并添加一个长条件来过滤,其中将再次有另一个流。
但是是否有可能在没有额外流的情况下返回 Car 或者以某种方式使用 StreamEx 库(我没有在库中找到这样做的方法)?
IDE 每次在运行 mvn clean install 后重新下载工件,甚至在启动它也下载了这些工件的运行器之后。
启动后,mvn clean install
我在 IDE 中使用 Run Configuration Maven 启动 Tomcat 服务器,但不是启动服务器,而是下载构建 maven 时已经下载的 SNAPSHOT 工件。我停止服务器并重新启动服务器,每次重新启动服务器时,IDE 都会一次又一次地下载相同的工件。
如果您Work Offline
在 IDE 设置中选中该框,则在启动时它会写入
[ERROR] Failed to execute goal on project ****.application.war: Could not resolve dependencies for project com.*****.application.war:war:251.0.0-SNAPSHOT: The following artifacts could not be resolved: com.*****.application.server:jar:251.0.0-SNAPSHOT, com.*****.common:jar:251.0.0-
Always update snapshot
未设置复选框
我启动了mvn clean install
,然后我点run
进去了Intellij IDEA
,但是它IDE
重新做build
了,虽然所有的代码都被maven成功编译了。是否有可能使它不再编译,因为一切都已经成功编译?
我无法调整 FloatingActionButton 的大小,我正在传递一个“加号”图像,它是一个矢量。在vectore指向中更改黑色加号的大小
android:width="64dp"
android:height="64dp"
应用程序启动时实际大小不会改变。同时设置 64dp 和 200dp
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/red">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:contentDescription="@string/Green"
android:src="@drawable/ic_menu_add_black_24dp"
style="@style/Widget.MaterialComponents.FloatingActionButton"
app:backgroundTint="@color/green"
android:background="@color/red"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" />
ic_menu_add_black_24dp.xml
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?colorControlNormal"
android:pathData="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v3z" />
<path
android:pathData="M0 0h24v24H0z" />
无法将 RecyclreView 从工具栏(写入“Home”的位置)定位到 BottomNavigationView 的顶部边框。我尝试使用 Studio 工具。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/red"
android:paddingTop="?attr/actionBarSize">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0FAA0F"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
app:navGraph="@navigation/mobile_navigation" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
我尝试了不同的方案,将其添加到 RecyclerView
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
结果是一样的,toolbar和RecyclerView之间有空隙,下边框超出了BottomNavigationView,虽然我希望只到BottomNavigationView的上边框
我还将 app:layout_constraintBottom_toTopOf="@id/nav_view" 插入到 recyclerView
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/red">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="@id/nav_view" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
我可以找到合并提交属于哪个提交
git rev-list hash1..master --ancestry-path
这将返回一个提交列表,其中列表中的最后一个是 hash1 提交的合并提交。我是否也可以找到它,但只能在相反的方向,有一个合并提交的哈希,找出它在合并期间创建了哪些提交,例如,我在 dev 分支上做了三个提交并在 master 中冻结,在这个如果创建了合并提交,这里是哈希合并 commita 想要找到这三个提交。
git show -s --pretty=%P 460f49a3
显示了两个提交,第一个是这三个提交中的最后一个提交(如果取自上一个示例),第二个是与这些提交无关的提交
有一组像“青苹果”这样的句子,每个句子有 2 到 7 个单词。您需要在其中找到,例如,使用“gra”或“gap”等关键字的“Green Apple”。我怎样才能做到这一点?
如何从指向 int 的指针复制到新变量中,我正在尝试
int *wordC = new int[length + 2];
int *сopy = new int[length + 2];
copy(wordС, wordС, сopy);
在这种方法中,输出数组副本保留相同的垃圾。第二个问题,几乎是一样的,是
char* file = new char[length];
您只需将文件的一部分复制到新数组中,例如从位置 10 到 16(在运行时只知道从何处复制以及复制多少)